Skip to content

Commit 0afd2fa

Browse files
fix MIS in the path tracer, dont make every ray that didn't miss go into the miss shader
1 parent c292f41 commit 0afd2fa

3 files changed

Lines changed: 6 additions & 6 deletions

File tree

include/nbl/builtin/hlsl/path_tracing/unidirectional.hlsl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ struct Unidirectional
5454
return hlsl::dot(spectralTypeToLumaCoeffs, col);
5555
}
5656

57-
bool closestHitProgram(uint16_t depth, uint32_t _sample, NBL_REF_ARG(ray_type) ray, NBL_CONST_REF_ARG(closest_hit_type) intersectData)
57+
bool closestHitProgram(const bool lastBounce, uint16_t depth, uint32_t _sample, NBL_REF_ARG(ray_type) ray, NBL_CONST_REF_ARG(closest_hit_type) intersectData)
5858
{
5959
anisotropic_interaction_type interaction = intersectData.getInteraction();
6060

@@ -76,7 +76,7 @@ struct Unidirectional
7676
ray.addPayloadContribution(emissive);
7777
}
7878

79-
if (!matLightID.canContinuePath())
79+
if (lastBounce || !matLightID.canContinuePath())
8080
return false;
8181

8282
bxdfnode_type bxdf = materialSystem.getBxDFNode(matID, interaction);
@@ -192,9 +192,9 @@ struct Unidirectional
192192

193193
continuePath = intersection.foundHit();
194194
if (continuePath)
195-
continuePath = closestHitProgram(d, sampleIndex, ray, intersection);
195+
continuePath = closestHitProgram(d==maxDepth, d, sampleIndex, ray, intersection);
196196
}
197-
if (!continuePath)
197+
if (continuePath)
198198
missProgram(ray);
199199

200200
const uint32_t sampleCount = sampleIndex + 1;

include/nbl/builtin/hlsl/shapes/spherical_triangle.hlsl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ struct SphericalTriangle
6464
return solidAngle(dummy0,dummy1);
6565
}
6666

67-
scalar_type projectedSolidAngle(const vector3_type receiverNormal, NBL_REF_ARG(vector3_type) cos_sides, NBL_REF_ARG(vector3_type) csc_sides, NBL_REF_ARG(vector3_type) cos_vertices)
67+
scalar_type projectedSolidAngle(const vector3_type receiverNormal, NBL_REF_ARG(vector3_type) cos_vertices)
6868
{
6969
if (pyramidAngles())
7070
return 0.f;

0 commit comments

Comments
 (0)