Search Unity

Project shadow into alpha channel

Discussion in 'Shaders' started by Marc, Nov 6, 2008.

  1. Marc

    Marc

    Joined:
    Oct 4, 2007
    Posts:
    499
    Im looking for a way to project an inverted shadow (shadow is white, rest is black) into an alpha channel.

    Its for a 2D game. The game consists of serveral layers: foregrounds, game plane, backgrounds. The shadow plane infront is suppose to just be a plane with a transparent/diffuse shader, which is where the shadow must apear. Should give an illusion that the game is on a flat surface. Like paper.

    I tried setting up a plane and using the build in dynamic shadows, but the shadow disapears once transparent shader is used, so that is a no go. I tried letting the camera render into a render texture in the hopes i could somehow modify the render to apply alpha. I guess it would be possible, but the object is also rendered and i only need the shadow. If i disable the mesh render the shadow goes away ofc, so that seems to be not an option either.

    I also looked at projected blob shadow, but that cannot project on a "non visible" plane either and it has the side effect of creating a static shadow, not depending on light source direction.

    So i am kinda out of ideas except for this last one, i asked looked around on the forum and asked in the IRC channel and got the impressions that it is possible, but requires a custom shader, so i thought i would put the post here.

    Would it be possible to create this and how would one go about it?

    Regards,
    Marc
     

    Attached Files: