Small volumetric path tracer

A picture is worth a thousand words.
D-POWER
Posts: 16
Joined: Tue Dec 25, 2012 8:16 am

Small volumetric path tracer

Post by D-POWER » Thu Jan 10, 2013 8:29 am

I have been working for the past month or so on a volumetric renderer based on smallpt. I implemented multiple scattering and a couple of phase functions (Isotropic and Henyey-Greenstein), the result so far are good enough to be shared, but the convergence is very slow, even slower than smallpt. That's why I'm planning to port this to the GPU and see what I can get.

The code is hosted on github, feel free to fetch it and tell me what you think.
In the first image, there is a weird triangular pattern that I don't know what's causing it (maybe the rng?)
image.png
image.png (821.18 KiB) Viewed 13106 times
Image

Ciebiada
Posts: 9
Joined: Thu Dec 27, 2012 9:38 am
Contact:

Re: Small volumetric path tracer

Post by Ciebiada » Thu Jan 10, 2013 3:06 pm

Nice images but they might have made a better impression if maybe the resolution was smaller so the quality would be better.
Are those white fireflies in the top image a bug? Because it doesn't look like naive-path-tracing caustic noise to me.

Also regarding the rng. I know I've advocated xorshift before but some time ago I found it produced some patterns in my silly path tracing renders. Maybe it was correlation between threads, I'm not really sure, but since then I switched back to a good implementation of simple LCG (like the one in java, the implemtation is publicly available) and had no problems whatsoever. It's fast and for monte carlo simulations its more than enough.

D-POWER
Posts: 16
Joined: Tue Dec 25, 2012 8:16 am

Re: Small volumetric path tracer

Post by D-POWER » Thu Jan 10, 2013 4:26 pm

The fireflies are most likely caused by indirect lighting from the glass sphere, since the light source is small so sampling becomes challenging for a naive path tracer. About the pattern in the first image, I still don't know exactly the problem, but my instincts are telling me it's the random number generator, since I'm using the same seeding parameters for every thread.

spectral
Posts: 382
Joined: Wed Nov 30, 2011 2:27 pm
Contact:

Re: Small volumetric path tracer

Post by spectral » Fri Jan 11, 2013 3:17 pm

Great test :-)

Maybe try this with SmallVCM :-D
Spectral
OMPF 2 global moderator

D-POWER
Posts: 16
Joined: Tue Dec 25, 2012 8:16 am

Re: Small volumetric path tracer

Post by D-POWER » Fri Jan 11, 2013 4:39 pm

Thanks spectral. My goal from the start is to provide a minimal code base for people to experiment with volumetric rendering, and show how it is done in practice, that's why I opted for smallpt, to maintain the spirit of a minimalistic unbiased path tracer.

The code will eventually be ported to the CUDA platform, since it offers huge speed improvements, so I might use some gpu tricks from smallptgpu...
By the way, anyone knows how slow OpenCL is compared to CUDA?

Dade
Posts: 206
Joined: Fri Dec 02, 2011 8:00 am

Re: Small volumetric path tracer

Post by Dade » Sat Jan 12, 2013 4:18 pm

D-POWER wrote:By the way, anyone knows how slow OpenCL is compared to CUDA?
CUDA usually gives access to some of the latest hardware feature not yet available in OpenCL and NVIDIA has introduced some really interesting feature in their latest generations of GPUs. However if a feature is available both in CUDA and in OpenCL, there is not a single technical reason why CUDA should be faster ... if it is faster, you should complain with your CUDA vendor ;)

Keep also in mind that a GTX 580 is faster than the newer GTX 680 for most single precision floating point applications (and HD7970 is a lot faster of both in the same field). So you have also to careful pick the hardware to use.

spectral
Posts: 382
Joined: Wed Nov 30, 2011 2:27 pm
Contact:

Re: Small volumetric path tracer

Post by spectral » Mon Jan 14, 2013 10:28 am

Sure,

It is nice to demonstrate it on a small renderer, but then... it will be interesting to add some comments, some references about the theory etc ;-)

BTW, I agree with Dade, about OpenCL vs CUDA .... OpenCL has approximately the same speed than CUDA... sometimes it is even faster (sometimes not) !

The main advantage (today) of using CUDA is that :
1) You have a good debugger even on the GPU
2) You have some existing librarie (thrust etc...)
3) CUDA C is more advanced than OpenCL

The main advantage of OpenCL are :
1) You can run on different kind of devices... CPU/GPU/...
2) You can handle more memory when using the CPU... interesting for big scenes
3) Dynamic code generation... you can use it to have a more dynamic/flexible renderer
Spectral
OMPF 2 global moderator

D-POWER
Posts: 16
Joined: Tue Dec 25, 2012 8:16 am

Re: Small volumetric path tracer

Post by D-POWER » Tue Jan 15, 2013 10:31 am

Thanks guys for sharing your thoughts about CUDA and OpenCL...

spectral another advantage of CUDA is that it is more and more supporting OO features of C++ which isn't available in OpenCL yet.
spectral wrote:It is nice to demonstrate it on a small renderer, but then... it will be interesting to add some comments, some references about the theory etc ;-)
Well I didn't use much references in my implementation except this paper, you can also find every equations that I used in this doc. If you still have questions, feel free to ask ;)

lion
Posts: 36
Joined: Wed Sep 12, 2012 2:35 pm

Re: Small volumetric path tracer

Post by lion » Thu Jan 17, 2013 6:42 pm

Another advantage of OpenCL is that it can run not only on Nvidia devices.
In some cases OpenGL shader can be used.
This two variants more portable.

D-POWER
Posts: 16
Joined: Tue Dec 25, 2012 8:16 am

Re: Small volumetric path tracer

Post by D-POWER » Mon Mar 11, 2013 3:13 pm

I've ported smallvpt to cuda, added support for sub-surface scattering and fixed a lot of bugs in my scattering code
image36263.png
image36263.png (237.9 KiB) Viewed 12299 times

Post Reply