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:).
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.
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.
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.
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.
I can try writing a template to start off with. As for your second request… slope-scaled depth bias ain’t my cake unfortunately.