Does CubeTexture support DataTexture?

Hi,
I load .pfm files to DataTextures 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! :blush:

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;
}

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

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. :sweat_smile:

Nope, Texture.type is not important in this case.

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!

You also need to set the type for the cube texture:

https://jsfiddle.net/rk59gf7u/

2 Likes

Thank you for the patient help. Am I right on what I add in the problem description? :thinking:

Um, what are you referring to?