From BlenderWiki
Raytraced Transparency
Mode: All Modes
Panel: Shading/Material Context → Mirror Transp
Hotkey: F5
Description
Raytracing is also used for simulating the refraction of light rays through a transparent material, like a lens. A ray is sent from the camera and travels through the scene until it encounters an object. If the first object hit by the ray is non-transparent, then the ray takes the color of the object. If the object is transparent, then the ray continues its travel through it to the next object, and so on, until a non-transparent object is finally encountered which gives the whole chain of rays its color. Eventually, the first transparent object inherits the colors of its background, proportionally to its Alpha value (and the Alpha value of each transparent Material hit in-between). But while the ray travels through the transparent object, it can be deflected from its course according to the Index of Refraction (IOR) of the material. When you actually look through a plain sphere of glass, you will notice that the background is upside-down and distorted: this is all because of the Index of Refraction of glass.
Enable Raytracing
You need to enable raytracing in your scene settings if you want to use raytraced transparency and refraction. This is done in the Scene/Render context → Render Panel. Raytracing is enabled by default in Blender 2.37 and higher. |
Alpha value
You need to set your Alpha value (A in the Material Pannel) at something else than 1.000. However, the alpha value will still be reported in the render as 1.0 |
Options
- RayTransp
- Enables and disables raytraced transparency
- Filt
- Amount of filtering for transparent ray trace. The higher this value, the more the base color of the material will show. The material will still be transparent but it will start to take on the color of the material.
- IOR
- Sets how much a ray travelling through the Material will be refracted, hence producing a distorted image of its background. See Examples.
- Depth
- Sets the maximum number of transparent surfaces a single ray can travel through. There is no typical value. Transparent objects outside the Depth range will be rendered pitch black if viewed through the transparent object that the Depth is set for. In other words: if you notice black areas on the surface of a transparent object, the solution is probably to increase its Depth value (this is a common issue with raytracing transparent objects).
- Limit
- materials thicker than this are not transparent. This is used to control the threshold after which the filter color starts to come into play.
- Falloff
- how fast light is absorbed as is passes through the material. Gives 'depth' and 'thickness' to glass.
- Fresnel
- Sets the power of the Fresnel effect. The Fresnel effect controls how transparent the Material is, depending on the angle between the surface normal and the viewing direction. Typically, the larger the angle, the more opaque a Material becomes (this generally occurs on the outline of the object).
- Fac
- A controlling 'factor' to adjust how the blending (between transparent and non-transparent areas) happens.
- SpecTra
- This slider controls the Alpha/falloff for Specular colors
Examples
Index of Refraction
(Influence of the IOR of an Object on the distortion of the background: spheres of Water, Glass and Diamond (top to bottom).). There are different values for typical materials: Air is 1.000 (no refraction), Alcohol is 1.329, Glass is 1.517, Plastic is 1.460, Water is 1.333 and Diamond is 2.417.
Glass
Realistic Glass is not perfectly transparent, and so light can reflect off of it, it can bend light, and you can even sometimes see shadows cast on the glass, since in reality the non-shadowed surface of the glass is reflecting some light back at you.
In the Render panel, enable Raytracing and Shadows. In the example render shown, we have a lamp just off camera to the right, a red-colored ball, an angled piece of glass covering the bottom of the picture, a teal-colored NURBS torus (donut), and a back wall, in Z order. You can see:
- Refracted wall, the donut, the environment behind the glass
- Shadows cast onto the glass by the red ball in front of the glass
- Shadows cast through the glass onto the donut by the red ball
- Shadow cast by the ball behind the glass into the box
- Refraction of the shadow of ball and torus coming back through the glass
- Specular glare on the glass from the lamp
In the Material settings, shown here for slightly blue green glass, enable Traceable and Shadbuff so that Raytraced as well as Shadow Buffer lamps will work with the glass.
In the Material panel, notice that the Alpha is not pure 0.0 In the Shaders panel, Shadow and TraShadow are enabled. The glass is colored by ambient light and emits its color, to simulate light bouncing around inside the glass itself and emerging
In the Mirror/Transp panel, default settings are used except for IOR.
Atmosphere/Cloud Cover
In this example, we need a cloud cover for a planet. This is used to texture a UV Sphere that is a larger diameter than the planet inside of it.
The Alpha of the base material is zero, as is any Ambient or Emit values.
Of course, we have to use the Cloud texture, and put it to two uses: to slightly affect the color of the mesh, and to affect the Alpha transparency. While the base material is white, the texture gives it a blue tinge. It receives shadows, so the shadow of the planet will actually darken the dark side of the atmosphere.
Where the texture is black, think 0 color. If you map that 0 to alpha, you get transparent, or see-through. Where the texture is white, think full, 1.0 color. If you map white to alpha, you get full opaqueness. If that 1.0 also maps to some color, like blue, you will get a fully opaque blue color. In the example to the right, that full blue is then mixed down by the Col slider in the texture Map To panel so that it mixes with the base white material and only shades the white a slight hue of blue.
To make the clouds more pronounced, you can map the input to a higher value, and/or multiply (not mix) two texture channels layers together.
Hints
In order to get a physically accurate Fresnel effect with the current algorithm, you have to set Fresnel to 5.0 and Fac to 1.25. Nevertheless, you can play with these values for the sake of artistic freedom, if you feel the need to.
Casting Transparent Shadows
By default, the shadows of transparent objects are rendered solid black, as if the object was not transparent at all. But in reality, the more transparent an object is, the lighter its shadow will be. This can be taken into account, not in the Mirror Transp panel transparent object settings.
Transparent shadows are set on the materials that receive the shadows from the transparent object. This is enabled and disabled with the TraShadow button, in the Shading/Material context → Shaders Panel. The shadow's brightness is dependent on the Alpha value of the shadow casting Material.
Ray versus Z Transparency
ZTransp, located in the Material Links panel, causes Blender to use the Z value, or distance from camera, to bleed things through. When using transparent planes with images, ray tracing will let the colors come through the transparent areas, but the Z values will not carry through. Therefore, later on down the rendering pipeline some issues may arise. For example, when OverSampling/Aliasing (OSA) is applied, artifacts may ensue as shown. In this example, raytracing is not providing the correct samples for the portion of the ground plane behind the transparent portions of the alpha-mapped tree image plane. To solve this, use ZTransp for the material, not raytracing.
As another alternative, change the texture interpolation filter size to 0.100 or some number smaller than 1.0. This slider is found in the Texture subcontext (F6 Map Image panel.
Raytracing affects the Color, but does not affect the Alpha channel value that is saved or passed on. Even if the Material is set to Alpha 0, raytracing will treat the material as transparent, but will return an alpha 1 for that channel regardless of the alpha setting inthe material.
ZTransp does affect Alpha channel values in the output. If you are going to be compositing the image later using Alpha over, you probably want to set ZTransp for your material. The disadvantage with ZTransp is that the light can not be bent or refracted.
To set the Alpha value of an object AND use raytracing, set the Pass Index the object (Object and Links panel). Render the image using Ray Transp and the Index pass (Render Layer panel). Then use the Index OB node to mask it out and the Set Alpha node to set the alpha for that portion of the image.
IOR values for Common Materials
The following list provides some Index Of Refraction values to use when RayTraced Transparency is used for varous liquids, solids (gems), and gases:
|
|
|
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|










![[]](/skins/blender/open.png)
