浏览代码

Refactored shadow coordinates generation to use less matrix multiplications.

alteredq 13 年之前
父节点
当前提交
8c25afa53f
共有 3 个文件被更改,包括 12 次插入10 次删除
  1. 0 0
      build/Three.js
  2. 0 0
      build/custom/ThreeWebGL.js
  3. 12 10
      src/renderers/WebGLShaders.js

文件差异内容过多而无法显示
+ 0 - 0
build/Three.js


文件差异内容过多而无法显示
+ 0 - 0
build/custom/ThreeWebGL.js


+ 12 - 10
src/renderers/WebGLShaders.js

@@ -1357,25 +1357,27 @@ THREE.ShaderChunk = {
 
 		"#ifdef USE_SHADOWMAP",
 
-			"for( int i = 0; i < MAX_SHADOWS; i ++ ) {",
+			"vec4 transformedPosition;",
 
-				"#ifdef USE_MORPHTARGETS",
+			"#ifdef USE_MORPHTARGETS",
 
-					"vShadowCoord[ i ] = shadowMatrix[ i ] * objectMatrix * vec4( morphed, 1.0 );",
+				"transformedPosition = objectMatrix * vec4( morphed, 1.0 );",
 
-				"#else",
+			"#else",
+			"#ifdef USE_SKINNING",
 
-				"#ifdef USE_SKINNING",
+				"transformedPosition = objectMatrix * skinned;",
 
-					"vShadowCoord[ i ] = shadowMatrix[ i ] * objectMatrix * skinned;",
+			"#else",
 
-				"#else",
+				"transformedPosition = objectMatrix * vec4( position, 1.0 );",
 
-					"vShadowCoord[ i ] = shadowMatrix[ i ] * objectMatrix * vec4( position, 1.0 );",
+			"#endif",
+			"#endif",
 
-				"#endif",
+			"for( int i = 0; i < MAX_SHADOWS; i ++ ) {",
 
-				"#endif",
+				"vShadowCoord[ i ] = shadowMatrix[ i ] * transformedPosition;",
 
 			"}",
 

部分文件因为文件数量过多而无法显示