Baked/Dynamic Shadow Maps iOS (a la Bladeslinger) Source included

A while ago I read this article
http://blogs.unity3d.com/2013/01/15/bladeslinger-pushing-the-boundaries-part-i/

I wanted to implement the static shadow maps algorithm except not as a projector but using shadow mapping techniques. This is a basic shadow map routine with no frills.

Instructions

Make sure all the objects you want shadows cast on use the Diffuse or Unlit Shadow Map shaders.
Hit GameObject → Create Other → Shadow Map Baker to create a shadow camera.
Select the Shadow Camera gameobject that was created
Aim it so your entire scene is inside. You can adjust near/far and ortho size but keep it as small as you can
Select resolution
Hit Bake and save it to a folder inside your project
adjust the bias to prevent artifacts

If you hit realtime then it will render a shadowmap each frame.
Requires Unity pro. But technically the static shadow maps only need it for baking.

Only tested on Mac

Source is included:) If you feel like giving a small donation for the demos it would be appreciated:).

Dropbox Link

https://dl.dropboxusercontent.com/u/17249329/baked%20shadow%20map.unitypackage

My other demos

http://forum.unity3d.com/threads/182296-GPU-Water-ripple-effect-Desktop-and-iOS-source-code-available

http://forum.unity3d.com/threads/180769-2D-dynamic-soft-shadows-(will-release-source-later)

More to free stuff to come!

1248349–53875–$baked shadow map.unitypackage (1.9 MB)

1 Like

could this be used on unity indie for static shadows?

You could bake those shadow maps elsewhere but it’d be more trouble than it’s worth.

Yeah you’re right hippocoder. I think it might be possible to do a RenderWithShader and copypixels to create the depth buffer so it would be fully indie compatible. I might give that a go.

Sorry for waking an old thread, but… Want me to port it to indie? I can! :wink: (I actually did a while back, but deleted it by accident… :smile:)

Again, will port it again if anyone wants me to! :slight_smile:

1 Like

Hi FuzzyQuills, I would definitely and extensively use an indie port of it for the project I’m working on. If you are willing to do it again, could you please post it here? PM me if you prefer.

Could really use this in my project.

Hey Brian,

Thanks for posting this up. This technique looks super useful! I was wondering if you had a Unity5 compatible version, I downloaded the package but some of the scripts and shaders didn’t compile properly.

I’ve uploaded it to GitHub with Unity 5 fixes.

Looking cool. :slight_smile: Didn’t even know you were still supporting this.

I’ve updated a few of my libraries including the water ripple one. Time to get off my lazy arse:)

LOL. :smile:

Anyway, which one’s the water ripple one? sounds interesting.

EDIT: nvm, found it via google, damn that’s impressive. :slight_smile: I’ll have to try that someday when I need decent water in one of my game worlds!

This is extremely rad! I’m wondering if there is a way to add an additional normal bias or slope-scaled depth bias, to help deal with some of the shadow acne?

For a normal bias, I’m not quite sure how that works, but if all it needs is to offset all the verts by a tiny amount… try using a custom shader on the shadow map camera (aka. use SetReplacementShader) that “squishes” the meshes slightly using the normals as the direction to “squish” in. :slight_smile:

I can try writing a template to start off with. As for your second request… slope-scaled depth bias ain’t my cake unfortunately. :wink: