Path Tracing CUDA Start Problems


I´m new to CUDA and i´m trying to “convert” my cpu path tracer into gpu path tracer. So I have to parallize my for-loop over the hole image or? So that every pixel is one thread in CUDA. But I don´t know how to start, because how do I kwow which thread is which pixel, how to combine them to the overall image.

Here some snippet

And I have another question. My cpu path tracer has some classes like Vector (with add/sub etc. operations), Material or Color. In my main program I add/sub Vectors etc. How can Cuda kwow these operations in the kernels too?

Hopefully I get some tipps, because I´m a beginner in CUDA. Thanks a lot :)

I would strongly recommend that you do some simpler tutorial projects first, until you get to an intermediate to advanced level in CUDA programming. Only then it will become more clear to you how to approach something like path tracing on the GPU.

You could also study some existing implementations (there are some in CUDA and OpenCL).

Specifically, here are some implementations of ray-tracers in CUDA:

Here is a path tracer:

I have been doing some coding about that matter for some time - You can see my code here. It is still in pre-alpha stage and much is yet to be developed. It can be helpful to get the idea, though…
At least I think so :)


Thanks to you all, I will try to learn a bit about CUDA and look at the examples you gave me. I have 3 months to finish my bachelor thesis about this, the topic is “Path Tracing on the GPU”. My Path Tracer works fine, so now I can bother with CUDA. Hope the time is enough to finish my work.