Path Tracer Rendering Dissection


I’m working on a real time Path Tracer using Optix. I started off with the SDK path tracer that came with Optix 4.0. Currently it renders into a single output buffer and all the values irrespective of the type of the light path goes into a same buffer.

I want to split the render for eg, I want to have the diffuse, specular reflections and caustics all rendered out separately. But when I display I want to add them up and display one single perfect image. But if I dont add up the diffuse contribution, I want the user to see only the caustics and the specular reflections. Please let me know What is the best way to go about it ?

Thanks in advance!!

Hi Rathnavel.

It’s not so much the paths that have diffuse or specular properties. It’s a property of the surfaces that the paths touch.

Have you considered what you want to output when a diffuse surface reflects in a specular surface or when a specular reflection refracts on a diffuse surface?

Since these things are intertwined I’m afraid it may not be as easy as rendering diffuse and specular to different buffers and adding them up afterwards.

What I imagine you could do is create two output buffers and based upon the first surface a path hits (depending on it being shaded diffurse or specular), have that whole path render to one of the two buffers, irrespective of the surfaces hit after that first bounce. However I’m not sure if that will give the result that you have in mind, since it will make the distintion based on the surface/object hit and not on a light effect.

Caustics especially are going to be hard. In a path tracer caustics are not a concept within the code. They aren’t added in separately, as they would be in a rasteriser, they just ‘happen’ as an effect of how light and geometry interact (as in the real world). Since each path is treated separately, there is no way for it to know that its light is contributing to a concentration of light that we humans experience as something that we call a caustic.

I must note that I have been working with path tracers for only a year. I’d be interested to know if anyone can correct or support what I’ve said above.

Let me close with a question: what is the effect that you would like to achieve by dissecting light?

Have a merry Christmas. :)

Good reply from PeterRabbit. I’ll add that this type of splitting is commonly called an Arbitrary Output Variable (AOV) in film production. This term might have been coined in Pixar’s Renderman documentation, which you can find online.

You could implement AOVs in OptiX by adding fields like “diffuse” and “specular” to the PerRayData struct, then writing those entries to separate output buffers toward the end of the ray-gen program.

As you already noted, the notion of what is diffuse and what is specular is not well defined in a path tracer with multiple bounces. Some renderers let the user specify expressions for AOVs; for example, to handle a caustic the user might say “give me all the paths that have one or more specular bounces followed by a diffuse bounce”, in a regular-expression like syntax. The OpenShadingLanuage spec on github has more info about light path expressions.

To get started on something easier, how about putting two lights in your scene and splitting their contributions into two AOVs? That is well defined in a path tracer and still useful.