Sep 9 2009

Point-based Indirect Diffuse/Colour Bleeding

If you read my previous post about baking occlusion, you’ll be very comfortable about this subject.

Much like baking occlusion into a point cloud, baking indirect diffuse also involves two steps. First we need to actually bake it into a point cloud, and then we need to read it back from the same point cloud.

First step:

Instead of having to add a surface shader that computes indirect diffuse to every object, in this approach we are going to use a light shader that computes that for us. This way we can leave our surface shaders, etc, untouched and only using a simple light with this shader I wrote. Just create an ambient light and apply the shader to it. You can also specify the number of samples in the shader, and the intensity of the indirect diffuse being calculated.
To bake it, we need to make sure to turn off the culling operations to be sure that the backfacing and hidden faces are taken into account by the renderer when creating the indirect diffuse pass(second step of this approach), and we also need to use a dicing method that is independent from the camera view:

Attribute “cull” “hidden” [0]
Attribute “cull” “backfacing [0]
Attribute “dice” “rasterorient” [0]

Again, we can use low pixel samples because we are not interested in the quality of the render, we only want to create the point cloud at this stage, thus its creation being faster:

PixelSamples 1 1

If we want a very dense point cloud, then we need to use a low shading rate. 0.5 should be enough. Just play around a bit to get this value right.

Second step:

In this step we only have to read back the information stored in the point cloud. To do this we use this shader I wrote in the same light, which is specific to read the data stored in the point cloud we created in the step before.
You can increase the pixel samples, lower the shading rate if needed and turn the culling and dicing back on.


To render these images, I used 3Delight. The shaders that work with PRman are here. I haven’t tested them but they should work.

Let me know what you guys think,