|
@@ -312,11 +312,12 @@ float computeShadowWithPCFCube(vec3 lightPosition, samplerCube shadowSampler, fl
|
|
|
{
|
|
|
vec3 directionToLight = vPositionW - lightPosition;
|
|
|
float depth = length(directionToLight);
|
|
|
- float diskScale = (1.0 - (1.0 + depth * 3.0)) / mapSize;
|
|
|
|
|
|
- depth = clamp(depth, 0., 1.);
|
|
|
+ depth = (depth - depthValues.x) / (depthValues.y - depthValues.x);
|
|
|
+ depth = clamp(depth, 0., 1.0);
|
|
|
|
|
|
- directionToLight.y = 1.0 - directionToLight.y;
|
|
|
+ directionToLight = normalize(directionToLight);
|
|
|
+ directionToLight.y = -directionToLight.y;
|
|
|
|
|
|
float visibility = 1.;
|
|
|
|
|
@@ -329,10 +330,10 @@ float computeShadowWithPCFCube(vec3 lightPosition, samplerCube shadowSampler, fl
|
|
|
// Poisson Sampling
|
|
|
float biasedDepth = depth - bias;
|
|
|
|
|
|
- if (unpack(textureCube(shadowSampler, directionToLight + poissonDisk[0] * diskScale)) < biasedDepth) visibility -= 0.25;
|
|
|
- if (unpack(textureCube(shadowSampler, directionToLight + poissonDisk[1] * diskScale)) < biasedDepth) visibility -= 0.25;
|
|
|
- if (unpack(textureCube(shadowSampler, directionToLight + poissonDisk[2] * diskScale)) < biasedDepth) visibility -= 0.25;
|
|
|
- if (unpack(textureCube(shadowSampler, directionToLight + poissonDisk[3] * diskScale)) < biasedDepth) visibility -= 0.25;
|
|
|
+ if (unpack(textureCube(shadowSampler, directionToLight + poissonDisk[0] * mapSize)) < biasedDepth) visibility -= 0.25;
|
|
|
+ if (unpack(textureCube(shadowSampler, directionToLight + poissonDisk[1] * mapSize)) < biasedDepth) visibility -= 0.25;
|
|
|
+ if (unpack(textureCube(shadowSampler, directionToLight + poissonDisk[2] * mapSize)) < biasedDepth) visibility -= 0.25;
|
|
|
+ if (unpack(textureCube(shadowSampler, directionToLight + poissonDisk[3] * mapSize)) < biasedDepth) visibility -= 0.25;
|
|
|
|
|
|
return min(1.0, visibility + darkness);
|
|
|
}
|
|
@@ -381,10 +382,10 @@ float computeShadowWithPCF(vec4 vPositionFromLight, sampler2D shadowSampler, flo
|
|
|
// Poisson Sampling
|
|
|
float biasedDepth = depth.z - bias;
|
|
|
|
|
|
- if (unpack(texture2D(shadowSampler, uv + poissonDisk[0] / mapSize)) < biasedDepth) visibility -= 0.25;
|
|
|
- if (unpack(texture2D(shadowSampler, uv + poissonDisk[1] / mapSize)) < biasedDepth) visibility -= 0.25;
|
|
|
- if (unpack(texture2D(shadowSampler, uv + poissonDisk[2] / mapSize)) < biasedDepth) visibility -= 0.25;
|
|
|
- if (unpack(texture2D(shadowSampler, uv + poissonDisk[3] / mapSize)) < biasedDepth) visibility -= 0.25;
|
|
|
+ if (unpack(texture2D(shadowSampler, uv + poissonDisk[0] * mapSize)) < biasedDepth) visibility -= 0.25;
|
|
|
+ if (unpack(texture2D(shadowSampler, uv + poissonDisk[1] * mapSize)) < biasedDepth) visibility -= 0.25;
|
|
|
+ if (unpack(texture2D(shadowSampler, uv + poissonDisk[2] * mapSize)) < biasedDepth) visibility -= 0.25;
|
|
|
+ if (unpack(texture2D(shadowSampler, uv + poissonDisk[3] * mapSize)) < biasedDepth) visibility -= 0.25;
|
|
|
|
|
|
return min(1.0, visibility + darkness);
|
|
|
}
|