Tutorial: transparency
By olivS, dimanche 26 décembre 2004 à 20:15 :: Blender tutorials :: #7 :: rss :: PDF
Transparency and light refraction within a transparent material are key parameters in order to get a realistic rendering of a material like solid glass. This tutorial doesn't help with getting caustic spots, which is beyond the reach of the actual version of Blender without using an external renderer like Yafray.

For Blender: 2.48a - French version available 
Fichier(s) attaché(s) :
Preliminaries
As well as anything related to raytracing with Blender, because of the supplementary calculus time required by your computer, raytracing is only an option that you should feel free to activate and deactivate. This is done by the mean of the Scene menu (F10 key). The Render tab shows a button labeled Ray you will have to activate in order to use raytracing in your pictures.

Setting transparency
In the Shading menu (F5 key), you can define the color of your object within the Material tab thanks to four components; three of these components are for color (R, G, B resp. stand for Red, Green and Blue), and the last one is a component of transparency (A stands for Alpha). As with the color components, the transparency is set through the use of a slider, its value going from 0.000 (object totally invisible) to 1.000 (object totally visible). In other words, with an Alpha value of 0.250, at the point of observation, the object will have a mix of 75% ((1-Alpha) x 100 %) of the color of the background, and 25% (Alpha x 100 %) only of its own color.

Such a render will give you a ghostly material, which will be not enough if you want to achieve the same kind of results as a transparent material, like glass, that has a thickness and a density. In this case, it's the color of the background (defined in the World buttons menu) that is mixed with the color of the object, and not the colors of the other objects located behind the transparent object. The following picture clearly shows a better kind of transparency, more suitable, and in order to get it, you have to activate the ZTransp button in the Links and Pipeline panel.

The render is still somehow wrong. When you look through a glass, a bottle, an ashtray, or any fancy glass object, you will see that the picture seeb through it is deformed by the thickness and the curves of the object. This phenomenon is called refraction. Of course, there is no refraction in the previous picture, and this is what breaks the realism of the render.
In order to correct this, go into the Mirror Transp tab and activate the Ray Transp button. As for the ZTransp button, the glass object will show the objects placed behind it, and not anymore the background set in the World buttons. Then increase the value of the IOR slider beyond 1.000 in order to witness the refraction phenomenon. Jump to Light refraction, here after, for more information on this.

You will notice that the ZTransp and Ray Transp buttons are mutually exclusive. The first depends on scanline calculations, while the second depends on raytracing calculations. The second is the most physically accurate method, the first one being just an approximation, faster to compute, though! Obviously, nothing prevent you from mixing the two methods within a single scene, in order to optimize calculation times where realism would not be spot, from the actual point of view of the scene.
Depth:
This button lets you set the "depth" of the transparency, that is, the number of transparent surfaces "hidden" behind each other, and that will be effectively rendered as transparent materials. The transparent materials in excess of this treshold will be rendered plain and solid, according to their base shader.
Fresnel, Fac:
By default, the material is rendered with a transparency level even on all its surface. By increasing the Fresnel value, you can artificially make the material more plain and solid on the outer edges, and using the Fac button, you can intensify the Fresnel effect.
Hints to know about
Even if you know have a fair basic knowledge of transparency, you will most probably come to some more questions about its usage, and you will find the proper answers here after.
Light refraction
You certainly have been surprised when looking through a drinking glass (or any other glass object, with curved surfaces) and when you saw a distortion of the objects located in the background of it. In fact, with transparent objects, like glass, the path of the light is no more linear, but is deviated according to the curvature of the object and its density. This phenomenon is called light refraction. You can simply reproduce it by activating, in the Mirror Transp tab, the Ray Transp button and by giving to the IOR slider (Index of Refraction) a value greater than 1.00 (1.50 in our example picture).

Of course, choosing the good value for the Index of Refraction is not easy, but you are not condamned to rely only on your artistic choice. There are many documents containing whole lists of materials with their associated IOR, based on the density of the material. Here's a short abstract from them, with some common values.
* Air 1.0002926
* Alcohol 1.329
* Amber 1.546
* Amethyst 1.544
* Diamond 2.417
* Emerald 1.576
* Glass 1.51714
* Oxygen (gas) 1.000276
* Oxygen (liq) 1.221
* Plastic 1.460
* Plexiglas 1.50
* Quartz 1.544
* Topaz 1.620
* Turquoise 1.610
* Water (gas) 1.000261
* Water 100'C 1.31819
* Water 20'C 1.33335
* Water 35'C (Room temp) 1.33157
Shadows of transparent objects
Now we delete the texture of the ground and give the lamp a different orientation, in order to be able to see shadows in the foreground. We notice that all the objects, cube, spheres, glasses, have solid shadows, while if we carefully look at the shadow of a real glass on a table, we will see that it should be lighter.

Blender can easily take into account the transparency of the material in order to provide more or less solid shadows (and even provide the shadow a hue depending of the color of the glass). For this, you have to adjust the shader of the object receiving the shadow, and not the shader of the object emitting the shadow: this is the only tricky step of this tutorial. In order to conclude on this topic, let's select the ground of the scene, and go to the Shading menu (F5 key), in the Shaders tab. Activate the TraShadow button and notive that now there are differences between the shadows of the various objects.

Blurry refractions
The very same way blurry reflections has been implemented, you can settle blurry refrections for transparent objects. For example, in the following picture, the Gloss value has been set at 0.850.

This property is very interesting for the simulation of depolished, frosted or smoked glasses, with the proper shaders.
The other properties (Samples and Thresh) work the same as for the Blurred reflections tutorial.
Colored glass
A lot of the glass objects in our surroundings are colored. This is the case for vases, bottles or any fancy glass objects. Try to give to the material a classic "bottle green" color:

The result is not satisfactory, because the hue is very feint, while the colors of the background are dominant. In order to achieve the illusion of colored glass, you will have to use the Filter parameter. The values close to 1.000 makes the base color of the material to be dominant, while the values close to 0.000 makes the background colors to be dominant.
Article written on December the 26th, 2004.
Updated on November the 23rd, 2008 for Blender 2.48a. Comments re-initialized
















Comments
1. On mardi 13 janvier 2009 à 18:32, by vliqmabm
2. On lundi 9 février 2009 à 12:10, by Katie - Software Recovery Reviewer
3. On dimanche 29 mars 2009 à 20:41, by Forest
Add a comment