Light!
A while ago I attended a presentation and in the slideshow I noticed a picture with very interesting attributes. The background of the slide was pure white and the picture had a white background too so there was a perfect blending in of the image however, the object in the image was white as well so all you could see was its shadows. I have been programming and playing with raytracers for long enough (more than 20 years) to recognize a raytraced image pretty quickly but this one was different, it used radiosity causing the shadows to be more real and correctly colored.
To make a long story short: I dived once again into the world of POV-Ray, Moray and radiosity. My goal was create a stock of transparent images by rendering shadows only so the images would fit on ANY background. I am not going to give you my images (just come to a presentation I give to see them) but I am going to give you my recipe.
But first, in honor of the first CTP of Silverlight 3 that is to be released later today, (if you look around on the internet you can already find the bits) I have rendered this using the recipe below (except for the blue colors).
Here is what you do in POV-Ray:
Setup radiosity like this:
radiosity {
brightness 2.2
count 100
error_bound 0.75
gray_threshold 0.0
low_error_factor 0.2
minimum_reuse 0.015
nearest_count 10
recursion_limit 1
#if (version>3.1)
adc_bailout 0.01
max_sample -1.0
media off
normal off
always_sample 1
pretrace_start 0.08
pretrace_end 0.04
#end
}
Radiosity works best when not explicitly using any lights like point lights, ambient lights or area lights in POV-Ray or any raytracer due to the way radiosity works. What you need is some objects made from materials that emit light (that sounds like an ordinary light but to the raytracer there is a very distinct difference). To get the effect I was looking for I created two materials:
#declare Pure_White_Light =
material
{
texture
{
pigment
{
color rgb <1.0, 1.0, 1.0>
}
finish
{
ambient 1.0
specular 0.7266
roughness 0.006139
}
}
}
#declare White =
material
{
texture
{
pigment
{
color rgb <1.0, 1.0, 1.0>
}
finish
{
ambient 0.0
phong 0.1151
phong_size 25.163333
specular 0.769767
roughness 0.0
metallic 0.5
}
}
}
The magic is in the ‘finish’ as you can see the Pure_White_Light material emits an ambient light.
Assign the objects you want to use as lights in your scene this emitting material and you are set to go.
One final step:
background { color <1.000,1.000,1.000> }
The image that is being rendered will be rendered to a white background. This will make it possible to add a transparency to the image based on the ‘darkness’ of the image in a image processing tool like Paint.NET
So lets render a cube:
On a white background this appears quite good and subtle. (Remember this is all a matter of taste and this is my blog so I am entitled to give my opinion and you do not have to agree 😉 ) Now let’s get this cube ready for an other background.
Start Paint.NET after installing the Alpha Mask plugin and open the image. First invert the colors of the image.
Next, apply the Alpha Mask plugin and select the same image as the alpha mask and invert the mask.
You’ll end up with the transparent version of the image above:
(The checker pattern is the background that Paint.NET shows when there is nothing to see)
This image can be used on top of any color in a slideshow. Of course I am going to write a plugin for Paint.NET that does all of this in a single keystroke but that’s for later 😉