POV-Ray : Newsgroups : povray.general : Shadow on alpha channel? Server Time
29 Nov 2024 13:30:12 EST (-0500)
  Shadow on alpha channel? (Message 1 to 3 of 3)  
From: zachrahan
Subject: Shadow on alpha channel?
Date: 19 Oct 2005 18:05:01
Message: <web.4356b88f87d51cba35162b020@news.povray.org>
Hi folks,

I'm trying to figure out a good (and easily-automated) way of rendering
images with povray that have an alpha channel and also object shadows on
the (otherwise transparent) background.

This is the same question as forwarded in these threads:
http://news.povray.org/povray.advanced-users/thread/%3Cweb.421342a39456fee4f2a37e710%40news.povray.org%3E/?mtop=3
and
http://news.povray.org/povray.advanced-users/thread/%3C4184d1c3$1@news.povray.org%3E/?ttop=216442&toff=50

The solutions mooted therein seem a bit clumsy for something that I will
eventually need to automate. Based on them, however, I have an idea which
may be workable.

Now, clearly, the best thing would be some special modifier in ITK to make
an object invisible but still "catch shadows" with whatever properties it
would have otherwise. Something like the "no_image" option. Since that's
not something I can do, here's my plan:
(1) Render the scene with an alpha channel.
(2) Re-render the scene with all objects marked "no_image", with no alpha
channel, and with a perfectly white "floor" plane to catch the shadows.

The second rendering is now basically an "alpha channel" for just the
shadows.
I would then recombine them as follows:
(A) Add the shadows to the original image by multiplying the image channel
from (1)
with the shadow image (2), using something like ImageMagick. This will just
add the shadows back without otherwise affecting the image.
(B) Add the shadows to the alpha channel by multiplying the alpha channel
from (1) with the shadow image (2). This again preserves the original alpha
in the white regions of the shadow image, but overlays the shadow alpha
value on the original image alpha in regions where there are shadows.

This process is very easily automated, and I think it is the best way to
deal with this problem (other than adding a new keyword to povray). First,
do others agree?

Second -- and most importantly -- what is the best way to make an image that
is perfectly white except where shadows are cast? A white plane with 100%
ambient? Something doubly-illuminted from behind? There still needs to be
the original light source so that shadows get cast properly, but I need
somehow for the shadows to be the *only* lighting variation in the image.
Is this possible?

Zach Pincus


Post a reply to this message

From: Slime
Subject: Re: Shadow on alpha channel?
Date: 19 Oct 2005 22:35:04
Message: <43570258$1@news.povray.org>
> This process is very easily automated, and I think it is the best way to
> deal with this problem (other than adding a new keyword to povray). First,
> do others agree?

Yes, I think this is generally the process suggested (even in the links you
posted).

> Second -- and most importantly -- what is the best way to make an image
that
> is perfectly white except where shadows are cast?

This does it:

 texture {
  pigment {rgb 1}
  finish {ambient 0 diffuse 1 brilliance .0001}
 }

The light source must, of course, have the color "rgb 1" to get white where
light hits the object. The "ambient 0 diffuse 1" ensures that the color of
the surface will be exactly the color of the light that hits it (with no
added ambient light), and "brilliance .0001" ensures that the angle of the
light has (virtually) no effect on its brightness on the surface.

Sample scene:

camera {
 location <0,4,-5>
 look_at 0
}
sphere{0,1 pigment {rgb 1} translate y no_image}
plane {
 y,0
 texture {
  pigment {rgb 1}
  finish {ambient 0 diffuse 1 brilliance .0001}
 }
}

light_source {
 <1,1,-1>*999
 rgb 1

 area_light
 x*300,y*300, 17, 17
 adaptive 1
}

 - Slime
 [ http://www.slimeland.com/ ]


Post a reply to this message

From: zachrahan
Subject: Re: Shadow on alpha channel?
Date: 20 Oct 2005 11:50:01
Message: <web.4357bc3c156283a435162b020@news.povray.org>
Thanks for clarifying the best material to use for the "shadow catcher"
surface. That seems to do the trick!

> Yes, I think this is generally the process suggested (even in the links you
> posted).

I agree -- the process I suggest above is heavily-derived from those links I
found.

I think the above method will be slightly easier than (as suggested in the
first link) rendering the shadows with an orthographic camera and then
mapping that texture (partially transparently) onto the shadow-catching
surface -- it involves less scene-changing. It's also important to remember
to combine the original alpha channel with the shadow alpha channel,
instead of using the latter as the sole alpha (as suggested in the second
link). I just figured I'd be explicit, in case anyone else wound up looking
at this thread for reference later.

(Also, note that the second link appears garbled in my web browser. Here it
is again, for reference:
http://news.povray.org/povray.advanced-users/thread/%3C4184d1c3$1@news.povray.org%3E/?ttop=216442&toff=50
)


Post a reply to this message

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