2
0
Эх сурвалжийг харах

Edited comments and whitespace, amending #7153.

tschw 10 жил өмнө
parent
commit
1b0d49df6a

+ 24 - 26
src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl

@@ -1,5 +1,5 @@
 #ifdef USE_SHADOWMAP
-	
+
 	uniform sampler2D shadowMap[ MAX_SHADOWS ];
 	uniform vec2 shadowMapSize[ MAX_SHADOWS ];
 
@@ -19,30 +19,28 @@
 	#if defined(POINT_LIGHT_SHADOWS)
 
 		float unpack1K ( vec4 color ) {
-		
+
 			const vec4 bitSh = vec4( 1.0 / (256.0 * 256.0 * 256.0), 1.0 / (256.0 * 256.0), 1.0 / 256.0, 1.0 );
 			return dot( color, bitSh ) * 1000.0;
-			
+
 		}
 
-		/**
-		*  cubeToUV() maps a 3D direction vector suitable for cube texture mapping to a 2D
-		*  vector suitable for 2D texture mapping. This code uses the following layout for the
-		*  2D texture:		
-		*  
-		*  xzXZ
-		*   y Y
-		*
-		*  Y - Positive y direction
-		*  y - Negative y direction
-		*  X - Positive x direction
-		*  x - Negative x direction
-		*  Z - Positive z direction
-		*  z - Negative z direction
-		*
-		*  Alternate code for a horizontal cross layout can be found here:
-		*  https://gist.github.com/tschw/da10c43c467ce8afd0c4
-		*/
+		// cubeToUV() maps a 3D direction vector suitable for cube texture mapping to a 2D
+		// vector suitable for 2D texture mapping. This code uses the following layout for the
+		// 2D texture:
+		//
+		// xzXZ
+		//  y Y
+		//
+		// Y - Positive y direction
+		// y - Negative y direction
+		// X - Positive x direction
+		// x - Negative x direction
+		// Z - Positive z direction
+		// z - Negative z direction
+		//
+		// Source and test bed:
+		// https://gist.github.com/tschw/da10c43c467ce8afd0c4
 
 		vec2 cubeToUV( vec3 v, float texelSizeX, float texelSizeY ) {
 
@@ -95,15 +93,15 @@
 			// scale := 0.5 / dim
 			// translate := ( center + 0.5 ) / dim
 			return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );
-			
+
 		}
 
 		vec3 gridSamplingDisk[ 20 ];
 		bool gridSamplingInitialized = false;
 
-		void initGridSamplingDisk(){
+		void initGridSamplingDisk() {
 
-			if( gridSamplingInitialized ){
+			if( gridSamplingInitialized ) {
 
 				return;
 
@@ -131,9 +129,9 @@
 			gridSamplingDisk[19] = vec3(0, 1, -1);
 
 			gridSamplingInitialized = true;
-			
+
 		}
 
 	#endif
 
-#endif
+#endif

+ 16 - 20
src/renderers/webgl/WebGLShadowMap.js

@@ -21,10 +21,10 @@ THREE.WebGLShadowMap = function ( _renderer, _lights, _objects ) {
 	var _depthMaterial, _depthMaterialMorph, _depthMaterialSkin, _depthMaterialMorphSkin,
 	_distanceMaterial, _distanceMaterialMorph, _distanceMaterialSkin, _distanceMaterialMorphSkin;
 
-	var cubeDirections = [ new THREE.Vector3( 1, 0, 0 ), new THREE.Vector3( - 1, 0, 0 ), new THREE.Vector3( 0, 0, 1 ), 
+	var cubeDirections = [ new THREE.Vector3( 1, 0, 0 ), new THREE.Vector3( - 1, 0, 0 ), new THREE.Vector3( 0, 0, 1 ),
 						   new THREE.Vector3( 0, 0, - 1 ), new THREE.Vector3( 0, 1, 0 ), new THREE.Vector3( 0, - 1, 0 ) ];
 
-	var cubeUps = [ new THREE.Vector3( 0, 1, 0 ), new THREE.Vector3( 0, 1, 0 ), new THREE.Vector3( 0, 1, 0 ), 
+	var cubeUps = [ new THREE.Vector3( 0, 1, 0 ), new THREE.Vector3( 0, 1, 0 ), new THREE.Vector3( 0, 1, 0 ),
 					new THREE.Vector3( 0, 1, 0 ), new THREE.Vector3( 0, 0, 1 ),	new THREE.Vector3( 0, 0, - 1 ) ];
 
 	var cube2DViewPorts = [ new THREE.Vector4(), new THREE.Vector4(), new THREE.Vector4(),
@@ -160,22 +160,18 @@ THREE.WebGLShadowMap = function ( _renderer, _lights, _objects ) {
 				var vpWidth = light.shadowMapWidth / 4.0;
 				var vpHeight = light.shadowMapHeight / 2.0;
 
-				/*
-				*
-				* These viewports map a cube-map onto a 2D texture with the
-				* following orientation:
-				*
-				*  xzXZ
-				*   y Y
-				*
-				*  Y - Positive y direction
-				*  y - Negative y direction
-				*  X - Positive x direction
-				*  x - Negative x direction
-				*  Z - Positive z direction
-				*  z - Negative z direction
-				*
-				*/
+				// These viewports map a cube-map onto a 2D texture with the
+				// following orientation:
+				//
+				//  xzXZ
+				//   y Y
+				//
+				// X - Positive x direction
+				// x - Negative x direction
+				// Y - Positive y direction
+				// y - Negative y direction
+				// Z - Positive z direction
+				// z - Negative z direction
 
 				// positive X
 				cube2DViewPorts[ 0 ].set( vpWidth * 2, vpHeight, vpWidth, vpHeight );
@@ -203,7 +199,7 @@ THREE.WebGLShadowMap = function ( _renderer, _lights, _objects ) {
 
 				var shadowFilter = THREE.LinearFilter;
 
-				if ( scope.type === THREE.PCFSoftShadowMap) {
+				if ( scope.type === THREE.PCFSoftShadowMap ) {
 
 					shadowFilter = THREE.NearestFilter;
 
@@ -258,7 +254,7 @@ THREE.WebGLShadowMap = function ( _renderer, _lights, _objects ) {
 			_renderer.getViewport( _vector4 );
 
 			_renderer.setRenderTarget( shadowMap );
-			_renderer.clear();		
+			_renderer.clear();
 
 			// render shadow map for each cube face (if omni-directional) or
 			// run a single pass if not