-
Notifications
You must be signed in to change notification settings - Fork 23
Revisit Reflection Probe implementation #66
Description
From Hubs-Foundation/hubs#5570
Description of the problem
Our Reflection probe implementation may be a bit danger. Because it switches envMap and envMap2 after setting up WebGL programs.
The Three.js renderer and other webgl modules generate shader code, get program cache, decide whether to change program, and so on, from material (and other objects) properties.
https://github.com/MozillaReality/three.js/blob/7c6fb585ffa7737544871d2bbd4b0864c316f148/src/renderers/WebGLRenderer.js
https://github.com/MozillaReality/three.js/blob/262eb259a1f92c3554a11353b7f52c13900f879e/src/renderers/webgl/WebGLProgram.js
https://github.com/MozillaReality/three.js/blob/12f550e0f44f68e5b6c946dd242ee08e42d209e4/src/renderers/webgl/WebGLPrograms.js
Switching envMap after setting up them can cause mismatch.
More proper implementation may be setting up envMap/2 first and then include them in the decision of shader code generation, program cache, and so on. (Or using the renderer hooks? I haven't deeply dug into them yet tho.)