Wednesday, August 21, 2013

DiffuseHitCache

DiffuseHitCache is a PRMan attribute that have the renderman to do a lookup to a pointcloud or brickmap file for the indirect illumination at the ray hit point. In normal scenario, if you have a blue floor and a grey ball sitting on it, you should see the blue color bleeding onto the base of the sphere. The result I am hoping to achieve is have blue floor reflect other colors than blue.




















If you wanna to have the floor to bounce off yellow color regardless of what the floor color is, you will first need to have the floor with yellow color. Next, create a RMSGIPtcLight and set the Bake Type to Create RenderRadiosity. This will generate a PointCloud file with Cs channel representing the color of the scene objects.

Point Cloud file of the scene
























We will be uisng this pointcloud file for the renderman to lookup to during the indirect illumination pass. You could run a brickmake command to convert pointcloud file to brickmap which does the same thing except for speed difference. For a simple scene like this, using a brickmap will not speed up a lot anyway.

For this to work, the pointbase way of achieving indirect illumination will not work. We will need to switch over to using Raytracing. Delete the RMSGIPtcLight node and any Render Radiosity pass. Create a RMSGILight node, then we need to add a few PRMan attributes to the floor object.

Diffuse Ray Shading - set this to Cache so that at the time of indirect illumination, you can tell renderman to look up for a point cloud or brick map file.

Diffuse Hit Cache - this is where you specify the path to the pointcloud or brickmap file. Beware that you will have to write it in this format:
file: D:\myFile.ptc

Pre Shape MEL - the final step is to add this attribute with the following command:
RiAttribute "shade" "string diffusehitcolorchannel" "Cs";
this will instruct renderman to lookup to the Cs channel in the pointcloud file.

Now, the floor can be any color but the color that get bounces off from the floor will be yellow.


No comments: