Skip to content

Commit

Permalink
path tracing: added support for non-shadow casting light and non-shad…
Browse files Browse the repository at this point in the history
…ow receiver surface
  • Loading branch information
turanszkij committed Dec 3, 2023
1 parent 7aef0ef commit 2f5631e
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 36 deletions.
74 changes: 39 additions & 35 deletions WickedEngine/shaders/raytraceCS.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -308,51 +308,55 @@ void main(uint3 DTid : SV_DispatchThreadID, uint groupIndex : SV_GroupIndex)
{
float3 shadow = energy;

RayDesc newRay;
newRay.Origin = surface.P;
newRay.TMin = 0.001;
newRay.TMax = dist;
newRay.Direction = L + max3(surface.sss);
if(light.IsCastingShadow() && surface.IsReceiveShadow())
{
RayDesc newRay;
newRay.Origin = surface.P;
newRay.TMin = 0.001;
newRay.TMax = dist;
newRay.Direction = L + max3(surface.sss);

#ifdef RTAPI

uint flags = RAY_FLAG_SKIP_PROCEDURAL_PRIMITIVES | RAY_FLAG_CULL_FRONT_FACING_TRIANGLES;
if (bounce > ANYTHIT_CUTOFF_AFTER_BOUNCE_COUNT)
{
flags |= RAY_FLAG_FORCE_OPAQUE;
}
uint flags = RAY_FLAG_SKIP_PROCEDURAL_PRIMITIVES | RAY_FLAG_CULL_FRONT_FACING_TRIANGLES;
if (bounce > ANYTHIT_CUTOFF_AFTER_BOUNCE_COUNT)
{
flags |= RAY_FLAG_FORCE_OPAQUE;
}

q.TraceRayInline(
scene_acceleration_structure, // RaytracingAccelerationStructure AccelerationStructure
flags, // uint RayFlags
0xFF, // uint InstanceInclusionMask
newRay // RayDesc Ray
);
while (q.Proceed())
{
PrimitiveID prim;
prim.primitiveIndex = q.CandidatePrimitiveIndex();
prim.instanceIndex = q.CandidateInstanceID();
prim.subsetIndex = q.CandidateGeometryIndex();
q.TraceRayInline(
scene_acceleration_structure, // RaytracingAccelerationStructure AccelerationStructure
flags, // uint RayFlags
0xFF, // uint InstanceInclusionMask
newRay // RayDesc Ray
);
while (q.Proceed())
{
PrimitiveID prim;
prim.primitiveIndex = q.CandidatePrimitiveIndex();
prim.instanceIndex = q.CandidateInstanceID();
prim.subsetIndex = q.CandidateGeometryIndex();

Surface surface;
surface.init();
surface.hit_depth = q.CandidateTriangleRayT();
if (!surface.load(prim, q.CandidateTriangleBarycentrics()))
break;
Surface surface;
surface.init();
surface.hit_depth = q.CandidateTriangleRayT();
if (!surface.load(prim, q.CandidateTriangleBarycentrics()))
break;

shadow *= lerp(1, surface.albedo * surface.transmission, surface.opacity);
shadow *= lerp(1, surface.albedo * surface.transmission, surface.opacity);

[branch]
if (!any(shadow))
{
q.CommitNonOpaqueTriangleHit();
[branch]
if (!any(shadow))
{
q.CommitNonOpaqueTriangleHit();
}
}
}
shadow = q.CommittedStatus() == COMMITTED_TRIANGLE_HIT ? 0 : shadow;
shadow = q.CommittedStatus() == COMMITTED_TRIANGLE_HIT ? 0 : shadow;
#else
shadow = TraceRay_Any(newRay, xTraceUserData.y, rng, groupIndex) ? 0 : shadow;
shadow = TraceRay_Any(newRay, xTraceUserData.y, rng, groupIndex) ? 0 : shadow;
#endif // RTAPI
}

if (any(shadow))
{
lightColor *= shadow;
Expand Down
2 changes: 1 addition & 1 deletion WickedEngine/wiVersion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 = 354;
const int revision = 355;

const std::string version_string = std::to_string(major) + "." + std::to_string(minor) + "." + std::to_string(revision);

Expand Down

0 comments on commit 2f5631e

Please sign in to comment.