Wednesday, October 10, 2007

Tutorial: Rendering Caustics in Brazil r/s

Let's start by answering the question, "what are caustics?" According to wikipedia, "a caustic is [an] envelope of light rays reflected or refracted by a curved surface or object, or the projection of that envelope of rays on another surface." This results in the concentration of light into patterns of light and shadow that's projected onto another surface. Caustics are very common in the environment around us and can be used for both artistic effect and to increase the level of realism in 3d renderings.

photos: Jimmy Earl, Heiner Otterstedt

Brazil r/s will automatically and accurately render caustic generated by both reflective (mirror) and refractive (glass, water, etc.) sufaces.

This exercise will cover the various settings that enable and control rendering of caustics in Brazil r/s.

Breakdown

Start by downloading and rendering the example scene (3ds Max 8, and Brazil r/s 2.0).

The scene contains a ground plane, one direct light, a camera, a cylinder (to add some reflections) and a glass teapot that we will use as a caustic generator.

The scene's material setup is as follows:

  1. teapot = Brazil2 glass material with default settings.
  2. ground plane = Brazil2 advanced material with diffuse set to white and a small specular highlight.
  3. cylinder = Brazil2 advanced material with diffuse set to white, highlight shader set to "none" and fully self illuminated (luminosity: 255/255/255) with Kl set to 2.0 (this setting makes the reflected cylinder more visible).

The scene is illuminated by a direct spotlight and a small amount of direct sky light (color: 23/36/50). Most of our caustics will be generated from the spotlight.

The quality and shape of your caustics depends largely on the geometry used to generate the caustics. More complex geometry creates more complex caustics, reflecting and refracting your light rays in a greater variety of directions.

The rendered scene is shown below with notes what we want to do. The rotated camera view is there to make the image a little more dramatic and to get the caustics aligned into a diagonal.

Note: Make sure that Genrate Caustics is checked on in Brazil2 Glass material options.

Execution

  1. Enable Caustics
    1. turn on photons in light rollout -- keep the default settings.
    2. Switch the lights shadow generator to "Brazil2 Ray shadows" to make the shadow transparent as they travel through the glass object.

    3. Check "Enable" in "Brazil Photon Map Settings" rollout, and turn Caustics on (marked with red dot).

    4. Render.
      Caustics are there and look good already, but the transparent shadows look wrong.
  2. Fixup the shadows by changing the shadow mode to "Rectangular Area":
    1. In the spotlight's Brazil 2 Ray Shadows rollout, change the shadow mode to the "Rectangle Area"
    2. Give the shadow some size by setting the scale of the shadow's Area Light Scale to 10 by 10
    3. Adjusting the max error to 5% will give us a nice balance between performance and quality in this scene.

  3. Tweak the caustics settings
    1. Set the "Photons in Estimate" to 50
    2. Set the "Max Search Radius" to 1000
    3. Adjust the "Energy Tweaks" "Multiplier" to .55

      The larger Max Search Radius will blends sparse areas of the caustic photons together better, and the smaller number of Photons in Estimate will cause the photon gather to stop searching for more photons around the sampling points much sooner ("Smaller Effective Radius"). By lowering the energy Multiplier, we are preventing the amount of over-bright photons in the of caustics.
  4. Increase the image sampling and render
    1. Set the Image Sampling to 1 by 2.
    2. Render

Conclusion

Now we have our glass teapot with believable shadows and caustics. You can download and render this final scene here.

Caustics in Brazil r/s render very quickly, so they are a feature that's actually quite fun to play and experiment with. Try different settings from those above and note how the changes affect the rendering. In addition to that, try getting creative and experimenting with some of the following:

  1. Glossy reflections on the teapot glass material.
  2. Allow Absorption in the glass material.
  3. Try caustics with Dispersion.
  4. Play with area shadow settings.
  5. Experiment with the "Affect Surface" settings in the light.
  6. Try different Photon Map Settings.
  7. And in the end, why not a little of post-production?

The techniques mentioned above were all used in the creation of the following picture:

Tutorial Contributed by Pavel Romsy