Ver Fonte

Share tangent space matrix between regular and clearcoat normals

In case a material has both regular and clearcoat normal maps and is using vertex tangents, we can compute the tangent space matrix made out of the three basis vectors once and use it for both regular and clearcoat normals.
Olli Etuaho há 6 anos atrás
pai
commit
eaa4a987e2

+ 1 - 2
src/renderers/shaders/ShaderChunk/clearcoat_normal_fragment_maps.glsl.js

@@ -6,8 +6,7 @@ export default /* glsl */`
 
 	#ifdef USE_TANGENT
 
-		mat3 vClearcoatTBN = mat3( tangent, bitangent, clearcoatNormal );
-		clearcoatNormal = normalize( vClearcoatTBN * clearcoatMapN );
+		clearcoatNormal = normalize( vTBN * clearcoatMapN );
 
 	#else
 

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

@@ -29,6 +29,12 @@ export default /* glsl */`
 
 		#endif
 
+		#if defined( TANGENTSPACE_NORMALMAP ) || defined( USE_CLEARCOAT_NORMALMAP )
+
+			mat3 vTBN = mat3( tangent, bitangent, normal );
+
+		#endif
+
 	#endif
 
 #endif

+ 0 - 1
src/renderers/shaders/ShaderChunk/normal_fragment_maps.glsl.js

@@ -25,7 +25,6 @@ export default /* glsl */`
 
 	#ifdef USE_TANGENT
 
-		mat3 vTBN = mat3( tangent, bitangent, normal );
 		normal = normalize( vTBN * mapN );
 
 	#else

粤ICP备19079148号