Problem with Reflector affecting lighting when its texture is rendered.

Description of the problem

I have a problem with changes to lighting when Reflector object is used.

I have distilled the problem down here:
https://jsfiddle.net/cmd4/9zLhq9Lf/
You should see that the lighting on the walls changes whenever you rotate the view, as the mirror changes between facing towards and away from the camera.

Note that to show the problem, it seems to require adding the Reflector object before the first render, and the rest of the scene after the first render. i.e. If I create the whole scene before the first render, then I don’t seem to get any issues.

My guess is that the problem may be related to setting up GL state for the point light when rendered for both the main camera and the “virtual” camera created by the Reflector class.

Maybe in this function below, but here I am out of my depth:
(from https://github.com/mrdoob/three.js/blob/dev/src/renderers/webgl/WebGLLights.js)

setup( lights, shadows, camera )
 {
...
	var viewMatrix = camera.matrixWorldInverse;
...
	} else if ( light.isSpotLight ) {
                     var uniforms = cache.get( light );
                     uniforms.position.setFromMatrixPosition( light.matrixWorld );
                     uniforms.position.applyMatrix4( viewMatrix ); <<<<HERE???
...

Three.js version
  • Master
  • r88
Browser
  • Chrome
  • Firefox
  • Edge
OS
  • Windows
  • macOS
  • Linux
  • Android
  • iOS

Author: Fantashit

1 thought on “Problem with Reflector affecting lighting when its texture is rendered.

  1. Just for info: I can confirm that updating to r90 fixed the problems I was having with Reflector in my application. Thank you! 🙂

Comments are closed.