Fixed ordered dithering offset

This commit is contained in:
Lucas Dower 2021-11-19 21:46:02 +00:00
parent 31f9a93bb1
commit d310cc6b20

View File

@ -16,17 +16,17 @@ export class OrderedDitheringBlockAssigner implements BlockAssigner {
/** 4x4x4 */
private static _size = 4;
private static _threshold = 256/4;
private static _threshold = 256 / 8;
private static _mapMatrix = [
0, 16, 2, 18, 48, 32, 50, 34,
6, 22, 4, 20, 54, 38, 52, 36,
24, 40, 26, 42, 8, 56, 10, 58,
0, 16, 2, 18, 48, 32, 50, 34,
6, 22, 4, 20, 54, 38, 52, 36,
24, 40, 26, 42, 8, 56, 10, 58,
30, 46, 28, 44, 14, 62, 12, 60,
3, 19, 5, 21, 51, 35, 53, 37,
1, 17, 7, 23, 49, 33, 55, 39,
27, 43, 29, 45, 11, 59, 13, 61,
25, 41, 31, 47, 9, 57, 15, 63
3, 19, 5, 21, 51, 35, 53, 37,
1, 17, 7, 23, 49, 33, 55, 39,
27, 43, 29, 45, 11, 59, 13, 61,
25, 41, 31, 47, 9, 57, 15, 63
];
private _getThresholdValue(x: number, y: number, z: number) {
@ -34,7 +34,7 @@ export class OrderedDitheringBlockAssigner implements BlockAssigner {
assert(0 <= x && x < size && 0 <= y && y < size && 0 <= z && z < size)
const index = (x + (size * y) + (size * size * z));
assert(0 <= index && index < size * size * size);
return OrderedDitheringBlockAssigner._mapMatrix[index] / (size * size * size);
return (OrderedDitheringBlockAssigner._mapMatrix[index] / (size * size * size)) - 0.5;
}
assignBlock(voxelColour: RGB, voxelPosition: Vector3): BlockInfo {