At some moment in the scene, all my textures turn black, multiple geos / mats / meshes, with no errors logged.
It seems unintended, that it can break the whole scene (?).
I narrowed it down to the interaction of one geometry’s color attribute and shader.
The values are in the range of 0-65535, and if set them all to 0, there’s no issue.
Ok if don’t touch values in the buffer attribute and I replace all uses in the custom shader chunk of color.r, color.g, color.b with 1.0, everything breaks still. But if I replace with 0., it is fine. Making progress.
edit: added an update. the error seems conditional on PMREM generator / scene.envMap
A curiosity, are you using post-processing at all? Once I had a similar issue, and in my case it was fixed when I removed some of the postprocessing functions I was using.
Which postproc? I am using pmndrs/postprocessing, but only doing a tonemapping pass right now.
Here is a pmndrs/postprocessing tonemapping
example.
Only way I can get everything to black is to slide middleGrey
to 0
It’s not likely a tone mapping issue.
It only affects textures, which become black.
The error is here:
// VALUE = 0.; // no error
// VALUE = 1.; // error
// VALUE = 0.001; // no error
// If comment out this line, no error
displace.xyz += normal * noise * VALUE * _force * 6.3;
// If remove the normal, no error
// displace.xyz += noise * VALUE * _force * 6.3;
// Updated findings:
// no error
// displace.xyz += vec3(normal.x, 1., normal.z) * noise;
// error
// displace.xyz += vec3(normal.x, normal.y, normal.z) * noise;
mvPosition = modelViewMatrix * vec4(owc + displace.xyz, 1.) ;
gl_Position = projectionMatrix * mvPosition;
Another clue is the ‘catastrophic all textures go black’ error can be prevented by turning off this part of the code (PMREM Generator):
const cameraWorldPos = new THREE.Vector3();
const pmremGen = new THREE.PMREMGenerator(this.renderer);
let pmremTarget;
this.loop.beforeRender = () => {
this.cubeCamera.counter += 1;
if (this.cubeCamera.counter % 360 === 0) {
this.camera.getWorldPosition(cameraWorldPos);
this.cubeCamera.position.copy(cameraWorldPos);
this.cubeCamera.update(this.renderer, this.scene);
// feedback loop fix? it works, but idk just a guess
// [.WebGL-0x1090004b9c00] GL_INVALID_OPERATION: Feedback loop formed between Framebuffer and active Texture.
this.renderer.setRenderTarget(null);
let t;
// Re-use the target, otherwise PMREM allocates a target / texture per call
if (pmremTarget) {
t = pmremGen.fromCubemap(this.cubeRenderTarget.texture, pmremTarget);
}
else {
t = pmremGen.fromCubemap(this.cubeRenderTarget.texture);
pmremTarget = t;
}
t.texture.needsPMREMUpdate = false;
this.scene.environment = t.texture;
}
}