Skip to content

Commit 7b27052

Browse files
committed
Fixed max light index for light sampling to numLights - 1
1 parent bb6df97 commit 7b27052

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

renderer/cpp/src/core/shading.cu

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ void diffuseKernel(int *materialRequests, const int *numMaterialRequests, Pathst
174174
if(useLightSampling) {
175175
state.Lsample = glm::vec3(0.0);
176176
if (numLights > 0) {
177-
int lightIndex = min(int(numLights * curand_uniform(&localRandState)), numLights);
177+
int lightIndex = min(int(numLights * curand_uniform(&localRandState)), numLights - 1);
178178
sample = glm::vec2(curand_uniform(&localRandState), curand_uniform(&localRandState));
179179
Ray shadowRay(ray.o, glm::vec3(0.0));
180180
state.lightPdf = lights[lightIndex].Sample(shadowRay, state.Lsample, sample);

0 commit comments

Comments
 (0)