Преглед изворни кода

common.glsl: transformNormal -> transformDirection and inverseTransformNormal -> inverseTransformDirection.

Ben Houston пре 10 година
родитељ
комит
92c8bda8ec

+ 2 - 2
src/renderers/shaders/ShaderChunk/common.glsl

@@ -20,11 +20,11 @@ float whiteCompliment( in float a ) { return saturate( 1.0 - a ); }
 vec2  whiteCompliment( in vec2 a )  { return saturate( vec2(1.0) - a ); }
 vec3  whiteCompliment( in vec3 a )  { return saturate( vec3(1.0) - a ); }
 vec4  whiteCompliment( in vec4 a )  { return saturate( vec4(1.0) - a ); }
-vec3 transformNormal( in vec3 normal, in mat4 matrix ) {
+vec3 transformDirection( in vec3 normal, in mat4 matrix ) {
 	return normalize( ( matrix * vec4( normal, 0.0 ) ).xyz );
 }
 // http://en.wikibooks.org/wiki/GLSL_Programming/Applying_Matrix_Transformations
-vec3 inverseTransformNormal( in vec3 normal, in mat4 matrix ) {
+vec3 inverseTransformDirection( in vec3 normal, in mat4 matrix ) {
 	return normalize( ( vec4( normal, 0.0 ) * matrix ).xyz );
 }
 vec3 projectOnPlane(in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal) {

+ 2 - 2
src/renderers/shaders/ShaderChunk/envmap_fragment.glsl

@@ -5,7 +5,7 @@
 		vec3 cameraToVertex = normalize( vWorldPosition - cameraPosition );
 
 		// Transforming Normal Vectors with the Inverse Transformation
-		vec3 worldNormal = inverseTransformNormal( normal, viewMatrix );
+		vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
 
 		#ifdef ENVMAP_MODE_REFLECTION
 
@@ -39,7 +39,7 @@
 		vec4 envColor = texture2D( envMap, sampleUV );
 		
 	#elif defined( ENVMAP_TYPE_SPHERE )
-		vec3 reflectView = flipNormal * ( transformNormal( reflectVec, viewMatrix ) + vec3(0.0,0.0,1.0) );
+		vec3 reflectView = flipNormal * ( transformDirection( reflectVec, viewMatrix ) + vec3(0.0,0.0,1.0) );
 		vec4 envColor = texture2D( envMap, reflectView.xy * 0.5 + 0.5 );
 	#endif
 

+ 1 - 1
src/renderers/shaders/ShaderChunk/envmap_vertex.glsl

@@ -1,6 +1,6 @@
 #if defined( USE_ENVMAP ) && ! defined( USE_BUMPMAP ) && ! defined( USE_NORMALMAP ) && ! defined( PHONG )
 
-	vec3 worldNormal = transformNormal( objectNormal, modelMatrix );
+	vec3 worldNormal = transformDirection( objectNormal, modelMatrix );
 
 	vec3 cameraToVertex = normalize( worldPosition.xyz - cameraPosition );
 

+ 2 - 2
src/renderers/shaders/ShaderChunk/lights_lambert_vertex.glsl

@@ -12,7 +12,7 @@ transformedNormal = normalize( transformedNormal );
 
 for( int i = 0; i < MAX_DIR_LIGHTS; i ++ ) {
 
-	vec3 dirVector = transformNormal( directionalLightDirection[ i ], viewMatrix );
+	vec3 dirVector = transformDirection( directionalLightDirection[ i ], viewMatrix );
 
 	float dotProduct = dot( transformedNormal, dirVector );
 	vec3 directionalLightWeighting = vec3( max( dotProduct, 0.0 ) );
@@ -172,7 +172,7 @@ for( int i = 0; i < MAX_DIR_LIGHTS; i ++ ) {
 
 	for( int i = 0; i < MAX_HEMI_LIGHTS; i ++ ) {
 
-		vec3 lVector = transformNormal( hemisphereLightDirection[ i ], viewMatrix );
+		vec3 lVector = transformDirection( hemisphereLightDirection[ i ], viewMatrix );
 
 		float dotProduct = dot( transformedNormal, lVector );
 

+ 2 - 2
src/renderers/shaders/ShaderChunk/lights_phong_fragment.glsl

@@ -132,7 +132,7 @@ vec3 viewPosition = normalize( vViewPosition );
 
 	for( int i = 0; i < MAX_DIR_LIGHTS; i ++ ) {
 
-		vec3 dirVector = transformNormal( directionalLightDirection[ i ], viewMatrix );
+		vec3 dirVector = transformDirection( directionalLightDirection[ i ], viewMatrix );
 
 				// diffuse
 
@@ -197,7 +197,7 @@ vec3 viewPosition = normalize( vViewPosition );
 
 	for( int i = 0; i < MAX_HEMI_LIGHTS; i ++ ) {
 
-		vec3 lVector = transformNormal( hemisphereLightDirection[ i ], viewMatrix );
+		vec3 lVector = transformDirection( hemisphereLightDirection[ i ], viewMatrix );
 
 		// diffuse
 

+ 4 - 4
src/renderers/shaders/ShaderLib.js

@@ -915,7 +915,7 @@ THREE.ShaderLib = {
 
 			"		for( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {",
 
-			"			vec3 dirVector = transformNormal( directionalLightDirection[ i ], viewMatrix );",
+			"			vec3 dirVector = transformDirection( directionalLightDirection[ i ], viewMatrix );",
 
 						// diffuse
 
@@ -958,7 +958,7 @@ THREE.ShaderLib = {
 
 			"		for( int i = 0; i < MAX_HEMI_LIGHTS; i ++ ) {",
 
-			"			vec3 lVector = transformNormal( hemisphereLightDirection[ i ], viewMatrix );",
+			"			vec3 lVector = transformDirection( hemisphereLightDirection[ i ], viewMatrix );",
 
 						// diffuse
 
@@ -1236,7 +1236,7 @@ THREE.ShaderLib = {
 
 			"void main() {",
 
-			"	vWorldPosition = transformNormal( position, modelMatrix );",
+			"	vWorldPosition = transformDirection( position, modelMatrix );",
 
 			"	gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
 
@@ -1286,7 +1286,7 @@ THREE.ShaderLib = {
 
 			"void main() {",
 
-			"	vWorldPosition = transformNormal( position, modelMatrix );",
+			"	vWorldPosition = transformDirection( position, modelMatrix );",
 
 			"	gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",