Add more precise Global SDF raycasting nearby geometry (at cost of performance)
This commit is contained in:
@@ -250,6 +250,7 @@ GlobalSDFHit RayTraceGlobalSDF(const GlobalSDFData data, Texture3D<float> tex, T
|
|||||||
for (; step < 250 && stepTime < intersections.y && hit.HitTime < 0.0f; step++)
|
for (; step < 250 && stepTime < intersections.y && hit.HitTime < 0.0f; step++)
|
||||||
{
|
{
|
||||||
float3 stepPosition = worldPosition + trace.WorldDirection * stepTime;
|
float3 stepPosition = worldPosition + trace.WorldDirection * stepTime;
|
||||||
|
float stepScale = trace.StepScale;
|
||||||
|
|
||||||
// Sample SDF
|
// Sample SDF
|
||||||
float cascadeMaxDistance;
|
float cascadeMaxDistance;
|
||||||
@@ -260,7 +261,10 @@ GlobalSDFHit RayTraceGlobalSDF(const GlobalSDFData data, Texture3D<float> tex, T
|
|||||||
{
|
{
|
||||||
float stepDistanceTex = tex.SampleLevel(SamplerLinearClamp, textureUV, 0);
|
float stepDistanceTex = tex.SampleLevel(SamplerLinearClamp, textureUV, 0);
|
||||||
if (stepDistanceTex < chunkMarginDistance)
|
if (stepDistanceTex < chunkMarginDistance)
|
||||||
|
{
|
||||||
stepDistance = stepDistanceTex;
|
stepDistance = stepDistanceTex;
|
||||||
|
stepScale *= 0.63f; // Perform smaller steps nearby geometry
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -292,7 +296,7 @@ GlobalSDFHit RayTraceGlobalSDF(const GlobalSDFData data, Texture3D<float> tex, T
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Move forward
|
// Move forward
|
||||||
stepTime += max(stepDistance * trace.StepScale, voxelSize);
|
stepTime += max(stepDistance * stepScale, voxelSize);
|
||||||
}
|
}
|
||||||
hit.StepsCount += step;
|
hit.StepsCount += step;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user