Просмотр исходного кода

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 6 лет назад
Родитель
Сommit
eaa4a987e2

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

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

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

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

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

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

粤ICP备19079148号