diff --git a/Source/Shaders/GlobalSignDistanceField.hlsl b/Source/Shaders/GlobalSignDistanceField.hlsl index 4ecc7b81c..cafb02869 100644 --- a/Source/Shaders/GlobalSignDistanceField.hlsl +++ b/Source/Shaders/GlobalSignDistanceField.hlsl @@ -250,6 +250,7 @@ GlobalSDFHit RayTraceGlobalSDF(const GlobalSDFData data, Texture3D tex, T for (; step < 250 && stepTime < intersections.y && hit.HitTime < 0.0f; step++) { float3 stepPosition = worldPosition + trace.WorldDirection * stepTime; + float stepScale = trace.StepScale; // Sample SDF float cascadeMaxDistance; @@ -260,7 +261,10 @@ GlobalSDFHit RayTraceGlobalSDF(const GlobalSDFData data, Texture3D tex, T { float stepDistanceTex = tex.SampleLevel(SamplerLinearClamp, textureUV, 0); if (stepDistanceTex < chunkMarginDistance) + { stepDistance = stepDistanceTex; + stepScale *= 0.63f; // Perform smaller steps nearby geometry + } } else { @@ -292,7 +296,7 @@ GlobalSDFHit RayTraceGlobalSDF(const GlobalSDFData data, Texture3D tex, T } // Move forward - stepTime += max(stepDistance * trace.StepScale, voxelSize); + stepTime += max(stepDistance * stepScale, voxelSize); } hit.StepsCount += step; }