Photon Illumination of DGS Materials in Mental Ray for Maya

DGS stands for Diffuse, Glossy, Specular. DGS materials are used to simulate materials with physical accuracy. It's the combination of these DGS materials with Global Illumination that produce those 3D scenes of unprecedented photo-realism.

Global Illumination

Global Illumination is a rendering tool designed to recreate the effect of reflected light. With Global Illumination, a single light can be used to illuminate a whole room. This is simply because light reflected by its surroundings continues to illuminate the scene.

The main benefit of using global illumination is that it produces a more predictable behavior of light. It accurately models the behavior of light by simulating indirect illumination. Photographers, for example, use the bouncing of light off reflector boards to increase a light's size - producing a softening effect. Diffuse light produced from this technique is perfect for reproducing human skin tone. Another benefit of Global Illumination is its ability to recreate color bleed. This is where the color from an object reflects or bleeds onto surrounding objects. This effect can add just that extra touch of realism to a scene.

Photons

To achieve the global illumination effect Photon Mapping is used. A Photon map is a data file used to store the global illumination solution. The visual effects of Photons are like individual paintball splats. When initially rendered, they leave their illuminating mark on the object and continue to travel as they bounce from object to object.

Model set-up

The aim here is to study the use of DGS materials with Global Illumination. The same model set-up is being used from the previous article and the rendered results will be used to compare conventional materials with DGS materials.
The main difference in the set-up is that a large cube is being used to recreate a room environment. This prevents photons from escaping into infinity - saving render time. Also, two point lights are included instead of spotlights, as they will convert to Mental Ray area lights more accurately.

DGS Materials

Unlike conventional 3d shaders, such as a Lambert, Blinn, Phong or Anisotropic, a DGS Material simulates the natural behavior of light. Objects are seen by the human eye because the material properties of an object enable light to be reflected off its surface and into our eye. Some surfaces are rough and will cause light to reflect in different directions. This is known as diffuse light. In contrast are near perfectly smooth objects which reflect light at an equal angle of incidence. This is referred to as Specular light. Most surfaces exist somewhere between being rough and smooth. Those surfaces that have a slight sheen to them are known as glossy surfaces.

A DGS material has eight attributes: Diffuse, Glossy, Specular, Shiny, Shiny_u, Shiny_v, Transp, and Ior.

Diffuse: The Diffuse color is the base color of an object. The diffuse attribute controls how much of the light is reflected in all directions.

Glossy: The glossy attribute controls light that is reflected in one direction, but slightly scattered. It is used to produce blurry reflections off surfaces that have a slight roughness.

Specular: The specular attribute controls how much light is reflected. It produces the characteristic hotspot or white shine seen on highly polished surfaces and also produces mirror like reflections.

As the DGS material is a physically accurate representation of a material, the Diffuse, Glossy and Specular attributes need to be set with accuracy in mind. For example, it is not possible to have a randomly rough, shiny object. Each Value of the HSV for Diffuse, Glossy and Specular can not exceed a combined value of 1. For example, a semi-glossy surface might have a Diffuse of 0.2, a Glossy value of 0.5, and a Specular value of 0.3 - giving the combined Value of 1.0. It is however possible to have a combined Value of less than one. As these attributes describe the reflection of light, smaller values simply mean that more light is being absorbed.

Shiny: Shiny describes how blurry the specular reflects are and only affects materials set with a Glossy value. It works a little like the Cosine Power parameter of the Phong shader. The lower the Shiny value the glossier or more blurred the specular reflections will be. For example, higher values above 100 produce hard specular reflections and very low values of less than 1 make glossy reflection appear like a diffuse reflection.

Shiny_u & Shiny_v: These control the amount of blurring along the U and V axis of a Glossy reflection. They are used to produce an anisotropic effect. Rough surfaces are usually made up of microscopic random bumps, producing a soft diffuse reflection. Anisotropic highlights however are produced form surfaces with microscopic bumps running along in an even grain. Reflections stretch in the direction of this grain, producing highlights that travel in one direction.
The Shiny_u and Shiny_v work just like the Shiny attribute where the lower the value, the larger the blur. When Shiny_u or Shiny_v is set to a value other than 0, Shiny is ignored. Anisotropic highlights are created by setting a value higher in either the U or V direction.

Transp: Transp controls how transparent the object is. If this is set to a value of 1.0, then the object effectively becomes air. As objects such as glass also reflect, this setting needs to be set to less than 1.0. For example, to create a glass surface, set Transp to 0.9, and set Specular to white. Or, for frosted glass, replace Specular with Glossy and set a value for Shiny.

Ior: Ior controls the Index of Refraction. It is used to create the effect of light passing through a medium denser than air. To see the effect of IoR the Transp needs to be set to a value higher than 0. The default of 1.0 produces no refraction and is equivalent to an object with a density equal to air. Some commonly used Index of Refraction values are: Vacuum = 1.0, Air = 1.0003, Water = 1.333, Glass = 1.5 to 1.7 and Diamond = 2.419.

Material Set-Up

All the objects in this scene will be assigned a DGS_material and a DGS_material_photon. The photon material will handle the indirect illumination created by the Global Illumination. Materials are assigned by selection the object, and in the Rendering Menu section, under Lighting/Shading, assigning a new dgs_material. A DGS material Shading Group is created, with the dgs_material linked to it. Scrolling to the Mental Ray section reveals the Custom Shaders section. The Material Shader field is linked to the new dgs_material and the material's attributes can be activated by selecting the input connection button. To assign the DGS_material_photon, scroll to the Custom Shaders section and select the add texture button next to the Photon Shader field. From the Photonic Materials group, choose DGS_material_photon. Ensure that both the photon material and material settings match. Finally, turning on Opaque in the Flag section will speed up render times.

Backdrop Material: The backdrop is a painted white wall. Acrylic based paint is usually a rough matte surface with most of the light reflected being diffuse. The backdrop material's Diffuse Value is therefore set to 0.8, with Hue and Saturation set to 0.0 as it is a white wall. Glossy and Specular are set to 0.0 as the wall is being used to scatter the light.

Ball Material: The ball, in contrast to the wall will be shiny. As a highly polished object, it will be used to study the effects of bouncing light. The ball will be a dark grey object with a Diffuse Value of 0.2 (with Hue & Saturation set to 0.0). To give the ball slightly softened highlights, Glossy is set to 1.0. The rest of the reflections will come from the Specular with a setting of 0.7. Shiny is left at 50, just to blur the highlights a little.

Negative Fill and Room Environment: The black reflector boards (or negative fill) and the Room Environment are to absorb most of the light. In this set-up the Negative Fill is being used to shield the sphere from any direct illumination. Diffuse is reduced to 0.1, and Glossy and Specular are set to 0. Some light is reflected so that a Photon Map can be generated and we avoid the annoying "no photons stored after emitting 10000 photons" warning. This warning results when photons travel into infinite space, or are completely absorbed by a material and their reflection is not caught at least once.

Reflector Board - Positive Fill: The reflector board is being used to catch the bouncing light and used to illuminate the sphere like a large soft light. Its Diffuse is set to a Value of 0.8 and Glossy and Specular are set to 0.0.

Light Shader and Physical Lights

As well as 3d objects, Mental Ray can also apply shaders to lights and cameras. A Physical Light can be applied to a point light, as a shader, and used to simulate the real world light property of decay. Physical Lights use a natural inverse-square fall off. Fall off is the rate at which light decays. A light's intensity diminishes by a factor of four each time it doubles its distance. An object that is twice as far away from a light source will be four times less bright than an object positioned half way. In other words, an object's brightness or illumination will be affect by how close or far it is to the light source.

The main value to control of a Physical light is its Color. The light's intensity is defined by the Value attribute of its HSV color. By default Maya automatically assigns a Value of 1000. Since the Physical light uses an inverse-square fall off, the RGB values are never in the range of 0-1 and need to be high enough for the light to travel.

FMental Ray Area Lights

An Area Light is a far more physically accurate representation of a light source. Area lights have shape, enabling them to cast multiple rays from points within its shape - producing those characteristic soft, raytraced shadows.

Area Lights have five attributes to control including Type, Sampling, Low Level, Low Sampling and Visible. The main Types (or shapes) of Mental Ray area lights are Rectangle, Disc, Sphere, Cylinder, and User. Sampling controls the quality of the area light and reduces graininess. Increasing the sampling is like adding more lights into the light area. The more lights casting rays, the cleaner the shadows will be, but the slower the renders times. The default of 3 x 3 is fine and is usually set to 5 x 5 when doing a final renders. Low Level is slightly more complicated. Setting a Low Level area value will cause Mental Ray to look at the sum of traced reflections and refractions. If this level exceeds the Low Level value, then the next Low Sampling attribute will override the Sampling field. For example, if Sampling is set to 5 x 5, Low Level is set to 3, and a Low Sampling set to 2 x 2, then once the combined reflection and refraction rays exceed 3, the reflections and refractions of the shadow are sampled at a lower value of 2 x 2. This can greatly increase performance. Visible enables the area light to be seen as a reflection in the object. As a physical light shader is being used, and the color value is so high, it is best to turn this value off as reflection can be too bright. The solution to reflecting a light source is to create a stand-in object for the area light.

The Light's Photon Emission

Global Illumination uses Photons emitted from the light source. These Photons will hit any objects in its path and continue to bounce throughout a scene until the maximum number of reflections is achieved.

Photon emission needs to be turned on for a light, revealing three main attributes: Photon Color, Photon Intensity, and Exponent. Photon Color simply controls the color of the Photons emitted. Photon Intensity controls the amount of light distributed by the light source . Increasing or decreasing the intensity controls the brightness of the scene. Exponent refers to the intensity fall off of the photons. Using a Light Shader will inherently give the photons a falloff. The default value of 2 is physically accurate and indicates a natural inverse-square falloff. Lower values mean less falloff, and photons retain more energy over longer distances making renders appear brighter. Higher values increase the falloff and photons loose energy faster over distance - making renders appear darker. Exponent can be used when physical accuracy isn't a main concern and can be used to quickly brighten or darken a scene.

Lighting Set-Up

There are three main areas to cover when setting up the lights: applying a Physical Light Shader, converting the point light to a Mental Ray Area Light, and turning on Emit Photons.

The Decay Rate of the Point Light Attributes could be set to Quadratic to achieve a similar effect to a Physical Light Shader. However, as DGS materials are being used, a more accurate result will be achieved using this shader. To attach a physical light node, select the light and scroll down to the Mental Ray section, Custom Shaders section. Click on the add texture button next to the Light Shader field. A Create Render Node window will appear. Scroll down to the Lights section and select the Physical_light node. The Attribute Editor will switch to display the Physical_light settings. The default values are used.

To convert the Point Light into an Area Light, select the light again, and scroll down to the Area Light section in the Mental Ray section and turn on Area Light. The default Rectangle Type and Sampling is used. Low Level is initially set to 3 to speed up rendering of shadows.

To enable Photon Emission, turn of Emit Photons in the Light's Caustics and Global Illumination section of the Mental Ray section. As this is a white light, the default color is used.

Lastly, turn on Ray Trace Shadows and ensure that both lights in the scene are set-up with the same settings.

Render Set-Up

Finally, to create the Global Illumination solution, the Mental Ray render is selected in the Render Global Settings. In the 'mental ray' tab, the Quality Preset is set to Draft and Global Illumination is turn on in the Caustics and Global Illumination section. Initial test renders are created at the smaller 320 x 240 resolution.

Fine-tuning the Global Illumination

The initial render from this set-up is too bright. One solution would be to move the lights back - just as moving real lights further away reduces their intensity. Another, perhaps less realistic solution, would be to increase the Exponent value of the light's photons.

Instead, to reduce the brightness in this example, the Photon Intensity of each of the lights is reduced to 2000.

Photon Visualization

Being able to see the effect of the photons will better enable their control. There are two ways to see how the photons are reacting to the scene. The first is to set the Global Illum Accuracy in the Render Global Settings to 1, producing the following render.

The other way is to preview the photons as dots in the view-port. To do this, in the Render Global Settings, turn on Enable Map Vizualizer, under the Photon Map File field. Render the scene again and a photon map is written to disk and the view-port is scattered with a star-field of white dots. Unlike standard shaders, the effects of Mental Ray materials can't be seen in the view-port and instead objects are colored green. However, when photon visualization is tuned on, the white dots on the green actually help.

It can be seen from the last render that the photon splats are quite large and not covering whole areas. To produce a cleaner render Global Illum Photons of each light are increased. The Global Illum Photons is the number of photons needed to hit an object and be reflected. It represents the number of photons stored in the photon map. The higher the number used the longer the render times - therefore a balance is needed between quality and time.

Here, 100,000 photons have been used, at an accuracy of 1. More photons have produced better results but have increased render times. 50,000 photons could also be used if render time is too slow.

At this point we can now start to mix the intensity of the photons together by increasing the Global Illum Accuracy.

Here the Global Illum Accuracy has been boosted up to 400. The results are now much smoother. As values above 100 are used, the difference in quality begins to be more subtle and render times increase.

When the Global Illum Radius is left at 0, a value is automatically set based on the largest object in the scene. It is used to set the maximum distance at which photons are considered. Adjusting this value can reduce noise by blurring the photons. In this particular case increase the Radius above 1 had no visible effect, and the default automatic value was used.

Final Gather

Final gathering is a less accurate means of calculating indirect illumination, but can be used to improve the quality of global illumination. Global illumination is more affective on shiny and transparent materials requiring accurate ray tracing of light. However, it is not as affective on matte materials. Final Gather can be used to improve lighting and shading effects on more diffuse surfaces by eliminating photon map artifacts.

Final Gather is turned on in the Render Global Settings, under the Final Gather section. The default number of Final Gather Rays is 1000 per sample point. This controls the number of rays shot and can be too high for test renders. The Final Gather Rays value is set 100 for the first test render. Also, with final gathering, fewer Global Illum Photons are need and lower Global Illum Accuracy will still produce sufficient results. For each of the lights, the Global Illum Photons was reduced to 50,000 and the Global Illum Accuracy reduced to 100. This speeds up render time, without affecting results.

Introducing final gather has in fact darkened the image. The wall is now a source of ray-emitting light and its brightness is determined by the tone of the material. The wall and reflector board where both initially set to a diffuse value of 0.8. Increasing their diffuse values for both dgs material and dgs photon material produces the following brighter image.

This image has the backdrop material set to 0.9 and the reflector board set to 1.0. The Final Gather Accuracy has also been increased to 200. Note how Final Gather now casts a clearer shadow for the ball.

The Min/Max Radius controls the size of the sampling region used by final gather rays. The default value 0 produces an approximation based on the largest object in the scene. The values will vary based on the sizes of geometry in the scene. A guideline is to set the Max Radius to 10% of the scene's overall dimension, and then set the Min Radius to 10% of the Max Radius. By setting Export Verbosity to Info Messages in the Translation section, it is possible to record the scene diameter in the Output Window. In this example it's about 90 units.

Here the Max Radius has been set to 9 and the Min Radius to 0.9. The results are a little smoother than the last render.
The Filter option controls speckle elimination and prevents samples with extreme brightness from incorrectly illuminating the scene.

Increasing this value to 2 has eliminated some of the brightness from the hotspot in the background.
And so that's using DGS Materials with Global Illumination and Final Gather.

Information for this article has come from the following sources:

- A DGS tutorial posted on Highend3d.

- The Diffuse, Glossy and Specular diagrams where recreated from Jeremy Birn's book 'Digital Lighting & Rendering'. A must have book for anyone serious about 3d graphics. It is available from Amazon.

- Many of the individual attribute explanations were aided by the Maya Help manual.

- Maya version 6 was used for all renders and the files are available for download.

- 01_set-up.mb
- 02_mat.mb
- 03_tweeking.mb
- 04_tweeking.mb
- 05_final.mb

The final render has been produced with a few creative touches. One of the negative fill boards was rotated to directly illuminate the sphere. The sphere's Saturation value of its Specular component was set to 1.0, with Hue set to primary red. The camera was moved in a little cloaser and the backdrop Value reduced to 0.85. Production quality settings were used and the area lights sampling increased to 5 x 5.

So, are DGS materials better than standard materials? Yes, once you get the hang of them. The main practical advantage is that DGS photon materials are a must when using Global Illumination as they render must faster. Personally, I find the idea of describing a material in terms of its relative roughness or smoothness to be much more intuitive.

Have fun experimenting with this great new technology.

Enter content...

Fetching comments...

Post a comment