The POV-Ray Cyclopedia

I was cleaning out my POV Files folder, and came across this little trick I thought I'd share. I'm not sure what inspired this, but someone, somewhere wanted to know how to fade an object to transparency. It's not that hard to do and someone, somewhere figured it out. (I'm not going to take the credit for this because I didn't customize the header of the file, so I don't know if I came up with it or I pulled it from someone elses work.)

Part One
Using an image in the page

The average pigment function is all we need to do this. Lets declare some textures to play with:

#declare basetexture = texture {
   pigment {radial frequency 8} 
   finish{specular 1}}
   
#declare cleartexture = texture { pigment { rgbt 1 } }

#declare secondtexture = texture { 
   pigment { granite } 
   normal { granite } }

Image one shows a simple sphere with basetexture applied, Image two shows the same simple sphere with secondtexture applied to it. I didn't bother rendering anything with cleartexture applied to it, because the image is quite boring.

Radial Texture
1. Basetexture applied
Radial Texture
2. Secondtexture applied
Part Two
Fading the texture

Now we just need to create the texture. The example will give you an animation, of course. You want to plug in a number between 0 and 1 for texture_clock. When texture_clock is 0, the first pigment in the list will be applied, and when texture_clock is 1, only the second pigment will be applied. It's when texture_clock is between the two that something interesting happens.

#declare texture_clock = clock; // 0 to 1

sphere { 0.0, 1 
         texture { average 
                   texture_map { [(1- texture_clock) basetexture ]
                                 [(texture_clock) secondtexture ] } } }

Radial Texture
3. Fade to clear
Radial Texture
4. Fade to granite

Send feedback, or head back to the Cyclopedia.

Thanks for watching.