ToniFF
December 16, 2019, 9:37am
1
Hi,
I load .pfm
files to DataTexture
s and construct a CubeTexture
which named envMapDiffuse
by the data textures.
But I get all black in shader:
gl_FragColor = vec4(textureCube(envMapDiffuse, envDir).rgb, 1);
return;
I have checked that the float data is read and envDir
is right.
I want to make sure that if this works theoretically, thanks!
BTW: Except for setting the texture type, it seems like that apply samplerCube uniform value when define uniforms in construct function of my ShaderMaterial is useless. I need apply it by a separete sentence.
constructor() {
// This doesn't really apply the map:
this.uniforms = THREE.UniformsUtils.merge([
THREE.UniformsLib.lights,
{
envMapDiffuse: {
value: envMapDiffuse // const CubeTexture
}
}
]);
// This works:
this.uniforms.envMapDiffuse.value = envMapDiffuse;
}
Mugen87
December 16, 2019, 11:15am
2
Yes, you can create an instance of CubeTexture
with DataTextures
.
Live example: https://jsfiddle.net/0mnygezs
Move the camera around to see all sides of the skybox.
2 Likes
ToniFF
December 16, 2019, 11:41am
3
Thank you very much! But my data are floats. Does it make any difference? I don’t know how to modify your fiddle to process floats.
Mugen87
December 16, 2019, 12:29pm
4
Nope, Texture.type
is not important in this case.
ToniFF
December 16, 2019, 12:50pm
5
I try to fill float datas in your fiddle: https://jsfiddle.net/qc4pokgm/1/
But it becomes black, please tell me what goes wrong, thanks!
Mugen87
December 16, 2019, 12:58pm
6
You also need to set the type for the cube texture:
https://jsfiddle.net/rk59gf7u/
2 Likes
ToniFF
December 16, 2019, 1:34pm
7
Thank you for the patient help. Am I right on what I add in the problem description?
Mugen87
December 16, 2019, 2:37pm
8
Um, what are you referring to?