Parcourir la source

Revert "Revert "Share isPerspective code""

This reverts commit 0b621c65fea07ef9e51cc80372f997fb55c12615.
Mr.doob il y a 5 ans
Parent
commit
0c9a786bc8

+ 6 - 0
src/renderers/shaders/ShaderChunk/common.glsl.js

@@ -109,5 +109,11 @@ float linearToRelativeLuminance( const in vec3 color ) {
 
 	return dot( weights, color.rgb );
 
+}
+
+bool isPerspectiveMatrix( mat4 projectionMatrix ) {
+
+  return projectionMatrix[ 2 ][ 3 ] == - 1.0;
+
 }
 `;

+ 1 - 1
src/renderers/shaders/ShaderLib/points_vert.glsl.js

@@ -20,7 +20,7 @@ void main() {
 
 	#ifdef USE_SIZEATTENUATION
 
-		bool isPerspective = ( projectionMatrix[ 2 ][ 3 ] == - 1.0 );
+		bool isPerspective = isPerspectiveMatrix( projectionMatrix );
 
 		if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );
 

+ 1 - 1
src/renderers/shaders/ShaderLib/sprite_vert.glsl.js

@@ -20,7 +20,7 @@ void main() {
 
 	#ifndef USE_SIZEATTENUATION
 
-		bool isPerspective = ( projectionMatrix[ 2 ][ 3 ] == - 1.0 );
+		bool isPerspective = isPerspectiveMatrix( projectionMatrix );
 
 		if ( isPerspective ) scale *= - mvPosition.z;