Povray transparent background with shadows
I would like to use Pov-Ray to create images that can be used on a website on any background color. Photos should have a transparent background, but with reflections and shadows applied to a transparent flat surface.
In Pov-Ray (3.7) you can set transparent background by setting Output_Alpha=True
to file povray.ini
and posting as file png
.
You can even get transparent reflective surfaces using color Clear
on a plane (or any other object). But if you set the object's color to Clear
, no shadows will be superimposed on it.
Can I cast shadows on transparent objects?
source to share
The technique suggested by m13r produces very good renderings, but requires 3 render passes and a lot of scene changes for each. It takes time and requires a bit of customization.
Simpler and more honest, in some cases, the best result can be obtained in just two passes. Set both background and ground plane to white, render, set them to black, render again. Let's say you toggle the setting here and generate two files, white.png
and black.png
using one or the other of these light definitions.
//#declare SceneLight = rgb<1,1,1>
#declare SceneLight = rgb<0,0,0>
background { color SceneLight }
plane {
y, 0
pigment {
color SceneLight
}
}
Now two images and extract the difference using the two backgrounds method described here .
magick black.png white.png -alpha off \
\( -clone 0,1 -compose difference -composite -negate \) \
\( -clone 0,2 +swap -compose divide -composite \) \
-delete 0,1 +swap -compose CopyOpacity -composite \
transparent.png
The disadvantage of this method is that you have less flexibility compared to lighting the stage and you cannot pretend to reflect something off the ground. If your objects are matte enough not to be severely affected by the background colors of the scene, then this method may be for you. In my case, it saved one pass that took a lot of rendering time and a lot of manipulation of scene objects.
source to share