Closed trusktr closed 1 year ago
Yup, the material uses #defines
for camera type to avoid branching since changing camera type is not a common usecase.
You can use another material with for the other camera, and then switch the material at runtime when needed. You can use the materialIndex
property if you want to precompile the material.
onBeforeCompile
only ever runs once, initially, and never again. Therefore if someone does this:the shader's
ORTHOGRAPHIC
define will not be defined.And conversely, if the user starts with an
OrthographicCamera
then later switches to aPerspectiveCamera
,ORTHOGRAPHIC
will still be defined.This leads to the shader's conditional branches running the wrong code, not matching the camera that is used.
The issue with
onBeforeCompile
, and how to make it work, is described here:https://discourse.threejs.org/t/onbeforecompile-fires-only-once-although-i-set-needsupdate-true/38614