Mar
15
2012

Fake Realtime Shadows With Surface Shader

Yes! After several hours of shader errors, finally got this working, fake realtime shadows using shader (2D)

Its using obstacle map texture (see image#2), so thats the 1st downside of it,
but still better than nothing..

More info later..

Ideas to try:
– Blur the wall map texture, Soft shadows?
– Add 2nd pass for: combining the shadow, instead of 1st pass? or use 2nd pass for blurring?
– Would this work as camera shader, using depthmap as an automatic obstacle map? (*problem: how to get neighbour pixel colors from vertex color..?)
– Fake directional light shadows should be even easier?
– Use light attenuation for shadow / light strength?

Current progress:
– Can use screenshot as an automatic wall mask texture, no need to create it manually
– But that creates another problem, the view should be same size as plane/texture?
– Using depthmap as wall mask would give realtime shadows, with moving objects also,
but no idea how to use depth pass like a texture+uv with Tex2D..

Webplayer:
http://unitycoder.com/upload/demos/mFakeShadowShader2/

Download source:
fakeShadowShader.unityPackage

*image#2: obstacle texture map


8 Comments + Add Comment

  • Hi, are there any plans of releasing the source? or can you explain in short how this shader works?

  • Hi, can you releasing the source code?

    Sorry for the obsession, but it’s perfect for my project, but haven’r experience in writing shaders…

    • I’ll try add it soon (by next week at least)
      one note, you need to create that obstacle mask image.. (so if objects are moving, they wont cast shadows, unless they are updated on the obstacle mask texture..)

  • source added

    • Thank you so much 🙂

Leave a comment

Connect

Twitter View LinkedIn profile Youtube Github Join Discord Twitch Instagram BlueSky

UnityLauncherPro

Get UnityLauncherPRO and work faster with Unity Projects!
*free unity hub alternative

@unitycoder_com

Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.