3d texture min size should be 16x16x16...

This commit is contained in:
Gyuri Horák 2023-03-23 13:47:51 +01:00
parent 8ae0907fda
commit 0fb709ff7c
Signed by: dyuri
GPG Key ID: 4993F07B3EAE8D38

View File

@ -289,34 +289,34 @@ class RepaShader extends HTMLElement {
this._gl.texParameteri(this._gl.TEXTURE_3D, this._gl.TEXTURE_MAG_FILTER, this._gl.NEAREST); this._gl.texParameteri(this._gl.TEXTURE_3D, this._gl.TEXTURE_MAG_FILTER, this._gl.NEAREST);
this._gl.texParameteri(this._gl.TEXTURE_3D, this._gl.TEXTURE_WRAP_S, this._gl.CLAMP_TO_EDGE); this._gl.texParameteri(this._gl.TEXTURE_3D, this._gl.TEXTURE_WRAP_S, this._gl.CLAMP_TO_EDGE);
this._gl.texParameteri(this._gl.TEXTURE_3D, this._gl.TEXTURE_WRAP_T, this._gl.CLAMP_TO_EDGE); this._gl.texParameteri(this._gl.TEXTURE_3D, this._gl.TEXTURE_WRAP_T, this._gl.CLAMP_TO_EDGE);
this._gl.texParameteri(this._gl.TEXTURE_3D, this._gl.TEXTURE_WRAP_R, this._gl.CLAMP_TO_EDGE);
// ???
this._gl.texParameteri(this._gl.TEXTURE_3D, this._gl.TEXTURE_BASE_LEVEL, 0);
this._gl.texParameteri(this._gl.TEXTURE_3D, this._gl.TEXTURE_MAX_LEVEL, 0);
let size = 32;
let t3data = new Uint8Array(size * size * size);
for (let i = 0; i < size; i++) {
for (let j = 0; j < size; j++) {
for (let k = 0; k < size; k++) {
let index = i * size * size + j * size + k;
t3data[index] = (i * j * k) % 255;
}
}
}
this._gl.texImage3D( this._gl.texImage3D(
this._gl.TEXTURE_3D, // target this._gl.TEXTURE_3D, // target
0, // level 0, // level
this._gl.R8, // format - red8 (1byte) this._gl.R8, // format - red8 (1byte)
3, // width size, // width
3, // height size, // height
3, // depth size, // depth
0, // border 0, // border
this._gl.RED, // format - red this._gl.RED, // format - red
this._gl.UNSIGNED_BYTE, // type - unsigned byte this._gl.UNSIGNED_BYTE, // type - unsigned byte
new Uint8Array([ t3data // data
0, 0, 0,
0, 127, 0,
0, 0, 0,
0, 127, 0,
127, 255, 127,
0, 127, 0,
0, 0, 0,
0, 127, 0,
0, 0, 0,
127, 0, 127,
0, 0, 0,
127, 0, 127,
]) // data
); );
this._textures3d = []; this._textures3d = [];
@ -324,9 +324,9 @@ class RepaShader extends HTMLElement {
texture, texture,
texElement: { texElement: {
name: 'test3d', name: 'test3d',
width: 3, width: size,
height: 3, height: size,
depth: 3, depth: size,
}, },
}); });
// TODO end of 3d texture experiment // TODO end of 3d texture experiment