I’m trying to understand how to preprocess envMaps correctly with the PMREMGenerator.
My current situation:
I create a PMREM immediately after setting up my scene, and compile its equirectangular shader (that compile step is not clear to me, but that’s what I’ve seen in examples):
this.mPmremGenerator = new THREE.PMREMGenerator(this.mRenderer);
this.mPmremGenerator.compileEquirectangularShader();
Next, I use TextureLoader to load the envmap texture, and in its callback, I use fromEquirectangular
to preprocess the envmap into a RenderTarget
, and extract the new texture from it and return it.
private preprocessEnvMap(pEnvMap: Texture) {
const WorldContext.mainScene.pmremGenerator;
return aPmremGenerator.fromEquirectangular(pEnvMap).texture;
}
Finally, I take the returned texture, assign it as my material’s envMap
, and call the material’s needsUpdate = true
.
The result is that I get a shader error:
THREE.WebGLProgram: shader error: 0 35715 false gl.getProgramInfoLog No compiled fragment shader when at least one graphics shader is attached.
Help will be much appreciated,
Thanks
EDIT:
My envmap is equirectnagular, not a cubemap.
I noticed that PMREMGenerator
gives the texture it creates a name containing “cubeUv”. What’s the explanation for that?
Also, the image property of the returned texture only has its width and height set, and nothing else.