Go back to the main page

Reasonably enough, in this tutorial I'm going to cover transparency in POV-Ray. There's not a whole lot to do here, so let's get started.

We have two kinds of transparency available to us. Both are specified in the pigment definition. The two are rgbt and rgbf. Both are four-dimensional vectors where the last value controls how transparent the object is. Let's look at two examples.

cylinder
{
-2*x, 2*x, 1
pigment {color rgb .3}
}

sphere
{
0, 1.5
pigment {color rgbt < .4, .4, 1, .5>}
}
RGBT example
cylinder
{
-2*x, 2*x, 1
pigment {color rgb .3}
}

sphere
{
0, 1.5
pigment {color rgbf < .4, .4, 1, 1>}
}
RGBF example

The RGBT method of making an object transparent allows light to go through the transparent object without being altered by it. Using a value of .5 for the transparency means that half of the light that strikes the sphere will make it through to the cylinder. A value of 1 would make the sphere invisible, while a value of 0 would make it solid. The RGBF method, on the other hand, alters any light that passes through the object in question, giving the light the color of that object. Since I made the transparency value 1 on the sphere, no light bounced off of it. Instead all of the light passed through and was turned blue. Generally RGBF is the more realistic of the two transparency techniques.

One problem with transparent objects becomes obvious when we try to use CSG on them. Let's take a look.

union
{
box
{
-1, 1
rotate 45
translate .6*x
pigment {color rgbf < 0, 1, 0, .5>}
}
box
{
-1, 1
rotate 45
translate -.6*x
pigment {color rgbf < 0, 0, 1, .5>}
}
}
Union problem

Notice that you can see the original cubes still inside of the unioned space. Ideally we'd get a single transparent object, not something like this. We can fix this problem by using the merge CSG. Merge works exactly like union save that all interior surfaces are removed. Thus we don't get the problem shown above. Instead we get this:

Merge

There's that problem nicely fixed. And that's it for transparencies.


Go back to the main page

All items on this site are copyright 2002 Chris Weisiger (a.k.a. Derakon). That's right - I made everything on this site. Reproduction of any of my work i\ n whole or in part requires my express consent.