Code cleanup

#2717
This commit is contained in:
Wojtek Figat
2024-08-05 19:44:06 +02:00
parent a49fc1c5d1
commit 23fcfb4eb2
9 changed files with 33 additions and 43 deletions

View File

@@ -67,7 +67,6 @@ void PS_Forward(
gBuffer.Color = material.Color;
gBuffer.Specular = material.Specular;
gBuffer.AO = material.AO;
// gBuffer.ViewPos is the view space position of the pixel
gBuffer.ViewPos = mul(float4(materialInput.WorldPosition, 1), ViewMatrix).xyz;
#if MATERIAL_SHADING_MODEL == SHADING_MODEL_SUBSURFACE
gBuffer.CustomData = float4(material.SubsurfaceColor, material.Opacity);
@@ -126,23 +125,19 @@ void PS_Forward(
float3 screenColor = sceneColorTexture.SampleLevel(SamplerPointClamp, hit.xy, 0).rgb;
reflections = lerp(reflections, screenColor, hit.z);
}
// Fallback to software tracing if possible
#if USE_GLOBAL_SURFACE_ATLAS && CAN_USE_GLOBAL_SURFACE_ATLAS
// If hit.z >= 0.9f then skip sdf tracing
if (hit.z < 0.9f)
if (hit.z < REFLECTIONS_HIT_THRESHOLD)
{
// Don't use temporal effect in forward pass
float3 reflectWS = ScreenSpaceReflectionDirection(screenUV, gBuffer, ViewPos);
float4 surfaceAtlas;
if(TraceSDFSoftwareReflections(gBuffer, reflectWS, surfaceAtlas)){
if (TraceSDFSoftwareReflections(gBuffer, reflectWS, surfaceAtlas))
{
float3 screenColor = sceneColorTexture.SampleLevel(SamplerPointClamp, hit.xy, 0).rgb;
reflections = lerp(surfaceAtlas, float4(screenColor, 1), hit.z);
}
}
#endif
#endif

View File

@@ -29,10 +29,8 @@ bool TraceSDFSoftwareReflections(GBufferSample gBuffer, float3 reflectWS, out fl
float3 hitPosition = sdfHit.GetHitPosition(sdfTrace);
float surfaceThreshold = GetGlobalSurfaceAtlasThreshold(GlobalSDF, sdfHit);
surfaceAtlas = SampleGlobalSurfaceAtlas(GlobalSurfaceAtlas, GlobalSurfaceAtlasChunks, RWGlobalSurfaceAtlasCulledObjects, GlobalSurfaceAtlasObjects, GlobalSurfaceAtlasDepth, GlobalSurfaceAtlasTex, hitPosition, -reflectWS, surfaceThreshold);
return true;
}
return false;
}