the last few days have been quite exhausting but it was worth it. I now understand webgl2 shader much better.
now i face the next challenge. I want to create a 3D texture. With a shader I could use powerful noise functions. But the question that arises for me is the following: how do I get the texel datas from the shader, which are in the GPU, into my Data3DTexture?
maybe this pseudocode will help to better illustrate what I want
//Values for the Data3DTexture
const size = 128;
const data = new Uint8Array( size * size * size );
//---------------------------------------------------------------------------------------------
// what I imagine is a shader which generates the texels for the Data3DTexture
const FS =`
in int size; //x, y, z
out vec4 Color;
someNoisefunction(vec3 coord){
...code...
}
void main(){
ivec3 pixel = ivec3(gl_GlobalInvocationID.xyz); //something like that but i need a webgl2 equivalent
Color = texelFetch(someNoisefunction(pixel), pixel);
}`;
data = reseive all texels from shader
//---------------------------------------------------------------------------------------------
//now create Data3DTexture
const texture = new THREE.Data3DTexture( data, size, size, size );
does anyone know of an example in which a Data3DTexture is filled using a shader?