Solid and Hollow Glass

Glass and tranparent materials in general are tricky thing because they exhibits refraction, that is, the bending of light rays due to the different optical density of the various materials.

To fully take into account refraction a Ray Tracer is mandatory. We can nevertheless produce convincing resuls in Blender.

We will use EnvMaps and advanced Texturing techniqus to achieve this.

Let's consider a scene with some basic geometries, a cube, a cone, a sphere and a torus. We will make the sphere look like a solid ball of glass or either a glass bubble. We need to create the appearance that light is bending as it passes through. We expect to see the objects behind the solid glass sphere heavily warped, as if through a very thick lens, while for the hollow glass the sphere centre should be almost transparent while the sides should deflect light.

Solid Glass

Set up an environment map for the sphere's material the same way we did for the ball in the previous section, with an empty to locate the EnvMap's perspective at the centre of the sphere.

To fake Refraction we make some changes to the output mapping with the ofsZ, sizeX, sizeY, sizeZ and Col sliders to warp the map in a way that looks like refraction. Use the settings in Figure 57.

Figure 57. Envmap settings to fake refraction.

Select the Mir RGB material sliders and lower the R and G a bit to give a blue tint to the texture. Experience with the idiosyncrasies of Blender's handling of mirror colors dictates this unintuitive approach when combining environment-mapped reflections and refractions in a single material. Turn the Ref slider all the way down. (Figure 58).

Figure 58. Material settings

You now have a blue-tinted refraction of the environment. Shiny glass also needs a reflection map, so place the same texture into another texture channel. Press the Add, Col, and Emit buttons, and use the Refl button for the coordinates. Make the material Color black and turn Emit all the way up. (Figure 59).

Figure 59. Reflection Map

This will change a lot our first texture. In order to get the refraction texture back to a nice blue tint again, we have to add a new texture, leaving the texture type set to None. Select the Mix and Cmir buttons, and set the Col slider about halfway up. Click the Neg button and set the texture input RGB sliders to a dark blue (Figure 60).

Figure 60. Final touches

The final result should look like Figure 61. The refraction effect is most noticeable when the scene is animated!

Figure 61. Rendering

Hollow Glass

That's fine for a solid lump of glass, but how do we go about making hollow-looking glass such as you might need for making a vase? Thin glass has strong refraction only where it slopes away from the eye at a steep angle. We can easily mimic this effect by using Blender's Blend texture to control the object's transparency, plus another transparency texture to keep the bright highlights visible.

Add a new texture to the material. Select Blend as the type and select the green Sphere option. Go back to the material buttons, select Nor as the mapping type, and disable the X and Y axes in the input coordinates. Mix the texture with Alpha. Move the Alpha material slider to 0.0 and set the blue ZTransp option (Figure 62).

Figure 62. Setting transparency.

This gives nice transparency as the surface angles toward the eye, but we want the bright environment-mapped reflections to show up on those otherwise-transparent areas. If you look at glass windows, you will see that bright light reflecting from the surface will be visible and prevent you from seeing through a pane that is ordinarily transparent. We can do this easily by selecting the environment-mapped reflection texture in the material window and enabling the Alpha option (Figure 63).

Figure 63. Setting Reflections

That's all there is to it. The result should look like Figure 64.

Figure 64. Hollow Glass