rain blocker fix

This commit is contained in:
Turánszki János
2025-05-22 09:25:45 +02:00
parent 843a6ec1af
commit f3c1a7ba0b
6 changed files with 25 additions and 21 deletions
+10 -10
View File
@@ -1175,24 +1175,21 @@ struct alignas(16) FrameCB
uint frame_count;
uint temporalaa_samplerotation;
int texture_shadowatlas_index;
int texture_shadowatlas_transparent_index;
uint entity_culling_count;
uint capsuleshadow_fade_angle;
uint2 shadow_atlas_resolution;
float2 shadow_atlas_resolution_rcp;
float4x4 cloudShadowLightSpaceMatrix;
float4x4 cloudShadowLightSpaceMatrixInverse;
int texture_shadowatlas_index;
int texture_shadowatlas_filtered_index;
int texture_shadowatlas_transparent_index;
float cloudShadowFarPlaneKm;
int texture_volumetricclouds_shadow_index;
uint giboost_packed; // force fp16 load
uint entity_culling_count;
uint capsuleshadow_fade_angle;
uint giboost_packed; // force fp16 load
int texture_volumetricclouds_shadow_index;
int indirect_debugbufferindex;
int padding0;
int padding1;
float blue_noise_phase;
int texture_random64x64_index;
@@ -1217,6 +1214,9 @@ struct alignas(16) FrameCB
float4x4 rain_blocker_matrix_prev;
float4x4 rain_blocker_matrix_inverse_prev;
float4x4 cloudShadowLightSpaceMatrix;
float4x4 cloudShadowLightSpaceMatrixInverse;
ShaderScene scene;
VXGI vxgi;
+4 -4
View File
@@ -98,7 +98,7 @@ inline void light_directional(in ShaderEntity light, in Surface surface, inout L
if (cascade_fade > 0 && dither(surface.pixel + GetTemporalAASampleRotation()) < cascade_fade)
continue;
light_color *= shadow_2D(light, 1 - shadow_pos.z, shadow_uv.xy, cascade, 16);
light_color *= shadow_2D(light, 1 - shadow_pos.z, shadow_uv.xy, cascade);
break;
}
}
@@ -205,7 +205,7 @@ inline void light_point(in ShaderEntity light, in Surface surface, inout Lightin
if ((GetFrame().options & OPTION_BIT_RAYTRACED_SHADOWS) == 0 || GetCamera().texture_rtshadow_index < 0 || (GetCamera().options & SHADERCAMERA_OPTION_USE_SHADOW_MASK) == 0)
#endif // SHADOW_MASK_ENABLED
{
light_color *= shadow_cube(light, LunnormalizedShadow, 1);
light_color *= shadow_cube(light, LunnormalizedShadow);
}
if (!any(light_color))
@@ -319,7 +319,7 @@ inline void light_spot(in ShaderEntity light, in Surface surface, inout Lighting
[branch]
if (is_saturated(shadow_uv))
{
light_color *= shadow_2D(light, rcp(dist_rcp) / range, shadow_uv.xy, 0, 1);
light_color *= shadow_2D(light, rcp(dist_rcp) / range, shadow_uv.xy, 0);
}
}
@@ -452,7 +452,7 @@ inline void light_rect(in ShaderEntity light, in Surface surface, inout Lighting
[branch]
if (is_saturated(shadow_uv))
{
light_color *= shadow_2D(light, rcp(dist_rcp) / range, shadow_uv.xy, 0, 1);
light_color *= shadow_2D(light, rcp(dist_rcp) / range, shadow_uv.xy, 0);
}
}
+4 -4
View File
@@ -6,9 +6,9 @@ static const float exponential_shadow_bias = 80;
inline half3 sample_shadow(float2 uv, float cmp)
{
Texture2D<float> texture_shadowatlas = bindless_textures_float[descriptor_index(GetFrame().texture_shadowatlas_index)];
Texture2D<float> texture_shadowatlas = bindless_textures_float[descriptor_index(GetFrame().texture_shadowatlas_filtered_index)];
float shadowMapValue = texture_shadowatlas.SampleLevel(sampler_linear_clamp, uv, 0);
half3 shadow = saturate(shadowMapValue * exp(-exponential_shadow_bias * cmp));
half3 shadow = sqr(saturate(shadowMapValue * exp(-exponential_shadow_bias * cmp)));
#ifndef DISABLE_TRANSPARENT_SHADOWMAP
Texture2D<half4> texture_shadowatlas_transparent = bindless_textures_half4[descriptor_index(GetFrame().texture_shadowatlas_transparent_index)];
@@ -33,7 +33,7 @@ inline void shadow_border_clamp(in ShaderEntity light, in float slice, inout flo
uv = clamp(uv, topleft, bottomright);
}
inline half3 shadow_2D(in ShaderEntity light, in float z, in float2 shadow_uv, in uint cascade, in float shadow_power = 1)
inline half3 shadow_2D(in ShaderEntity light, in float z, in float2 shadow_uv, in uint cascade)
{
shadow_uv.x += cascade;
shadow_uv = mad(shadow_uv, light.shadowAtlasMulAdd.xy, light.shadowAtlasMulAdd.zw);
@@ -41,7 +41,7 @@ inline half3 shadow_2D(in ShaderEntity light, in float z, in float2 shadow_uv, i
return sample_shadow(shadow_uv, z);
}
inline half3 shadow_cube(in ShaderEntity light, in float3 Lunnormalized, in float shadow_power = 1)
inline half3 shadow_cube(in ShaderEntity light, in float3 Lunnormalized)
{
const float3 uv_slice = cubemap_to_uv(-Lunnormalized);
float2 shadow_uv = uv_slice.xy;
+1 -1
View File
@@ -27,7 +27,7 @@ void main(uint3 DTid : SV_DispatchThreadID)
float4 transparent_filtered = 0;
const float2 spread_offset = filter.atlas_resolution_rcp * (2 + filter.spread * 8);
const uint soft_shadow_sample_count = (uint)lerp(8.0, 128.0, saturate(length(filter.spread)));
const uint soft_shadow_sample_count = (uint)lerp(8.0, 12.0, saturate(length(filter.spread)));
const float soft_shadow_sample_count_rcp = 1.0 / (float)soft_shadow_sample_count;
const float soft_shadow_sample_count_sqrt_rcp = rsqrt((float)soft_shadow_sample_count);
@@ -66,7 +66,7 @@ float4 main(VertexToPixel input) : SV_TARGET
[branch]
if (light.IsCastingShadow())
{
attenuation *= shadow_cube(light, Lunnormalized, input.pos.xy);
attenuation *= shadow_cube(light, Lunnormalized);
}
[branch]
+5 -1
View File
@@ -4245,9 +4245,11 @@ void UpdatePerFrameData(
frameCB.indirect_debugbufferindex = device->GetDescriptorIndex(&buffers[BUFFERTYPE_INDIRECT_DEBUG_0], SubresourceType::UAV);
// Note: shadow maps always assumed to be valid to avoid shader branching logic
const Texture& shadowMap = shadowMapAtlas_Filtered.IsValid() ? shadowMapAtlas_Filtered : *wi::texturehelper::getBlack();
const Texture& shadowMap = shadowMapAtlas.IsValid() ? shadowMapAtlas : *wi::texturehelper::getBlack();
const Texture& shadowMapFiltered = shadowMapAtlas_Filtered.IsValid() ? shadowMapAtlas_Filtered : *wi::texturehelper::getBlack();
const Texture& shadowMapTransparent = shadowMapAtlas_Transparent_Filtered.IsValid() ? shadowMapAtlas_Transparent_Filtered : *wi::texturehelper::getWhite();
frameCB.texture_shadowatlas_index = device->GetDescriptorIndex(&shadowMap, SubresourceType::SRV);
frameCB.texture_shadowatlas_filtered_index = device->GetDescriptorIndex(&shadowMapFiltered, SubresourceType::SRV);
frameCB.texture_shadowatlas_transparent_index = device->GetDescriptorIndex(&shadowMapTransparent, SubresourceType::SRV);
frameCB.shadow_atlas_resolution.x = shadowMap.desc.width;
frameCB.shadow_atlas_resolution.y = shadowMap.desc.height;
@@ -7157,6 +7159,7 @@ void DrawShadowmaps(
break;
} // terminate switch
}
#if 0 // note: rain blocker doesn't use filtering for now, it uses pcf
// Rain blocker filtering:
if (vis.scene->weather.rain_amount > 0)
{
@@ -7173,6 +7176,7 @@ void DrawShadowmaps(
device->BindDynamicConstantBuffer(filter, 2, cmd);
device->Dispatch((filter.rect.z + 7u) / 8u, (filter.rect.w + 7u) / 8u, 1, cmd);
}
#endif
device->Barrier(GPUBarrier::Image(&shadowMapAtlas_Filtered, ResourceState::UNORDERED_ACCESS, ResourceState::SHADER_RESOURCE), cmd);
device->Barrier(GPUBarrier::Image(&shadowMapAtlas_Transparent_Filtered, ResourceState::UNORDERED_ACCESS, ResourceState::SHADER_RESOURCE), cmd);
device->EventEnd(cmd);