ddgi backface pulling leak improvement

This commit is contained in:
Turánszki János
2025-03-10 08:08:58 +01:00
parent 808421dbba
commit 3dfd578778
5 changed files with 33 additions and 19 deletions
+8 -5
View File
@@ -173,9 +173,8 @@ void main(uint3 DTid : SV_DispatchThreadID, uint3 Gid : SV_GroupID, uint groupIn
wiRayQuery q;
q.TraceRayInline(
scene_acceleration_structure, // RaytracingAccelerationStructure AccelerationStructure
RAY_FLAG_CULL_FRONT_FACING_TRIANGLES |
//RAY_FLAG_CULL_FRONT_FACING_TRIANGLES |
RAY_FLAG_SKIP_PROCEDURAL_PRIMITIVES |
RAY_FLAG_CULL_FRONT_FACING_TRIANGLES |
RAY_FLAG_ACCEPT_FIRST_HIT_AND_END_SEARCH, // uint RayFlags
0xFF, // uint InstanceInclusionMask
newRay // RayDesc Ray
@@ -205,7 +204,7 @@ void main(uint3 DTid : SV_DispatchThreadID, uint3 Gid : SV_GroupID, uint groupIn
wiRayQuery q;
q.TraceRayInline(
scene_acceleration_structure, // RaytracingAccelerationStructure AccelerationStructure
RAY_FLAG_CULL_BACK_FACING_TRIANGLES |
//RAY_FLAG_CULL_BACK_FACING_TRIANGLES |
RAY_FLAG_SKIP_PROCEDURAL_PRIMITIVES |
RAY_FLAG_FORCE_OPAQUE, // uint RayFlags
push.instanceInclusionMask, // uint InstanceInclusionMask
@@ -278,6 +277,11 @@ void main(uint3 DTid : SV_DispatchThreadID, uint3 Gid : SV_GroupID, uint groupIn
#endif // RTAPI
if (surface.IsBackface())
{
hit_depth *= 0.9; // push inwards to help avoid shadow leaks from inwards to outside
}
surface.P = ray.Origin;
surface.V = -ray.Direction;
surface.update();
@@ -395,9 +399,8 @@ void main(uint3 DTid : SV_DispatchThreadID, uint3 Gid : SV_GroupID, uint groupIn
#ifdef RTAPI
q.TraceRayInline(
scene_acceleration_structure, // RaytracingAccelerationStructure AccelerationStructure
RAY_FLAG_CULL_FRONT_FACING_TRIANGLES |
//RAY_FLAG_CULL_FRONT_FACING_TRIANGLES |
RAY_FLAG_SKIP_PROCEDURAL_PRIMITIVES |
RAY_FLAG_CULL_FRONT_FACING_TRIANGLES |
RAY_FLAG_ACCEPT_FIRST_HIT_AND_END_SEARCH, // uint RayFlags
0xFF, // uint InstanceInclusionMask
newRay // RayDesc Ray
+11 -4
View File
@@ -160,7 +160,8 @@ void main(uint3 DTid : SV_DispatchThreadID)
scene_acceleration_structure, // RaytracingAccelerationStructure AccelerationStructure
RAY_FLAG_SKIP_PROCEDURAL_PRIMITIVES |
RAY_FLAG_FORCE_OPAQUE |
RAY_FLAG_CULL_FRONT_FACING_TRIANGLES | RAY_FLAG_ACCEPT_FIRST_HIT_AND_END_SEARCH, // uint RayFlags
//RAY_FLAG_CULL_FRONT_FACING_TRIANGLES |
RAY_FLAG_ACCEPT_FIRST_HIT_AND_END_SEARCH, // uint RayFlags
0xFF, // uint InstanceInclusionMask
newRay // RayDesc Ray
);
@@ -193,8 +194,8 @@ void main(uint3 DTid : SV_DispatchThreadID)
q.TraceRayInline(
scene_acceleration_structure, // RaytracingAccelerationStructure AccelerationStructure
RAY_FLAG_SKIP_PROCEDURAL_PRIMITIVES |
RAY_FLAG_FORCE_OPAQUE |
RAY_FLAG_CULL_BACK_FACING_TRIANGLES, // uint RayFlags
//RAY_FLAG_CULL_BACK_FACING_TRIANGLES |
RAY_FLAG_FORCE_OPAQUE, // uint RayFlags
push.instanceInclusionMask, // uint InstanceInclusionMask
ray // RayDesc Ray
);
@@ -261,6 +262,11 @@ void main(uint3 DTid : SV_DispatchThreadID)
#endif // RTAPI
if (surface.IsBackface())
{
hit_depth *= 0.5; // push inwards to help avoid shadow leaks from inwards to outside
}
surface.P = ray.Origin;
surface.V = -ray.Direction;
surface.update();
@@ -382,7 +388,8 @@ void main(uint3 DTid : SV_DispatchThreadID)
scene_acceleration_structure, // RaytracingAccelerationStructure AccelerationStructure
RAY_FLAG_SKIP_PROCEDURAL_PRIMITIVES |
RAY_FLAG_FORCE_OPAQUE |
RAY_FLAG_CULL_FRONT_FACING_TRIANGLES | RAY_FLAG_ACCEPT_FIRST_HIT_AND_END_SEARCH, // uint RayFlags
//RAY_FLAG_CULL_FRONT_FACING_TRIANGLES |
RAY_FLAG_ACCEPT_FIRST_HIT_AND_END_SEARCH, // uint RayFlags
0xFF, // uint InstanceInclusionMask
newRay // RayDesc Ray
);
+1 -1
View File
@@ -142,7 +142,7 @@ bool VXGI_ENABLED = false;
bool VXGI_REFLECTIONS_ENABLED = true;
bool VXGI_DEBUG = false;
int VXGI_DEBUG_CLIPMAP = 0;
bool CAPSULE_SHADOW_ENABLED = true;
bool CAPSULE_SHADOW_ENABLED = false;
float CAPSULE_SHADOW_ANGLE = XM_PIDIV4;
float CAPSULE_SHADOW_FADE = 0.2f;
+12 -8
View File
@@ -555,6 +555,7 @@ namespace wi::scene
if (wi::renderer::GetDDGIEnabled())
{
float bounds_blend = 0.01f;
ddgi.frame_index++;
if (!TLAS.IsValid() && !BVH.IsValid())
{
@@ -563,6 +564,7 @@ namespace wi::scene
if (!ddgi.ray_buffer.IsValid()) // Check the ray_buffer here because that is invalid with serialized DDGI data, and we can detect if dynamic resources need recreation when serialized is loaded
{
ddgi.frame_index = 0;
bounds_blend = 1;
const uint32_t probe_count = ddgi.grid_dimensions.x * ddgi.grid_dimensions.y * ddgi.grid_dimensions.z;
@@ -611,14 +613,16 @@ namespace wi::scene
device->CreateTexture(&tex, nullptr, &ddgi.depth_texture);
device->SetName(&ddgi.depth_texture, "ddgi.depth_texture");
}
ddgi.grid_min = bounds.getMin();
ddgi.grid_min.x -= 1;
ddgi.grid_min.y -= 1;
ddgi.grid_min.z -= 1;
ddgi.grid_max = bounds.getMax();
ddgi.grid_max.x += 1;
ddgi.grid_max.y += 1;
ddgi.grid_max.z += 1;
float3 grid_min = bounds.getMin();
grid_min.x -= 1;
grid_min.y -= 1;
grid_min.z -= 1;
float3 grid_max = bounds.getMax();
grid_max.x += 1;
grid_max.y += 1;
grid_max.z += 1;
ddgi.grid_min = wi::math::Lerp(ddgi.grid_min, grid_min, bounds_blend);
ddgi.grid_max = wi::math::Lerp(ddgi.grid_max, grid_max, bounds_blend);
}
else if (ddgi.ray_buffer.IsValid()) // if ray_buffer is valid, it means DDGI was not from serialization, so it will be deleted when DDGI is disabled
{
+1 -1
View File
@@ -9,7 +9,7 @@ namespace wi::version
// minor features, major updates, breaking compatibility changes
const int minor = 71;
// minor bug fixes, alterations, refactors, updates
const int revision = 697;
const int revision = 698;
const std::string version_string = std::to_string(major) + "." + std::to_string(minor) + "." + std::to_string(revision);