فهرست منبع

Review Comments

Sebastien Vandenberghe 8 سال پیش
والد
کامیت
8a9bad422d
2فایلهای تغییر یافته به همراه6 افزوده شده و 4 حذف شده
  1. 6 0
      src/Lights/babylon.directionalLight.ts
  2. 0 4
      src/Shaders/ShadersInclude/shadowsFragmentFunctions.fx

+ 6 - 0
src/Lights/babylon.directionalLight.ts

@@ -167,6 +167,9 @@ module BABYLON {
 
         /**
          * Gets the minZ used for shadow according to both the scene and the light.
+         * 
+         * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
+         * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 0.5) / (0.5 + 5) -> (depth + 0.5) * 0.5.
          * @param activeCamera 
          */
         public getDepthMinZ(activeCamera: Camera): number {
@@ -175,6 +178,9 @@ module BABYLON {
 
         /**
          * Gets the maxZ used for shadow according to both the scene and the light.
+         * 
+         * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
+         * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 0.5) / (0.5 + 5) -> (depth + 0.5) * 0.5.
          * @param activeCamera 
          */
         public getDepthMaxZ(activeCamera: Camera): number {

+ 0 - 4
src/Shaders/ShadersInclude/shadowsFragmentFunctions.fx

@@ -11,7 +11,6 @@
 	{
 		vec3 directionToLight = vPositionW - lightPosition;
 		float depth = length(directionToLight);
-		//depth = (depth - depthValues.x) / (depthValues.y - depthValues.x);
 		depth = (depth + depthValues.x) / (depthValues.y);
 		depth = clamp(depth, 0., 1.0);
 
@@ -35,7 +34,6 @@
 	{
 		vec3 directionToLight = vPositionW - lightPosition;
 		float depth = length(directionToLight);
-		//depth = (depth - depthValues.x) / (depthValues.y - depthValues.x);
 		depth = (depth + depthValues.x) / (depthValues.y);
 		depth = clamp(depth, 0., 1.0);
 
@@ -71,7 +69,6 @@
 	{
 		vec3 directionToLight = vPositionW - lightPosition;
 		float depth = length(directionToLight);
-		//depth = (depth - depthValues.x) / (depthValues.y - depthValues.x);
 		depth = (depth + depthValues.x) / (depthValues.y);
 		float shadowPixelDepth = clamp(depth, 0., 1.0);
 
@@ -92,7 +89,6 @@
 	{
 		vec3 directionToLight = vPositionW - lightPosition;
 		float depth = length(directionToLight);
-		//depth = (depth - depthValues.x) / (depthValues.y - depthValues.x);
 		depth = (depth + depthValues.x) / (depthValues.y);
 		float shadowPixelDepth = clamp(depth, 0., 1.0);