How to: Render Inside A Medium

(with correct IOR tracking)

MoonRay natively supports nested dielectrics in scalar mode only, which allows for correct index of refraction tracking. However, if you want your camera to start in a certain medium (say, underwater), there are a few attributes you need to set on the camera to allow for correct index of refraction tracking.

Attribute Descriptions

  • medium_material: the material you want the camera to start in
  • medium_geometry: limits the application of the medium_material only to the medium_geometry

    Note: medium_geometry is primarily useful if you want your camera to be partially submerged in a medium. The rays that pass through the medium_geometry will have the index of refraction of the specified medium_material, while rays that do not pass through the medium_geometry will assume they are in air. Setting medium_geomety may have a small, negative performance impact, so I wouldn’t set this unless you know your camera will be partially submerged.


local waterMat = DwaRefractiveMaterial("waterMat") {
    ["index_of_refraction"] = 1.33
local waterBox = AbcGeometry("water") {
    ["medium_material"] = waterMat
    ["medium_geometry"] = waterBox

The image comparison below shows the effect of setting the medium_material to water. As expected, the rightmost sphere with a water material applied to it disappears, while the sphere with the red specular material applied to it appears duller.

medium material with IOR 1.33 applied include.image_alt_after