Implementing custom shadow map filtering...

Hi guys.

I am after some knowledge of how to do some sort of custom shadow filtering for my game project. being that Unity Free doesn’t have soft shadows, I need to find a way to do my own shadow sampling in free. only problem is, Google brings up nothing on this!

If anyone can point me in the right direction, that would be great! :slight_smile:

some keywords for searching:
unitySampleShadow
_ShadowMapTexture

i’ve tried replacing AutoLight.cginc and modifying it, but only managed to invert the shadow so far…(or duplicate, but it starts to float around…)

Yes search on AutoLight.cginc and try to find the shadowmap part, and modify it to have some pcf filtering.

first version kind of working (webplayer demo) :
http://unitycoder.com/upload/demos/HardShadowSoftener/

OOH! mgear, you are a legend! could you give me this. perrrlease! :smile:

@Cyrien5100 : i did give the autolight.cginc a go, but i didn’t know what to change… :eyes:

EDIT: Also, do you know where to put a modified AutoLight? i kinda forgot… :frowning:

i’m posting the sources soon’ish (later this week hopefully)

COOL! Also know how to replace a new AutoLight.cginc?

i did this:

  • copied UnityCG, UnityShaderVariables, HLSLSupport, AutoLight to assets folder
  • renamed these as: UnityCG2, UnityShaderVariables2, HLSLSupport2
  • created new shader file (that default diffuse)
  • add this line to shader: #include “UnityCG2.cginc”
  • modified it to use: #include “UnityShaderVariables2.cginc”
  • modified that to use: #include “HLSLSupport2.cginc”
  • then modified AutoLight for the soft shadow (basically changed all returns to 1, until founded which one it is)

Question: when adding autolight, do you have to include it? I did everything else… but changing all returns to 1 does nothing!

Good stuff folks. Just a quick note, ShadowSoftener.com somehow does this without modifying autolight or any other built-in cginc. So it’s definitely doable without such hackiness — the built-in cgincs get often (ok rarely but still) changed during Unity updates, but will your project keep up forever? :wink: :wink:

There’s some built-in named pass tags you can use or hook into or some such. Don’t have the full details on me but just in case you were wondering whether there is a way that doesn’t require modifying the built-in cgincs. There is :smile:

That would be pretty nice, also founded out that the other cgincs were not needed, just put the AutoLight in the same folder as the shader…

sources are in the github now, need help to improve it :slight_smile:
http://unitycoder.com/blog/2014/07/15/unity-indie-soft-shadows-directional-light/

** posted the “release” as new thread here:
http://forum.unity3d.com/threads/free-directional-light-soft-shadow-unity-indie.257432/