Transparent Objects and Blender
Transparent Objects and Blender
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 Yafaray or Luxrender.
1. 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 Render menu. The Shading panel shows an
option labeled Ray Tracing you will have to activate in order to use raytracing in your pictures.
2. Setting transparency
In the Material menu, you can define the base color of your object within the Diffuse panel tab
thanks to the color picker, just like usual. In the Transparency panel, you will find the Alpha
parameter whose value ranges from 0.000 (object totally invisible) through 1.000 (object totally
visible). Blender can use not less than three different methods to handle transparency:
Only the latest is considered modern and realistic, but the two others are cheaper, computation
timewise. The second method is a good compromise between results (at a given distance) and
computation times.
This is the most primitive type of transparency. Basically, it blends the Diffuse material color
with the World menu's World colors (textures included) according to the opacity Alpha value.
Unfortunately, depending of the World settings, such a render will give you a ghostly material,
which will be disappointing if you want to achieve some realistic results, unless you have no
blocking objects in the view behind the transparent surface (some outdoor scenes, for example).
Apart from setting any Alpha value in the Transparency panel, you don't have anything else to
do to enjoy this method. For example, with an opacity Alpha value of 0.250, the object will
have a mix of only 25% (Alpha x 100 %) of the Diffuse color, and 75% (the complementary
part: (1-Alpha) x 100 %) of the World color. Obviously, you can somehow cheat even in
closed environments by adding a texture to the World, which will reduce the ghostly effect.
2.2 Z-Depth based transparency
Unfortunately, most of time, there are blocking objects in the background and their colors DO
matter and have to be viewed throuh the front transparent object. Luckily, as a scanliner, Blender
virtually stores the distances of any surface point from the camera in a depth buffer called the Z-
buffer, so it is very easy for it to sort the surfaces from the point of view of the scene. Basically,
when deciding the color of a given pixel from the final rendered image, if it belongs to a
transparent surface, the scanliner will pick the color of the next surface immediately behind it in
the Z-buffer and mix it according to the opacity of each materials. For example, still with an
Alpha value of 0.250, the rendered pixel would have a color made from 75% of the color of the
object standing behind it and 25% of the Diffuse color of the transparent object.
With this method, the results are better looking, and easily take into account multiple transparent
surfaces. Unfortunately, the transparent surfaces seem to lack thickness and density of some sort,
as show in the following picture.
In order to benefit from this technique, in the Transparency panel, you have to make sure that
Transparency option is ticked on, and to activate the Z Transparency button.
2.3 Raytraced transparency
When you look through a glass, a bottle, an ashtray, or any fancy glass object, you will see that
the background environment is deformed by the thickness and the curves of the object. This
phenomenon is called refraction, and simulating it would add a lot of realism to the render. It
currently can only be done using raytracing: a ray in sent from the camera ; when it reaches a
transparent surface, instead of showing what is exactly behind it on the same trajectory, the ray
will be defelected by the curves of the transparent surface according to its density, then showing
a slightly different part of the environment.
In order to set this behavior, go back into the Transparency panel and activate the Raytrace
button. As for the Z Transparency test case, the glass object will show the objects standing
behind it, and not anymore the background set in the World menu. But in order to get the image
distorsion through the transparent surface, you have to set the density of the material.
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 noticeable
enough, from the actual point of view of the scene.
2.3.1 IOR
Setting the density is as simple as increasing the value of the IOR slider beyond 1.000 in order
to witness the refraction phenomenon. Jump to 3.1 Light refraction, hereafter, for more
information on this, but two values are very useful and should be known by any serious 3D
enthusiast: 1.52 for glass and 1.33 for water.
2.3.2 Depth
This button lets you set the "depth" of the transparency, that is, the number of transparent
surfaces stacked behind each other along the ray direction, and that will be effectively rendered
as transparent materials. The transparent materials in excess of this threshold will be rendered
plain and solid, according to their base shader.
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 Blend button, you can fine-tune the Fresnel effect. Behavior is quite
close to Fresnel effect applied to reflective materials.
3. 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 hereafter.
You certainly have been surprised when looking through a drinking glass (or any other glass
object, with curved surfaces) and when you saw for the first time 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 deflected according to the curvature of the object and its density. This
phenomenon is called light refraction. In Blender, you can simply reproduce it by activating the
Raytrace option in the Transparency panel, and then setting the IOR slider (Index of
Refraction) with a density value greater than 1.00.
Of course, choosing the good values for the Index of Refraction is not easy, but 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
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 can notice that all the objects (cube, spheres, glasses,
etc.) have solid shadows, while if we carefully look at the shadows of a real glass on a table, for
example, we will see that they should be lighter. Blender can easily take into account the
transparency of the material in order to cast more or less solid shadows (and even provide the
shadow a hue depending of the color of the transparent surface). 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 Material menu, in the Shadow panel. Then acitvate the
Receive Transparent tick option and notice how the shadows look different now.
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 Threshold) work the same as for the
blurred reflections tutorial.
From top left to bottom right, Filter values of 0.250, 0.500, 0.750 and 1.000