geometry: sample pixels from their centers
This commit is contained in:
parent
60a2e8f19e
commit
ef88325fc8
24
geometry.js
24
geometry.js
@ -1,18 +1,22 @@
|
||||
import { memoize } from "./memoize";
|
||||
|
||||
function _makeTextureFace(texture) {
|
||||
const textMul = 0.0625;
|
||||
const textOff = texture.map(x => x * textMul);
|
||||
const textureWidth = 16;
|
||||
const texturesPerAtlas = 16;
|
||||
const textMul = 1 / texturesPerAtlas;
|
||||
const halfPixel = 1 / texturesPerAtlas / textureWidth / 2;
|
||||
const textOff = texture.map(x => x * textMul + halfPixel);
|
||||
const a = textMul / textureWidth * (textureWidth - 1);
|
||||
const textuv = [
|
||||
[0.99, 0.99],
|
||||
[0.01, 0.99],
|
||||
[0.01, 0.01],
|
||||
[0.99, 0.99],
|
||||
[0.01, 0.01],
|
||||
[0.99, 0.01],
|
||||
[1, 1],
|
||||
[0, 1],
|
||||
[0, 0],
|
||||
[1, 1],
|
||||
[0, 0],
|
||||
[1, 0],
|
||||
];
|
||||
|
||||
const textures = textuv.map(uv => uv.map((x, j) => textMul * x + textOff[j]));
|
||||
const textures = textuv.map(uv => uv.map((x, j) => a * x + textOff[j]));
|
||||
|
||||
return textures;
|
||||
}
|
||||
@ -124,4 +128,4 @@ export function makeBufferFromFaces(gl, faces) {
|
||||
numVertices,
|
||||
delete: () => gl.deleteBuffer(glBuffer),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user