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.

indirectDiffuseComparison_loRes

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,

Jorge

13 Responses to “Point-based Indirect Diffuse/Colour Bleeding”

  • Tessa Says:

    Hi Jorge,
    Thanks for the 3delight tips. I have done a similar thing to your images above with a mock up cornell box, and using a light shader rather than surface shaders. My point cloud looks good, but in my render when I read the ptc i am not getting colour bleeding on the walls of the cornell box, as you would get with final gathering for example. Just wondered if you had noticed this. Any ideas why? Cheers

    • Jorge Says:

      @Tessa: It depends on you shader. What did you use to bake the colour bleeding and how? Can you elaborate please?

      Please read my response to Christine.

      Let me know if this works please.
      Jorge

  • Clay Says:

    Hi Jorge. First, thanks for your very detailed and informative blog posts. I look forward to more!

    I’m having trouble getting this to work right. It seems to be writing out a point cloud fine, but it doesn’t contain any color information when I open it in ptcview. When I then render from that (colorless) pointcloud, it seems like my object (a rainbow helix in the center) recieves light from the white box it sits inside of, but I see no other colors bouncing off onto the walls.

    Am I missing a step in the process? I’ve tried adding Visibility attributes to the geometry (and playing with Diffuse Rays and such), but with no success. I am new to renderman, so I am a bit clueless. Ambient Occlusion worked quite easily, on the otherhand! Cheers

    • Jorge Says:

      @Clay: I think I forgot to mention that I applied normal lambert shaders with “bright” colours to the objects in my scene. Please read my response to Christine. If this doesn’t help, please let me know guys. Sorry for the confusion.

      Jorge

  • Jorge Says:

    Hi Guys, sorry for the late reply.

    Thanks a lot guys, keep the replies coming.

    Jorge

  • Christine Bui Says:

    I’m having the same problem as the other guys here. I applied the JPindirectDiffuseLight.sdl to the ambient light and renderthe ptc file. Then I apply JPiddPtcRead.sdl to the ambient light and try to render the final image. But I see no color bleed. Your response to @Clay sounds like the missing step but how do I do that? The surface assignment slot will not read JPiddPtcRead.sdl.

    Thanks again
    Christine

    • Jorge Says:

      Hi Christine. I just noticed that I forgot to mention something on the post. For example, image you have a cornell box like the one I have in my renders. I applied normal lambert shaders, wrote by me, I didn’t try using the maya lambert shader but it might work as well, gave them bright colours for the purpose of having some nice colour bleeding, and then you created the ambient light and assigned the light shader to it to bake indirect diffuse to the point cloud. After that, you assign the iddPtcRead shader to the ambient light and point it to the newly created point cloud.

      Be aware that to have some kind of noticeable colour bleeding I used bright colours, like the red, blue and green.

      So, to sum up, set up a normal scene with normal lambert shaders, and apply them to your objects, giving each object a different colour. Then add the iddLight to the ambient light( a special one just to bake the indirect diffuse, this light won’t light your scene) and bake the point cloud as explained in the post. After the point cloud is baked, assign the iddPtcRead to the ambient light, point it to the point cloud file, and render. Be sure you tweak the render settings as desired. Everything should be working.

      Please le me know if this works.
      Jorge

  • tom Says:

    hi
    could you post your lambert shaders, pretty please, Id love to get this working
    thanks for posting this tutorial, good 3delight stuff is abit thin on the ground

  • tom Says:

    sorry if Im very noob to all this
    Ive got this working now
    using maya lamberts, remember to make at least one of them with some incandenscence or you dont get anything ‘lighting’ your scene

    • Jorge Says:

      Hi Tom. Nice to know that it worked with Maya shaders. I gotta try it myself. If you need anything else let me know.

      Thanks
      Jorge

  • pg Says:

    cool stuff, thanks.
    What do you think the workflow would be for animated geo?
    Do you know how to combine two point clouds?
    Say one for animated geo and the other for the static background geo.
    You’ve probably already seen this but here is another method using the atmosphere shader:

    http://www.3delight.com/en/modules/PunBB/viewtopic.php?id=1365&p=1

  • bruce Says:

    Hi Jorge,
    I have a question about colorbleeding.The indirectdiffuse function need to use raytrace.The renderman’s environment lighting has two methods to finish colorbleeding effect. One is raytrace,the other is pointbased.So I want to know that when we’re using light shader, how could we achieve the colorbleeding without raytrace?

    • Jorge Says:

      Hi bruce, to compute colorbleeding you always need to use ray tracing because rays need to be shoot so it detects if objects are near, and if they are which color they have to create the colorbleeding effect. What you can do, is actually bake that colorbleeding into a point cloud, so in the future you don’t need to compute it again, but you have to be careful because if the position of the objects change or if the objects shader changes color, etc, the colorbleeding will need to be re-baked into the point cloud.

      Hope this helps,
      Jorge

Leave a Reply