Skip to content

Commit bd194c7

Browse files
authored
Fix: use first sample of given beam when calculating output for non-hits (#332)
Before, the first sample of first beam were used for all output points
1 parent 5a098ad commit bd194c7

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/gpu/nodeKernels.cu

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -150,14 +150,14 @@ __device__ void saveReturnAsHit(const RaytraceRequestContext* ctx, int beamIdx,
150150
}
151151
}
152152

153-
__device__ void saveReturnAsNonHit(const RaytraceRequestContext* ctx, int beamIdx, int returnPointIdx,
153+
__device__ void saveReturnAsNonHit(const RaytraceRequestContext* ctx, int firstSampleInBeamIdx, int beamIdx, int returnPointIdx,
154154
rgl_return_type_t returnType)
155155
{
156156
// Arbitrary decision - if all samples are non hits, I just take the distance from center ray. This distance will be either
157157
// ctx.nearNonHitDistance or ctx.farNonHitDistance, based on optix kernel processing - check optixPrograms.cu. This provides
158-
// being able to set below minRange, above maxRange and non hit results with the same code. Moreover, results for sample
159-
// at idx 0 are always present with current implementation.
160-
const auto nonHitDistance = ctx->mrSamples.distance[0];
158+
// being able to set below minRange, above maxRange and non hit results with the same code. Moreover, results for
159+
// first sample in beam are always present with current implementation.
160+
const auto nonHitDistance = ctx->mrSamples.distance[firstSampleInBeamIdx];
161161

162162
if (ctx->xyz != nullptr) {
163163
const Mat3x4f ray = ctx->raysWorld[beamIdx];
@@ -358,7 +358,7 @@ __global__ void kReduceDivergentBeams(size_t beamCount, int samplesPerBeam, rgl_
358358
for (int returnIdx = 0; returnIdx < returnCount; ++returnIdx) {
359359
const auto returnPointIdx = beamIdx * returnCount + returnIdx;
360360
const auto returnType = getReturnType(returnMode, returnIdx);
361-
saveReturnAsNonHit(ctx, beamIdx, returnPointIdx, returnType);
361+
saveReturnAsNonHit(ctx, firstSampleInBeamIdx, beamIdx, returnPointIdx, returnType);
362362
}
363363
return;
364364
}

0 commit comments

Comments
 (0)