fixed crp_volLight 0 effectively disabling r_dynamicLight

This commit is contained in:
myT 2024-12-05 22:59:02 +01:00
parent c85ad330b3
commit b076ff8e8a
2 changed files with 12 additions and 5 deletions

View file

@ -41,6 +41,7 @@ struct DenoiseRC
{
vec3_t lightPosition;
uint32_t textureIndex;
uint32_t vshadowValid;
uint32_t vshadowTextureIndex;
uint32_t vshadowSamplerIndex;
float vshadowWorldScale;
@ -129,6 +130,7 @@ void DynamicLights::DrawPointLight(const dlight_t& light)
DenoiseRC rc = {};
VectorCopy(light.origin, rc.lightPosition);
rc.textureIndex = GetTextureIndexSRV(crp.sunlightTexture);
rc.vshadowValid = crp_volLight->integer != 0 ? 1 : 0;
rc.vshadowTextureIndex = GetTextureIndexSRV(crp.volumetricLight.pointShadowTexture);
rc.vshadowSamplerIndex = GetSamplerIndex(TW_CLAMP_TO_EDGE, TextureFilter::Linear);
rc.vshadowWorldScale = crp.volumetricLight.pointShadowVolumeScale;

View file

@ -30,6 +30,7 @@ cbuffer RootConstants
{
float3 lightPosition;
uint textureIndex;
uint vshadowValid;
uint vshadowTextureIndex;
uint vshadowSamplerIndex;
float vshadowWorldScale;
@ -40,8 +41,6 @@ float4 ps(VOut input) : SV_Target
SceneView scene = GetSceneView();
Texture2D shadingPositionTexture = ResourceDescriptorHeap[scene.shadingPositionTextureIndex];
Texture2D texture0 = ResourceDescriptorHeap[textureIndex];
Texture3D<float> vshadowTexture = ResourceDescriptorHeap[vshadowTextureIndex];
SamplerState vshadowSampler = SamplerDescriptorHeap[vshadowSamplerIndex];
int2 textureMax = GetTextureSize(texture0) - int2(1, 1);
int2 tcFrag = int2(input.position.xy);
@ -94,9 +93,15 @@ float4 ps(VOut input) : SV_Target
accum /= weightSum;
}
// only apply the volumetric shadow map when volumetric lighting is enabled
if(vshadowValid != 0u)
{
Texture3D<float> vshadowTexture = ResourceDescriptorHeap[vshadowTextureIndex];
SamplerState vshadowSampler = SamplerDescriptorHeap[vshadowSamplerIndex];
float3 vshadowTC = AABoxWorldSpaceToTC(positionFrag, lightPosition, GetTextureSize(vshadowTexture), vshadowWorldScale);
float transmittance = vshadowTexture.SampleLevel(vshadowSampler, vshadowTC, 0);
accum *= transmittance;
}
float4 result = float4(accum, 0);