|
@@ -1793,48 +1793,28 @@ class WebGLRenderer {
|
|
|
|
|
|
if ( refreshProgram || _currentCamera !== camera ) {
|
|
|
|
|
|
+ // common camera uniforms
|
|
|
+
|
|
|
p_uniforms.setValue( _gl, 'projectionMatrix', camera.projectionMatrix );
|
|
|
+ p_uniforms.setValue( _gl, 'viewMatrix', camera.matrixWorldInverse );
|
|
|
|
|
|
- if ( capabilities.logarithmicDepthBuffer ) {
|
|
|
+ const uCamPos = p_uniforms.map.cameraPosition;
|
|
|
|
|
|
- p_uniforms.setValue( _gl, 'logDepthBufFC',
|
|
|
- 2.0 / ( Math.log( camera.far + 1.0 ) / Math.LN2 ) );
|
|
|
+ if ( uCamPos !== undefined ) {
|
|
|
|
|
|
- }
|
|
|
-
|
|
|
- if ( _currentCamera !== camera ) {
|
|
|
-
|
|
|
- _currentCamera = camera;
|
|
|
-
|
|
|
- // lighting uniforms depend on the camera so enforce an update
|
|
|
- // now, in case this material supports lights - or later, when
|
|
|
- // the next material that does gets activated:
|
|
|
-
|
|
|
- refreshMaterial = true; // set to true on material change
|
|
|
- refreshLights = true; // remains set until update done
|
|
|
+ uCamPos.setValue( _gl, _vector3.setFromMatrixPosition( camera.matrixWorld ) );
|
|
|
|
|
|
}
|
|
|
|
|
|
- // load material specific uniforms
|
|
|
- // (shader material also gets them for the sake of genericity)
|
|
|
-
|
|
|
- if ( material.isShaderMaterial ||
|
|
|
- material.isMeshPhongMaterial ||
|
|
|
- material.isMeshToonMaterial ||
|
|
|
- material.isMeshStandardMaterial ||
|
|
|
- material.envMap ) {
|
|
|
-
|
|
|
- const uCamPos = p_uniforms.map.cameraPosition;
|
|
|
-
|
|
|
- if ( uCamPos !== undefined ) {
|
|
|
-
|
|
|
- uCamPos.setValue( _gl,
|
|
|
- _vector3.setFromMatrixPosition( camera.matrixWorld ) );
|
|
|
+ if ( capabilities.logarithmicDepthBuffer ) {
|
|
|
|
|
|
- }
|
|
|
+ p_uniforms.setValue( _gl, 'logDepthBufFC',
|
|
|
+ 2.0 / ( Math.log( camera.far + 1.0 ) / Math.LN2 ) );
|
|
|
|
|
|
}
|
|
|
|
|
|
+ // consider moving isOrthographic to UniformLib and WebGLMaterials, see https://github.com/mrdoob/three.js/pull/26467#issuecomment-1645185067
|
|
|
+
|
|
|
if ( material.isMeshPhongMaterial ||
|
|
|
material.isMeshToonMaterial ||
|
|
|
material.isMeshLambertMaterial ||
|
|
@@ -1846,16 +1826,16 @@ class WebGLRenderer {
|
|
|
|
|
|
}
|
|
|
|
|
|
- if ( material.isMeshPhongMaterial ||
|
|
|
- material.isMeshToonMaterial ||
|
|
|
- material.isMeshLambertMaterial ||
|
|
|
- material.isMeshBasicMaterial ||
|
|
|
- material.isMeshStandardMaterial ||
|
|
|
- material.isShaderMaterial ||
|
|
|
- material.isShadowMaterial ||
|
|
|
- object.isSkinnedMesh ) {
|
|
|
+ if ( _currentCamera !== camera ) {
|
|
|
+
|
|
|
+ _currentCamera = camera;
|
|
|
+
|
|
|
+ // lighting uniforms depend on the camera so enforce an update
|
|
|
+ // now, in case this material supports lights - or later, when
|
|
|
+ // the next material that does gets activated:
|
|
|
|
|
|
- p_uniforms.setValue( _gl, 'viewMatrix', camera.matrixWorldInverse );
|
|
|
+ refreshMaterial = true; // set to true on material change
|
|
|
+ refreshLights = true; // remains set until update done
|
|
|
|
|
|
}
|
|
|
|