dither3dplugin
Cuts the frame to a few bits of colour with an ordered dither, at a lower resolution, as a PlayStation did.
Putting it in a scene
Add it to plugins with render3d. It is not applied until it is first turned on.
"plugins": ["loader", "scenemanager", "player", "skydome3d", "render3d", "dither3d"],
"world": {
"dither3d": {
"on": true,
"bits": 5,
"matrix": [-4, 0, -3, 1, 2, -2, 3, -1, -3, 1, -4, 0, 3, -1, 2, -2],
"ratio": 0.25
}
}
Properties
Read from world.dither3d. on, bits and ratio can also be read and written while the game runs, on plugins.dither3d. Each value written is checked as the scene's are.
.on : boolean
Whether it draws. Turning it off passes it over and returns to render3d's own resolution if ratio had set one.
.bits : number
The bits each of red, green and blue keeps, a whole number from 1 to 8. The PlayStation's 15-bit colour keeps 5.
.matrix : number[16]
The 4×4 dither pattern, 16 offsets in steps of 1/255 of full scale, row by row from the canvas's top left. Each pixel has its tile position's offset added to its colour before the colour is cut to bits. All zeros gives a plain cut with no dither. The example above is the PlayStation's.
.ratio : number
Optional. The pixels drawn per canvas pixel while it is on, shown as hard squares. 0.25 draws a 1280×720 canvas at 320×180, and the dither tile is then 4 drawn pixels. Left out, the resolution is render3d's.