浏览代码

Finalizing ESM for documentation

David Catuhe 8 年之前
父节点
当前提交
ba191ba2ab

文件差异内容过多而无法显示
+ 24 - 24
dist/preview release/babylon.core.js


文件差异内容过多而无法显示
+ 5081 - 5073
dist/preview release/babylon.d.ts


文件差异内容过多而无法显示
+ 32 - 32
dist/preview release/babylon.js


文件差异内容过多而无法显示
+ 44 - 29
dist/preview release/babylon.max.js


文件差异内容过多而无法显示
+ 5081 - 5073
dist/preview release/babylon.module.d.ts


文件差异内容过多而无法显示
+ 32 - 32
dist/preview release/babylon.noworker.js


+ 1 - 1
src/Lights/Shadows/babylon.shadowGenerator.ts

@@ -34,7 +34,7 @@
         private _blurBoxOffset = 0;
         private _bias = 0.00005;
         private _lightDirection = Vector3.Zero();
-        private _depthScale = 1;
+        private _depthScale = 30.0;
 
         public forceBackFacesOnly = false;
 

+ 7 - 1
src/Lights/babylon.directionalLight.ts

@@ -17,6 +17,11 @@ module BABYLON {
 
         @serialize()
         public autoUpdateExtends = true;
+
+        @serialize()
+        public shadowMinZ: number;
+        @serialize()
+        public shadowMaxZ: number;
         
         public customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
 
@@ -57,6 +62,7 @@ module BABYLON {
             this.direction = Vector3.Normalize(target.subtract(this.position));
             return this.direction;
         }
+
         /**
          * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.  
          * Returns the DirectionalLight.  
@@ -112,7 +118,7 @@ module BABYLON {
 
                 Matrix.OrthoOffCenterLHToRef(this._orthoLeft - xOffset * this.shadowOrthoScale, this._orthoRight + xOffset * this.shadowOrthoScale,
                     this._orthoBottom - yOffset * this.shadowOrthoScale, this._orthoTop + yOffset * this.shadowOrthoScale,
-                    activeCamera.minZ, activeCamera.maxZ, matrix);
+                    this.shadowMinZ !== undefined ? this.shadowMinZ : activeCamera.minZ, this.shadowMaxZ !== undefined ? this.shadowMaxZ : activeCamera.maxZ, matrix);
             }
             return this;
         }

+ 3 - 1
src/Lights/babylon.light.ts

@@ -5,13 +5,15 @@
         position: Vector3;
         transformedPosition: Vector3;
         name: string;
+        shadowMinZ: number;
+        shadowMaxZ: number;
 
         computeTransformedPosition(): boolean;
         getScene(): Scene;
 
-
         customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
         setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
+        
 
         needRefreshPerFrame(): boolean;
         needCube(): boolean;

+ 7 - 1
src/Lights/babylon.pointLight.ts

@@ -5,6 +5,11 @@
 
         @serializeAsVector3()
         public position: Vector3;
+
+        @serialize()
+        public shadowMinZ: number;
+        @serialize()
+        public shadowMaxZ: number;
         
         public customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
 
@@ -117,7 +122,8 @@
                 this.customProjectionMatrixBuilder(viewMatrix, renderList, matrix);
             } else {
                 var activeCamera = this.getScene().activeCamera;
-                Matrix.PerspectiveFovLHToRef(Math.PI / 2, 1.0, activeCamera.minZ, activeCamera.maxZ, matrix);
+                Matrix.PerspectiveFovLHToRef(Math.PI / 2, 1.0, 
+                this.shadowMinZ !== undefined ? this.shadowMinZ : activeCamera.minZ, this.shadowMaxZ !== undefined ? this.shadowMaxZ : activeCamera.maxZ, matrix);
             }
             return this;
         }

+ 9 - 2
src/Lights/babylon.spotLight.ts

@@ -10,7 +10,12 @@
         public angle: number;
 
         @serialize()
-        public exponent: number
+        public exponent: number;
+        
+        @serialize()
+        public shadowMinZ: number;
+        @serialize()
+        public shadowMaxZ: number;
 
         public transformedPosition: Vector3;
 
@@ -49,6 +54,7 @@
         public getAbsolutePosition(): Vector3 {
             return this.transformedPosition ? this.transformedPosition : this.position;
         }
+
         /**
          * Sets the passed matrix "matrix" as perspective projection matrix for the shadows and the passed view matrix with the fov equal to the SpotLight angle and and aspect ratio of 1.0.  
          * Returns the SpotLight.  
@@ -58,7 +64,8 @@
                 this.customProjectionMatrixBuilder(viewMatrix, renderList, matrix);
             } else {
                 var activeCamera = this.getScene().activeCamera;
-                Matrix.PerspectiveFovLHToRef(this.angle, 1.0, activeCamera.minZ, activeCamera.maxZ, matrix);
+                Matrix.PerspectiveFovLHToRef(this.angle, 1.0, 
+                this.shadowMinZ !== undefined ? this.shadowMinZ : activeCamera.minZ, this.shadowMaxZ !== undefined ? this.shadowMaxZ : activeCamera.maxZ, matrix);
             }
             return this;
         }

+ 1 - 2
src/Shaders/ShadersInclude/shadowsFragmentFunctions.fx

@@ -181,14 +181,13 @@
 			return 1.0;
 		}
 	
-		float shadowStrength = 30. * depthScale;
 		#ifndef SHADOWFULLFLOAT
 			float shadowMapSample = unpack(texture2D(shadowSampler, uv));
 		#else
 			float shadowMapSample = texture2D(shadowSampler, uv).x;
 		#endif
 		
-		float esm = 1.0 - clamp(exp(shadowStrength * shadowPixelDepth) * shadowMapSample - darkness, 0., 1.);		
+		float esm = 1.0 - clamp(exp(min(87., depthScale * shadowPixelDepth)) * shadowMapSample - darkness, 0., 1.);		
 
 		// Apply fade out at frustum edge
 		// const float fadeDistance = 0.07;

+ 1 - 2
src/Shaders/shadowMap.fragment.fx

@@ -46,8 +46,7 @@ void main(void)
 	depth += biasAndScale.x;
 
 #ifdef ESM
-	float shadowStrength = 30.0 * biasAndScale.y;
-	depth = exp(-shadowStrength * depth);
+	depth = exp(-min(87., biasAndScale.y * depth));
 #endif
 
 #ifndef FULLFLOAT