Author Topic: Are Transparent "Fake" Shadows do-able with a ShadowHelper and a Shader?  (Read 1866 times)

Offline kburden000

  • byte
  • *
  • Posts: 7
    • View Profile
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.


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

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11745
    • View Profile
    • http://www.jpct.net
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.

Offline Thomas.

  • double
  • *****
  • Posts: 833
    • View Profile
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? :)

Offline kburden000

  • byte
  • *
  • Posts: 7
    • View Profile
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
« Last Edit: March 13, 2012, 08:44:19 am by kburden000 »

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11745
    • View Profile
    • http://www.jpct.net
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.

Offline kburden000

  • byte
  • *
  • Posts: 7
    • View Profile
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...


Thanks Egon.
 
« Last Edit: March 13, 2012, 12:50:56 pm by kburden000 »