Cleanup in VSM code
This commit is contained in:
parent
a1f8df808b
commit
140d85470d
@ -53,7 +53,7 @@ vec2 get_parallax_offset_uv(vec2 uv, vec3 view_direction) {
|
||||
current_layer_depth += refinement_layer_depth;
|
||||
}
|
||||
|
||||
// Referse the UV operation again and return the result
|
||||
// Reverse the UV operation again and return the result
|
||||
current_uv += uv_refine_shift_per_layer;
|
||||
|
||||
return current_uv;
|
||||
@ -78,17 +78,19 @@ float get_shadow(vec4 fragPosLightSpace, vec3 normal) {
|
||||
|
||||
// get closest depth value from light's perspective (using [0,1] range fragPosLight as coords)
|
||||
mediump float closestDepth = moments.r;
|
||||
mediump float depth_squared = moments.g;
|
||||
// get depth of current fragment from light's perspective
|
||||
mediump float currentDepth = projCoords.z;
|
||||
// check whether current frag pos is in shadow
|
||||
float p = step(projCoords.z, moments.x);
|
||||
float p = step(currentDepth, closestDepth);
|
||||
|
||||
// We divide by this later, so make sure it's not exactly 0
|
||||
// It seems like it should always be 0.0, but due to interpolation it's not -- it increases with the deviation!
|
||||
// A larger second parameter to max() means more blur (but also more light bleeding)
|
||||
float variance = max(moments.y - moments.x * moments.x, (-0.01 + (currentDepth - closestDepth) * 0.7) * 0.1);
|
||||
float variance = max(depth_squared - closestDepth * closestDepth, (-0.01 + (currentDepth - closestDepth) * 0.7) * 0.1);
|
||||
|
||||
float d = currentDepth - closestDepth;
|
||||
|
||||
float d = projCoords.z - moments.x * 1.0;
|
||||
// Use linear_step to prevent light bleeding
|
||||
float p_max = linear_step(0.2, 1.0, variance / (variance + d * d));
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user