www.jpct.net

jPCT - a 3d engine for Java => Support => Topic started by: kburden000 on March 12, 2012, 05:28:54 pm

Title: Are Transparent "Fake" Shadows do-able with a ShadowHelper and a Shader?
Post by: kburden000 on March 12, 2012, 05:28:54 pm
I've got cast shadows with a ShadowHelper and a Shader working, but the shadow is always a solid non-transparent color.
 
Here's a screen shot. The facial image is the caster and the grass below is the receiver.
(http://i1242.photobucket.com/albums/gg526/kburden000/jpct_shadow_test.jpg)

Is it possible to make the cast shadow a partially  transparent color?
I would like to make the blue shadow coming behind the portrait appear to just "darken" the grass behind and leave the tiling intact.

If yes, a hint about how to do it would be appreciated.

Thanks
Title: Re: Are Transparent "Fake" Shadows do-able with a ShadowHelper and a Shader?
Post by: EgonOlsen on March 12, 2012, 08:27:59 pm
The ShadowHelper itself renders the scene three times. One time from the light sources into the depth map (you seem to have that working), one time receivers only from the camera with a dark ambient light only, then with full lighting the depth map projected into the scene. When using a shader, it should be possible to combine the last two steps. I assume that your shader already makes a comparison of current depth to projected depth map? If you, all you need to do is to render the pixels where the current depth is larger (i.e. where your background shines through now) in a darker color instead of not at all.

The default ShadowHelper might not be the best choice to accomplish this. If you need it, i can post the sources of the ShadowHelper to ease the creation of a shader based variant.
Title: Re: Are Transparent "Fake" Shadows do-able with a ShadowHelper and a Shader?
Post by: Thomas. on March 12, 2012, 08:58:59 pm
The default ShadowHelper might not be the best choice to accomplish this. If you need it, i can post the sources of the ShadowHelper to ease the creation of a shader based variant.
How complicated is port it to jPCT-AE? :)
Title: Re: Are Transparent "Fake" Shadows do-able with a ShadowHelper and a Shader?
Post by: kburden000 on March 12, 2012, 10:37:12 pm
I can see that Shadows work in AdvancedDemo. Sorry they looked opaque black until I looked closer on a better monitor.
I just hopefully figure it by dissecting the Demo.
Thanks for your time
Title: Re: Are Transparent "Fake" Shadows do-able with a ShadowHelper and a Shader?
Post by: EgonOlsen on March 13, 2012, 11:09:19 am
In the current state, you can't make an object that uses a shader a shadow receiver, because the ShadowHelper relies on some fixed function stuff that you would have to mimic in the shader. This is on my todo-list, but it might take a while before it will happen.
Title: Re: Are Transparent "Fake" Shadows do-able with a ShadowHelper and a Shader?
Post by: kburden000 on March 13, 2012, 12:46:07 pm
As per your info in the previous post, I changed my code so that the groundPlane ( i.e. the grass ) no longer gets any shading.
This appears to have worked. I now have a cast shadow that blends with the receiver's texture rather than replacing it.

This is using solely the ShadowHelper/caster/receiver semantics from jPCT.

Here's a screenshot...
(http://i1242.photobucket.com/albums/gg526/kburden000/jpct_shadow_fixed-1.jpg)

Thanks Egon.