Site hosted by Angelfire.com: Build your free website today!

Index > Main menu > Tutorials

Fading Reflections
Page 1 2 3

By Bernard Lebel

 

This tutorial presents a technique that allows you to create a falloff in reflection, or fading reflections. A fading reflection is when surrounding becomes less visible in the reflecting surface because of their distance. The more distant the reflected object is, the less likely he will show in the reflection of a reflective object.

This raytracing property is present in many 3D packages, but not in XSI. Some might think that with a scalar_state node you can do it, but no, because the scalar_state node only evaluates primary rays. As you know, reflections are actually secondary rays. So the only way to do it is via custom passes and overrides, if like me you don't know how to write mental ray shaders.

This tutorial is intended for Softimage|XSI 2.0 and above. Here is a database where you will find the the start and end scenes.
Click here to download
I did the tutorial with XSI version 2.02. If you have XSI 2.0 or 2.01, there is a model (Model.emdl) in the Model folder of the project folder that you can import in a new scene to have the starting scene.

Credits:
Initial design: Guy Rabiller
Redaction and refinements: Bernard Lebel
Additional refinements: Patrick Perreault


PAGE ONE - Initial setup - The first pass


1- Initial setup

Let's begin by loading the FalloffReflection_start scene. The cube and cylinders are reflective objects. The gound has a checkerboard texture on it, so we will be able to clearly see the effect of the technique.

When you use this technique, it is important that all the objects have a material on them. Since we will override material properties, we can't access them if the objects use the default Scene_Root material. For the sake of learning the technique, we won't play here with groups and layers, to avoid potential headaches.

Turn one viewport into an Explorer, and switch to passes.

You can see that we only have the default pass, wich we won't use at all. We will delete it later.


2- The first pass

Create a new empty pass.
To create the pass, do Render > Pass > New Pass > Empty.

 

Name this pass Reflection_Pass.

You can close the property page.

This pass will render the reflections only, without alteration. You can even start with a reflection pass, but here I show you how to create one from scratch.

Creating the additional partition
In the Explorer, select the Reflection_Pass item. Now we will create a new partition. So do Render > Pass > Partition > New.

 

Name this partition Partition_Reflective, and close the property page. It is this partition that will receive the reflective properties. Objects in other partitions won't render at all.

 

Info:
The utility of a pass is that it allows you to isolate specific properties that will be rendered alone, without the interference of other properties. For example, you can use a specular pass to render only specular info in the scene, to later composite it on the other passes with a compositing software. The partition is the system that allows you to define those properties that you want and those you don't want. If we take the same example, all the objects that we want their specular info to be rendered will be placed into a partition that allows specular to be rendered, but nothing else, and the other objects will be placed into a partition that doesn't allow any rendering.

Adding the first override entry
In the Explorer, expand the Background_Objects_Partition (wich is the default partition). Select cube and cylinder, drag & drop them into the Partition_Reflective partition.
Still in the Explorer, select the Background_Objects_Partition item, and do Property > Override.

 

Name this override Override01.

 

This override will allow us to block some properties associated with light the surface shaders, namely the Specular and the Primary Rays.

Click on Add Parameters, expand one object node (can be anyone, but in this tutorial it can only be the grid), then expand the Material node, then the Surface node, then the Phong node. Finally, select the specular_inuse node and click anywhere else in the GUI to validate the entry.

 

You should have something like this in the override property page:

This is not correct. The problem is that there is a bug in XSI 2.x. The command that creates the entry has missing characters, and you must enter them manually. It's not a big deal when you know how.

Correcting the override bug
Open the Script Editor (little parch icon at bottom left of the interface).

Select the last line of the History Log, and drag it into the Script Editor field. That line starts with SIAddEntryToOverride....

Then, at the end of the line, add , 2, as show below:

 

Now, select the override item in the Explorer, and delete it.

Again, select Background_Objects_Partition, do Property > Override, and name it Override01. We had to delete the override because you can't delete individual entries.

Then click on Run in the Script Editor. This will do exactly the same thing as when we did the Add Parameters, except that now the command will be properly executed because of our little modification. As a result, you should have something like this in the override property page:

You can see now that there the entry is quite different, and allows us to enable or disable the specular information for that partition. Leave it checked.

Adding the second entry
Click on Add Parameters. This time, browse to Grid > Visibility, and select Primary Rays.

This time we don't have to copy the log command to the script editor and modify it, because the aforementioned bug doesn't affect this parameter.
Uncheck primray. The result wil be that no object in the field of view will be visible. Close the override property page

 

Setting up the custom partition
Next, select the Partition_Reflective partition.

Now we will create the actual reflective property. Do Property > Override. Name the override Override02.

Adding the two first entries
Click on Add Parameters, and scroll down to AnyObject > Material > Surface > SurfaceShader > diffuse_inuse. Do the same thing but with specular_inuse.

 

You can see in the override property page that we now have 2 bugged entries! Don't worry, we will fix this immediately.

 

Correcting the override bug
Open the Script Editor. Drag the 2 last lines of the History Log (those starting with SIAddEntry...) and drop them onto the Script Editor field.

Again, add at the end of those lines the , 2 characters.

Delete the override, and recreate it with the same name.
Run the script. You should have this:

Uncheck both entries.

If you preview the scene, you should have this:

 

So we are done with the first pass. There are two more, but don't worry, they don't require as much setup as the one we did.

 

Next: The second pass, the third pass and rendering.