Long story short, I want a top-down shadow under my player.
-I can’t use a blob shadow because we have things like shelves, and other layered objects in our level, and the blob projection penetrates and draws onto all layers, which looks bad.
-I would like to use a real shadow, but I don’t want any illumination from the light that’s casting the shadow. I can’t do this, because setting the light to black, or the intensity to zero, also hides the shadow.
Finally, I think the solution is to set up my own transform, for what would normally be a light, and render my own shadow map from there. Then, I can simply apply attenuation in my fragment manually, based on that map.
My knowledge of shadow mapping is limited though, so I have some questions.
I’ll be referencing the following tutorial, trying to create a shadow map for a single directional light:
So in order to create the shadow map, do I simply set up an orthographic camera where the directional light would be, and render a depth texture? or is there more to it? Maybe some Unity specific requirements?
For applying the map, I’m looking at the second post here:
It seems that for a directional light, these two macros produce the following:
LIGHTING_COORDS(0,1) // float4 _ShadowCoord : TEXCOORD0;
TRANSFER_VERTEX_TO_FRAGMENT(o); // v2f._ShadowCoord = ComputeScreenPos(v2f.pos);
So those macros seem like a general solution for an arbitrary directional light, regardless of it’s properties.
This one, it seems, would need to be rewritten to use my own shadow map:
float atten = LIGHT_ATTENUATION(i); // unitySampleShadow(v2f._ShadowCoord)
So would I simply modify unitySampleShadow to take the shadow map as a parameter instead of using the global variable ‘_ShadowMapTexture’ ?
Any help on this would be greatly appreciated.
Thanks