volumetric directional light: don't early exit when out of shadow cascade

This commit is contained in:
Turánszki János
2023-01-11 12:27:29 +01:00
parent e82ce3f97e
commit da87e2b5c8
2 changed files with 15 additions and 21 deletions
@@ -39,7 +39,8 @@ float4 main(VertexToPixel input) : SV_TARGET
for (uint i = 0; i < sampleCount; ++i)
{
bool valid = false;
float3 shadow = 1;
for (uint cascade = 0; cascade < GetFrame().shadow_cascade_count; ++cascade)
{
float3 shadow_pos = mul(load_entitymatrix(light.GetMatrixIndex() + cascade), float4(P, 1)).xyz; // ortho matrix, no divide by .w
@@ -48,31 +49,24 @@ float4 main(VertexToPixel input) : SV_TARGET
[branch]
if (is_saturated(shadow_uv))
{
float3 attenuation = shadow_2D(light, shadow_pos, shadow_uv.xy, cascade);
if (GetFrame().options & OPTION_BIT_VOLUMETRICCLOUDS_SHADOWS)
{
attenuation *= shadow_2D_volumetricclouds(P);
}
// Evaluate sample height for height fog calculation, given 0 for V:
attenuation *= GetFogAmount(cameraDistance - marchedDistance, P, float3(0.0, 0.0, 0.0));
attenuation *= scattering;
accumulation += attenuation;
marchedDistance += stepSize;
P = P + V * stepSize;
valid = true;
shadow *= shadow_2D(light, shadow_pos, shadow_uv.xy, cascade);
break;
}
}
if (!valid)
if (GetFrame().options & OPTION_BIT_VOLUMETRICCLOUDS_SHADOWS)
{
break;
shadow *= shadow_2D_volumetricclouds(P);
}
// Evaluate sample height for height fog calculation, given 0 for V:
shadow *= GetFogAmount(cameraDistance - marchedDistance, P, 0);
shadow *= scattering;
accumulation += shadow;
marchedDistance += stepSize;
P = P + V * stepSize;
}
accumulation /= sampleCount;
+1 -1
View File
@@ -9,7 +9,7 @@ namespace wi::version
// minor features, major updates, breaking compatibility changes
const int minor = 71;
// minor bug fixes, alterations, refactors, updates
const int revision = 133;
const int revision = 134;
const std::string version_string = std::to_string(major) + "." + std::to_string(minor) + "." + std::to_string(revision);