diff --git a/src/renderer/pathtrace.c b/src/renderer/pathtrace.c index 56233ef7..92f052a2 100644 --- a/src/renderer/pathtrace.c +++ b/src/renderer/pathtrace.c @@ -48,10 +48,10 @@ static inline struct hitRecord getClosestIsect(struct lightRay *incidentRay, con return isect; } -struct color path_trace(const struct lightRay *incidentRay, const struct world *scene, int max_bounces, sampler *sampler) { +struct color path_trace(struct lightRay incident, const struct world *scene, int max_bounces, sampler *sampler) { struct color path_weight = g_white_color; struct color path_radiance = g_black_color; // Final path contribution "color" - struct lightRay currentRay = *incidentRay; + struct lightRay currentRay = incident; for (int bounce = 0; bounce <= max_bounces; ++bounce) { const struct hitRecord isect = getClosestIsect(¤tRay, scene, sampler); diff --git a/src/renderer/pathtrace.h b/src/renderer/pathtrace.h index 464463d7..48f59e68 100644 --- a/src/renderer/pathtrace.h +++ b/src/renderer/pathtrace.h @@ -16,9 +16,4 @@ struct world; -/// Iterative path tracer. -/// @param incidentRay View ray to be casted into the scene -/// @param scene Scene to cast the ray into -/// @param maxDepth Maximum depth of path -/// @param rng A random number generator. One per execution thread. -struct color path_trace(const struct lightRay *incidentRay, const struct world *scene, int max_bounces, sampler *sampler); +struct color path_trace(struct lightRay incident, const struct world *scene, int max_bounces, sampler *sampler); diff --git a/src/renderer/renderer.c b/src/renderer/renderer.c index 444e3a71..92afb41d 100644 --- a/src/renderer/renderer.c +++ b/src/renderer/renderer.c @@ -223,8 +223,7 @@ void *renderThreadInteractive(void *arg) { initSampler(sampler, SAMPLING_STRATEGY, r->state.finishedPasses, r->prefs.sampleCount, pixIdx); struct color output = textureGetPixel(r->state.renderBuffer, x, y, false); - struct lightRay incidentRay = cam_get_ray(cam, x, y, sampler); - struct color sample = path_trace(&incidentRay, r->scene, r->prefs.bounces, sampler); + struct color sample = path_trace(cam_get_ray(cam, x, y, sampler), r->scene, r->prefs.bounces, sampler); nan_clamp(&sample, &output); @@ -303,8 +302,7 @@ void *renderThread(void *arg) { initSampler(sampler, SAMPLING_STRATEGY, threadState->completedSamples - 1, r->prefs.sampleCount, pixIdx); struct color output = textureGetPixel(r->state.renderBuffer, x, y, false); - struct lightRay incidentRay = cam_get_ray(cam, x, y, sampler); - struct color sample = path_trace(&incidentRay, r->scene, r->prefs.bounces, sampler); + struct color sample = path_trace(cam_get_ray(cam, x, y, sampler), r->scene, r->prefs.bounces, sampler); // Clamp out fireflies - This is probably not a good way to do that. nan_clamp(&sample, &output); diff --git a/src/utils/protocol/worker.c b/src/utils/protocol/worker.c index 8eba337f..686693f1 100644 --- a/src/utils/protocol/worker.c +++ b/src/utils/protocol/worker.c @@ -169,8 +169,7 @@ static void *workerThread(void *arg) { initSampler(sampler, SAMPLING_STRATEGY, thread->completedSamples - 1, r->prefs.sampleCount, pixIdx); struct color output = textureGetPixel(r->state.renderBuffer, x, y, false); - struct lightRay incidentRay = cam_get_ray(cam, x, y, sampler); - struct color sample = path_trace(&incidentRay, r->scene, r->prefs.bounces, sampler); + struct color sample = path_trace(cam_get_ray(cam, x, y, sampler), r->scene, r->prefs.bounces, sampler); nan_clamp(&sample, &output);