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

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 _blurBoxOffset = 0;
         private _bias = 0.00005;
         private _bias = 0.00005;
         private _lightDirection = Vector3.Zero();
         private _lightDirection = Vector3.Zero();
-        private _depthScale = 1;
+        private _depthScale = 30.0;
 
 
         public forceBackFacesOnly = false;
         public forceBackFacesOnly = false;
 
 

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

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

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

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

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

@@ -5,6 +5,11 @@
 
 
         @serializeAsVector3()
         @serializeAsVector3()
         public position: Vector3;
         public position: Vector3;
+
+        @serialize()
+        public shadowMinZ: number;
+        @serialize()
+        public shadowMaxZ: number;
         
         
         public customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
         public customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
 
 
@@ -117,7 +122,8 @@
                 this.customProjectionMatrixBuilder(viewMatrix, renderList, matrix);
                 this.customProjectionMatrixBuilder(viewMatrix, renderList, matrix);
             } else {
             } else {
                 var activeCamera = this.getScene().activeCamera;
                 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;
             return this;
         }
         }

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

@@ -10,7 +10,12 @@
         public angle: number;
         public angle: number;
 
 
         @serialize()
         @serialize()
-        public exponent: number
+        public exponent: number;
+        
+        @serialize()
+        public shadowMinZ: number;
+        @serialize()
+        public shadowMaxZ: number;
 
 
         public transformedPosition: Vector3;
         public transformedPosition: Vector3;
 
 
@@ -49,6 +54,7 @@
         public getAbsolutePosition(): Vector3 {
         public getAbsolutePosition(): Vector3 {
             return this.transformedPosition ? this.transformedPosition : this.position;
             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.  
          * 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.  
          * Returns the SpotLight.  
@@ -58,7 +64,8 @@
                 this.customProjectionMatrixBuilder(viewMatrix, renderList, matrix);
                 this.customProjectionMatrixBuilder(viewMatrix, renderList, matrix);
             } else {
             } else {
                 var activeCamera = this.getScene().activeCamera;
                 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;
             return this;
         }
         }

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

@@ -181,14 +181,13 @@
 			return 1.0;
 			return 1.0;
 		}
 		}
 	
 	
-		float shadowStrength = 30. * depthScale;
 		#ifndef SHADOWFULLFLOAT
 		#ifndef SHADOWFULLFLOAT
 			float shadowMapSample = unpack(texture2D(shadowSampler, uv));
 			float shadowMapSample = unpack(texture2D(shadowSampler, uv));
 		#else
 		#else
 			float shadowMapSample = texture2D(shadowSampler, uv).x;
 			float shadowMapSample = texture2D(shadowSampler, uv).x;
 		#endif
 		#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
 		// Apply fade out at frustum edge
 		// const float fadeDistance = 0.07;
 		// const float fadeDistance = 0.07;

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

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