Final Gathering: Effect is Darker in XSI 5.0


Table of contents

Introduction

Final gathering is a way of calculating indirect illumination by casting rays from each illuminated point on an object’s surface. The rays are used to sample a hemisphere of a specified radius above each point and calculate direct and indirect illumination based on what the rays hit.

A popular use of final gathering is lighting a scene using bright constant-shaded (or textured) objects to “bounce” light into the scene, rather than using any active lights. For example, you can use a bright-blue “reflector” to simulate indirect illumination from the sky (XSI's environment shader achieves the same effect by surrounding the scene with a virtual textured sphere). Final Gathering is also used to complement a scene's direct and indirect lighting.

If you're using XSI version 5.0 or later, you may have noticed that the final gathering effect renders darker than it did in previous versions of XSI. The purpose of this article is to explain how final gathering has changed in XSI 5.0, and how to modify your scenes to recreate a pre-5.0 final gathering effect.

So Why Does Final Gathering Render Darker in XSI 5.0?

Prior to XSI 5.0, final gathering was using more than three times each material's actual radiance. This often resulted in overly bright or "washed out" looking final gathering renders.

In XSI 5.0, final gathering uses each material's actual radiance value, as specified by the material's surface (illumination) shaders. The result is darker, but more accurate final gathering renders. This is especially apparent in scenes where final gathering is the main, or the only form of lighting.

The examples below show the same two scenes rendered in XSI versions 4.2 and 5.0:


This scene was created and rendered in XSI 4.2. Final gathering provides the only lighting.
Enlarge
This scene was created and rendered in XSI 4.2. Final gathering provides the only lighting.
When rendered in XSI 5.0, the same scene is noticeably darker.
Enlarge
When rendered in XSI 5.0, the same scene is noticeably darker.
This scene was created and rendered in XSI 4.2. Final gathering (used for image-based lighting) is combined with a spotlight.
Enlarge
This scene was created and rendered in XSI 4.2. Final gathering (used for image-based lighting) is combined with a spotlight.
Again, when rendered in XSI 5.0, the same scene is noticeably darker, though less so because of the spotlight.
Enlarge
Again, when rendered in XSI 5.0, the same scene is noticeably darker, though less so because of the spotlight.


As you can see, the XSI 5.0 renders are much darker, which can be problematic when you're importing an older scene into 5.0, but you want it to look the the way it did when you created it in a previous version. Described below are two ways to brighten final gathering, both can be used to make old final gathering scenes look the way they did when you rendered them in previous versions of XSI.

Changing Surface Shader Radiance Values

To achieve the pre-5.0 behavior for radiance calculations, each Radiance color value for each surface shader in the scene needs to be multiplied by Pi (approximately 3.142). You can do this manually, or using scripting.

As you can see in the examples below, multiplying Radinace values by Pi yields very similar, if not quite identical renders to XSI 4.2.

Note: Differences between the 5.0 and 4.2. renders are mainly due to changes made to the mental ray renderer's final gathering algorithm. For the same final gathering settings (Accuracy, Radius, etc...) slightly smoother results are produced in XSI 5.0.


This XSI v.4.2 scene is too dark when rendered in version 5.0.
Enlarge
This XSI v.4.2 scene is too dark when rendered in version 5.0.
Multiplying the Radiance values of all surface shaders in the scene by Pi brightens the scene so it looks like it did when rendered in v.4.2.
Enlarge
Multiplying the Radiance values of all surface shaders in the scene by Pi brightens the scene so it looks like it did when rendered in v.4.2.
Compare the brightened 5.0 rendering to this original rendering from 4.2.
Enlarge
Compare the brightened 5.0 rendering to this original rendering from 4.2.
Again, the scene rendered in 5.0 is too dark.
Enlarge
Again, the scene rendered in 5.0 is too dark.
Here is the same scene rendered in 5.0 with the surface shaders' Radiance values multiplied by Pi.
Enlarge
Here is the same scene rendered in 5.0 with the surface shaders' Radiance values multiplied by Pi.
Compare the brightened 5.0 rendering to this original rendering from 4.2.
Enlarge
Compare the brightened 5.0 rendering to this original rendering from 4.2.

Changing Radiance Values Manually

Radiance values are usually located on the Indirect Illumination tab of a surface shader's property editor.
Enlarge
Radiance values are usually located on the Indirect Illumination tab of a surface shader's property editor.

  1. Open the property editor for the surface shader whose Radiance values you want to change.
  2. On the Indirect Illumination tab (or the main tab of any of the "simple" illumination shaders - Simple Phong, etc...), set each Radiance color value to 3.142 (or thereabouts) times its current value.
    You can either enter the new values directly or enter expressions to perform the multiplication automatically. For example, if the Radiance values are all set to 0.476 you can simply type 0.476*3.142 for each color value.
  3. Repeat steps 1 and 2 for every surface shader in the scene.

Changing Radiance Values Using a Script

In complex scenes with large material libraries, modifying all of the surface shaders manually is tedious at best. It's usually more efficient to write a script that multiplies the radiance values in all surface shaders. The script below is an example of the type of script you might use. Note that this is a basic example that does not account for cases where a surface shader's Radiance port is connected to another shader, or controlled using a material override.

Tip: For extra credit, you might try writing a script that, where necessary, inserts a Color Math Basic shader to perform the necessary multiplication-by-Pi on branches of the render tree connected to any surface shader's Radiance port.

// Get the material libraries
var oMatLibs = Application.ActiveProject.ActiveScene.MaterialLibraries;

// For each material in each material library, 
// process the shader tree attached to the surface 
// port of the material 
oEnum = new Enumerator( oMatLibs ) ; for (;!oEnum.atEnd();oEnum.moveNext() ) {
	var oMatLib = oEnum.item() ;
	oMatEnum = new Enumerator( oMatLib.Items  ) ;
	for (;!oMatEnum.atEnd();oMatEnum.moveNext() )
	{
		var oMat = oMatEnum.item();
		var oShader = oMat.Parameters.Item("Surface").Source;
		traverseShaderTree( oShader, adjustRadiance );
	}
}

// Traverses the shader tree starting at oRoot, and calls 
// the function fnCallback on each shader in the tree 
function traverseShaderTree( oRoot, fnCallback ) {
	if ( oRoot == null ) return;
	
 	fnCallback( oRoot ); 

	var oShaders = oRoot.Shaders;
	for (var i=0; i<oShaders.Count; i++)
	{
		var oShader = oShaders.Item(i) ;
		traverseShaderTree( oShader, fnCallback );
	}
} 

// Callback function that multiplies the radiance by PI 
function adjustRadiance( oShader ) {
	var PI = 3.14159;
	var oRadiance = oShader.Parameters.Item("radiance");
	if ( oRadiance != null )
	{
		LogMessage( "Adjusting radiance on " + oShader.FullName );
		var oRadianceParams = oShader.Parameters.Item("radiance").Parameters;
		oRadianceParams.Item("red").Value *= PI;
		oRadianceParams.Item("green").Value *= PI;
		oRadianceParams.Item("blue").Value *= PI;
	}
}

Using the Final Gathering Multiplier

An alternative way of brightening the effect of final gathering is to use the Multiplier option on the Final Gathering tab of the Render Options property editor. As you might have guessed, the multiplier multiplies final gathering's color contribution to the scene. The overall effect is to brighten the rendered image, particularly where final gathering causes objects to “bleed” their colors onto one another.

The examples below show the effect of using the multiplier, rather than material radiance, to brighten the final gathering effect.


Sample scene rendered in XSI 5.0.
Enlarge
Sample scene rendered in XSI 5.0.
Final gathering Multiplier values set to 3.35.
Enlarge
Final gathering Multiplier values set to 3.35.
Sample scene rendered in XSI 5.0.
Enlarge
Sample scene rendered in XSI 5.0.
Final gathering Multiplier values set to 3.35.
Enlarge
Final gathering Multiplier values set to 3.35.


The Mutiplier setting is located on the Final Gathering tab of the Render Options property editor
Enlarge
The Mutiplier setting is located on the Final Gathering tab of the Render Options property editor
To set the final gathering multiplier:
  1. From the Render toolbar, choose Render > Render > Options to open the Render Options property editor or Render > Region > Options to open the View Render Options (Render Region) property editor.
  2. On the Final Gathering tab, adjust the Multiplier color values. To increase brightness uniformly, set all colors to the same value.
    For example, if you want to double the default brightness of the final gathering effect, which is 1.0, set all of the color values to 2.0.


Note: if you are using multiple final gathering bounces, it's important to remember that the Multiplier affects only the first bounce.

This page was last modified 04:32, 2 Oct 2010.
This page has been accessed 17209 times.

© Copyright 2009 Autodesk Inc. All Rights Reserved. Privacy Policy | Legal Notices and Trademarks | Report Piracy