POV-Ray : Newsgroups : povray.general : Separate shadow and object layers Server Time
31 Oct 2024 23:29:05 EDT (-0400)
  Separate shadow and object layers (Message 1 to 8 of 8)  
From: posfan12
Subject: Separate shadow and object layers
Date: 25 Jun 2014 11:20:00
Message: <web.53aae7fedd599cbe186582ab0@news.povray.org>
I'm rendering an orthographic scene for a video game. I would like there to be
separate object and shadow layers. I.e. one image for all the objects in the
scene, minus shadows, and another image with shadows only. What is the best way
of going about doing this?

Right now I have one scene where all the objects are painted white and shadows
are turned on, and a second scene with all the objects painted normally but
shadows turned off. Is this the best way?


Mike


Post a reply to this message

From: Le Forgeron
Subject: Re: Separate shadow and object layers
Date: 25 Jun 2014 11:53:23
Message: <53aaf073$1@news.povray.org>
Le 25/06/2014 17:17, posfan12 nous fit lire :
> I'm rendering an orthographic scene for a video game. I would like there to be
> separate object and shadow layers. I.e. one image for all the objects in the
> scene, minus shadows, and another image with shadows only. What is the best way
> of going about doing this?
> 
> Right now I have one scene where all the objects are painted white and shadows
> are turned on, and a second scene with all the objects painted normally but
> shadows turned off. Is this the best way?
> 

If it works for you, it's a good way. Just wondering how you turn off
the shadow on second image: with +Qx (x <4), it also turns off patterned
texture, extended light, photons, refracted & transmitted rays and
media, radiosity and sslt.

For the shadow only image, you might want to have a look at the no_image
(and maybe no_reflection) as object modifier.

For the objects without shadow, there is the no_shadow object modifier.

> http://wiki.povray.org/content/Reference:Object_Modifiers

You could use the animation subsystem and a macro like

#macro WHATPART()
#if (clock > 0)
 no_image
#else
 no_shadow
#end
#end

with your objects calling WHATPART like:

sphere{ center, radius WHATPART() ... }


-- 
IQ of crossposters with FU: 100 / (number of groups)
IQ of crossposters without FU: 100 / (1 + number of groups)
IQ of multiposters: 100 / ( (number of groups) * (number of groups))


Post a reply to this message

From: clipka
Subject: Re: Separate shadow and object layers
Date: 25 Jun 2014 13:19:17
Message: <53ab0495$1@news.povray.org>
Am 25.06.2014 17:17, schrieb posfan12:
> I'm rendering an orthographic scene for a video game. I would like there to be
> separate object and shadow layers. I.e. one image for all the objects in the
> scene, minus shadows, and another image with shadows only. What is the best way
> of going about doing this?

Hmm... I'm thinking that there must be /some/ way to render to an image 
with alpha channel and get nearly-opaque shadows being cast on an 
otherwise transparent plane.

Let me know if that would help, and I'll come up with some way to do it. (*)

Other than that, as Jerome already mentioned, the "no_shadow" and 
"no_image" keywords are probably your big fat friends.


(* Heck, I'm sure it can be done by making smart use of what POV-Ray 
already provides, but it seems such a straightforward use case that 
POV-Ray should really provide an equally straightforward way of doing it.)


Post a reply to this message

From: posfan12
Subject: Re: Separate shadow and object layers
Date: 25 Jun 2014 13:35:00
Message: <web.53ab0814fa876566bdbe52210@news.povray.org>
clipka <ano### [at] anonymousorg> wrote:
> Am 25.06.2014 17:17, schrieb posfan12:
> > I'm rendering an orthographic scene for a video game. I would like there to be
> > separate object and shadow layers. I.e. one image for all the objects in the
> > scene, minus shadows, and another image with shadows only. What is the best way
> > of going about doing this?
>
> Hmm... I'm thinking that there must be /some/ way to render to an image
> with alpha channel and get nearly-opaque shadows being cast on an
> otherwise transparent plane.
>
> Let me know if that would help, and I'll come up with some way to do it. (*)
>
> Other than that, as Jerome already mentioned, the "no_shadow" and
> "no_image" keywords are probably your big fat friends.
>
>
> (* Heck, I'm sure it can be done by making smart use of what POV-Ray
> already provides, but it seems such a straightforward use case that
> POV-Ray should really provide an equally straightforward way of doing it.)

In GIMP I can convert the grayscale image to an alpha channel, and then apply
the alpha channel to a 100% black image.

If there's some internal POV-Ray trick that would be better.

Mike


Post a reply to this message

From: posfan12
Subject: Re: Separate shadow and object layers
Date: 25 Jun 2014 13:40:01
Message: <web.53ab08e8fa876566bdbe52210@news.povray.org>
Le_Forgeron <jgr### [at] freefr> wrote:
> If it works for you, it's a good way. Just wondering how you turn off
> the shadow on second image: with +Qx (x <4), it also turns off patterned
> texture, extended light, photons, refracted & transmitted rays and
> media, radiosity and sslt.

I'm using low quality settings anyway, so it won't matter much.

> For the shadow only image, you might want to have a look at the no_image
> (and maybe no_reflection) as object modifier.

No, I need more than just the shadow cast on the ground. I need to capture
shadows cast on everything, including the scene objects.

> For the objects without shadow, there is the no_shadow object modifier.

Yeah, that's what I intend to use.


Mike


Post a reply to this message

From: Le Forgeron
Subject: Re: Separate shadow and object layers
Date: 25 Jun 2014 14:22:28
Message: <53ab1364$1@news.povray.org>
Le 25/06/2014 19:34, posfan12 nous fit lire :
> clipka <ano### [at] anonymousorg> wrote:
>> Am 25.06.2014 17:17, schrieb posfan12:

>> (* Heck, I'm sure it can be done by making smart use of what POV-Ray
>> already provides, but it seems such a straightforward use case that
>> POV-Ray should really provide an equally straightforward way of doing it.)
> 
> In GIMP I can convert the grayscale image to an alpha channel, and then apply
> the alpha channel to a 100% black image.
> 
> If there's some internal POV-Ray trick that would be better.

Why do I suddenly think about negative light ? (and  emission/ambient...)

Usual scenes are in the 0 to 1 range for both parameters, but it can be
interesting to look at the combination of -1 , 0 and 1 cases.


Flat object, no shadow : emission 1, light 0, diffuse 1.

Shadow only picture: emission 0, light -1, diffuse 1
(black is full light, the brighter the more deep shadow)


Maybe emission 0.5, light 1, diffuse 0.5 can provide a descent base for
the objects, once you remove the shadow of it using the second picture
(0,-1,1).



-- 
IQ of crossposters with FU: 100 / (number of groups)
IQ of crossposters without FU: 100 / (1 + number of groups)
IQ of multiposters: 100 / ( (number of groups) * (number of groups))


Post a reply to this message

From: posfan12
Subject: Re: Separate shadow and object layers
Date: 25 Jun 2014 16:00:00
Message: <web.53ab2981fa876566bdbe52210@news.povray.org>
Never mind, guys. I was over-thinking the problem.

What I did was:

1. Render the scene normally but without a floor.
2. Then re-render with a basic white floor, and show shadows /only/.
3. In GIMP I then used the "Color to alpha" command with the image in step #2 to
create the shadow layer with lots of transparency.
4. In GIMP add the image in step #1 as a new layer to #2.
5. In GIMP flatten the image and save/export as PNG.

The result is this:

http://i421.photobucket.com/albums/pp292/SharkD2161/LDraw/datsville_overlay_shadow_test_zps8b7f1183.png

but larger.

The game characters can now walk "underneath" the shadows. There are places
where this method fails somewhat, and the characters themselves don't cast
shadows. But that's the best it is going to get unless you switch to a real-time
3D game engine.

Thanks!


Post a reply to this message

From: posfan12
Subject: Re: Separate shadow and object layers
Date: 26 Jun 2014 02:25:01
Message: <web.53abbbb3fa8765661dc356f50@news.povray.org>
If you want to see what I'm up to, visit here:

http://www.rpgmakervxace.net/topic/24781-datsville-rpg/


Post a reply to this message

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