PREVIOUS < INTRODUCTION

EXAMPLE 1 - The glass with water

Unzip the scenes from the zip file and load the scene01a.mb. When you open it, you'll see that there are few simple objects in the scene... the wall, the floor, and glass with water in it. There are also few shaders. The ones we are interested in are the Water1 and Glass1. If you go to the attribute editor of the first shader you'll see that it is highly transparent and that diffuse value is set to 0. This is because the glass or the water does not produce diffuse reflection of the light rays. So, if you create glass be sure to set the diffuse to 0 and increase transparency values. If you open raytrace option section of the Water1 shader you'll see that it has refractive index of 1.33, and the Glass1 shader has refractiov value set to 1.5. These are the values these materials have in real world, so if you create the glass be sure to set the refraction to 1.5, since it's default value it 1. Same goes to the water shaders, just set the refraction to 1.33. If you want to create crystal or diamond shaders you will have to use higher refraction values ... just the refraction values table on the internet.

As you already know, we will use the mentalray renderer to render caustics. To use it go to the Render menu> Render Using > mental ray. Now open the render window from Window> Rendering Editors > Render View. You can also set the mentalray as your renderer from RenderView ... click in the Render View toolbar where it says Maya Software and select mentalray. If you do a simple test render of the scen you just loaded it will look like this:

Oh my god, what is this? You won't believe it but this is the glass with water in it, and it doesn't have raytracing turned on. How to do this? As usually, in Render View go to the Options > Render Global's (mental ray). When mentalrayGlobals window pop up, go to the Quality section and press the box on the right side of RenderQuality option. The mentalrayOptions1 will open. As you see the raytracing on the top is turned on. Try to render the scene again. This is what you'll get.

Why this? Because when the ray hit the glass, with these options ray is only refracted once and it needs to be refracted at least 6 times (glass, glass, water, water, glass, glass). That's why we must increase the refracted ray depth to get the desirable effect. To do this go to the mentalrayOptions1 and in Rendering section set the Max Refraction rays and Max Ray Depth to 6. Render again and you'll get this:

That looks nice. The next thing to do is to turn on the shadows on. So select the spotlight and go to it's attribute editor (Ctrl+A). Open the Shadows section. On the top of the Shadow section is the Depth Map Shadows section. We will not use this type of shadows since it is faked shadow and can not be used in situations where the transparent surface need to cast shadow on the other objects. That's why you must open the section below, the Raytrace Shadow Attributes, and turn on the Use Ray Trace Shadows option. Render again and this happens:

Ok, we have the refraction and shadow, now we need to get the caustic in the scene. To produce caustic effect, you must set the light as photon emitter and set the caustics on in mentalray rendering options. So select the light, go to the attribute editor (Ctrl+A) and go to the mentalray > caustics and global illumination section. Set on the Emit Photons option. The Energy and Exponent becomes available to adjust, but for now leave it as it is. We will use it later to increase od decrease the intensity of caustics. Now go to the RenderGlobals (mentalray) > mentalrayOptions1 > Caustics/Global Illumination and turn on Caustics option. If you render the scene at this moment you'll get caustics effect in your picture, similar to this one:

As you see, there are some caustics on the floor in the shadow area, but there is something wrong. What? If you look at the picture from beginning, from real situation, you'll see that we are missing the area pointed in the that pic. The problem in our renderer is similar to the one we met few moments ago when we turned on the refraction. Remember the ray depth? ;) To solve this, in the mentalrayOptions1 at the Caustics/Global Illumination section set the Max Refraction Photons and Max Photons Depth to 6. Render again:

Here it comes. :) But to intense. To decrease the intensity of it, go to the attribute section of the our spotlight, and go to the Caustics and Global Illumination section. If you remember, I mentioned before that we will use the Energy and Exponent value to decrease the intensity od caustics. We will make few pictures to show you what's happening when we change these two values:


Energy 500
Exponent 2


Energy 1500
Exponent 2

Energy 3000
Exponent 2

Energy 8000 (Default)
Exponent 2

Energy 8000
Exponent 2 (Default)

Energy 8000
Exponent 2.5

Energy 8000
Exponent 3

Energy 8000
Exponent 3.5

We can get similar effect when we increase the exponent or energy value. In my opinion the value somewhere between energy 1500 and 3000 will be the most appropriate. So set the Energy value to 2300 and leave exponent to it's default value (2) and do another test render.

The quality of the caustics are controlled by the few options in light attribute editor and in the mentalray render globals options. To set the number of caustic photons emitted from the light source, select the light and go to it's attribute editor. Then jump to mentalray > Caustic and Global Illumination section. Let's make a few examples with different kind of Caustic Photons:


Caustic Photons 3 000


Caustic Photons 10 000 (Default)

Caustic Photons 30 000

Caustic Photons 80 000

The first picture renders very fast but it doesn't have the quality that we want. The second one is much better that the first, and it can be used for the final render. The third and last one produced the best caustic effect but with increased render times. Let's make a little interpolation between the second and third picture, and set the photons to 20 000. This will be our final setup for this situation. There would be situations, like rendering the caustics from sea surface, when you'll need to increase the caustic photons to higher values to get desirable result.

There are still few options that we are interested in, when it comes to quality of caustics. You'll find it in RenderGlobals (mentalray) > mentalrayOptions1 > Caustics/Global Illumination section. With Caustic Radius you can control how big are the area that photons are collected from, and with Caustic Accuracy you can control how much photons are collected together when calculating caustics at point x of the scene. You will leave these two to their default values. Don't worry about 0 value at Caustic Radius option ... if it is set to 0, the renderer set the appropriate value of this option, and it does this very good in many situations. As for the other option, the accuracy, well you should probably leave it as it is, but if you increase the caustic photons to very high values you should also increase this option to higher value. Also, if you change the Caustic Filter Type from Box to Cone, it will produce a little bit sharper caustics effect.

So this is it... the end of our first session... let's get in to the sea :)

NEXT > EXAMPLE 2 and 3 - Sea and Reflective objects

 


Toni Bratincevic - toni@interstation3d.com - http://www.interstation3d.com