POV-Ray : Newsgroups : povray.newusers : Using alpha transparency : Re: Using alpha transparency Server Time
5 Sep 2024 00:14:27 EDT (-0400)
  Re: Using alpha transparency  
From: Mike Williams
Date: 24 Apr 2002 16:01:31
Message: <1iom1DAg5wx8Ewlx@econym.demon.co.uk>
Wasn't it John Allers who wrote:
>Is there any way to project a shadow onto an invisible plane?
>
>Here's what I'm trying to do:
>I've created an "alien" for our graphics class.  I want to be able to put
>the alien into a real image.  Ex. I may want to show the alien walking
>behind me in a photograph.  The only problem I'm having is being able to
>project shadows.  If I put a white box under the alien for the shadow to
>fall on, the white box gets included in the alpha channel.
>
>Has anyone tried this?  Any advice would be greatly appreciated.

One trick would be to make two renders.

One render has just the alien against a transparent background.

Render number two has a plain bright white floor onto which the alien
casts a shadow. The background colour should also be pure bright white.
The alien is set "no_image" (needs Pov 3.5 or MegaPOV), or, with more
difficulty, is placed or bounded in such a way that the camera can't see
it and yet it still casts the same shadow. Set the lights so bright that
the resulting image is 100% white except where the shadow falls. I used

        global_settings {assumed_gamma 1.0}
        background {rgb 1}
        light_source {<-10,60,-50> colour rgb 1.5}
        box { <-10,-1,-10>,<10,0,10> pigment {color rgb 1.5}}
        #declare ALIEN = #include "alien.inc"
        object {ALIEN no_image}

so that all that the resulting image shows is the shadow. Hint: try not
to use an infinite plane as the floor, since it's hard to light it so
that the shadow is visible and the horizon is pure white.


How you merge the three images depends on what paint program you are
using. In Paint Shop Pro, I made sure that all three images were the
same size, and adjusted the contrast on the shadow image so that the
shadow was completely black. I then set them up as three layers:
(Use ^C to copy and ^L to paste as new layer). The layer parameters
looked like this:
        Background      Photo   100%    normal
        Layer 1         Shadow   50%    multiply
        Layer 2         Alien   100%    normal
Finally, with "Layer 2" active, I used "Masks -> Load from Alpha
Channel" to make PSP take notice of the alpha transparency.

The "50% multiply" layer affects the background photo like this:
wherever there's a white pixel in layer 1, the pixel from the background
is unchanged (any colour multiplied by 1 is itself) but wherever there's
a dark pixel, the background pixel is darkened by 50%. 

You can lighten or darken the shadow by changing the percentage until it
matches the darkness of the real shadows in the photo.

-- 
Mike Williams
Gentleman of Leisure


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.