- Home /
How to deal with shadow scale and self-shadows?
So, Unity and self-shadows on characters, no matter what combination of 'Clipping Plane' near/far distance, shadow distance and map resolution can I get it to render correctly.
My characters are measured in meters where 1 unity unit = 1 meter. This is the same as the internal physics uses and what we scale time against to get things to behave right in scripts. But for shadows this just turn out to be too small a scale it seems, standing 1.8 units high for 180cm this causes severe rolling 'banding artifacts' in the self-shadows as one move.
If I make my character really large, scale it to be 5x the size and stand 9 meters tall shadows can deal with it and can be dialed in to render correctly. So can I somehow make shadows behave this way but at unity's native scale of '1 unit = 1 meter' or am I really to be F'ed in the A by unity on this? I've attempted tweaking the code in the 'Shadow-ScreenBlur.shader' but replacing it as with the terrain shader doesn't seem to have any effect at all.
I have a file illustrating my problem but I can't upload it, keep getting 'Error parsing the uploaded file'.
Hi $$anonymous$$ister$$anonymous$$ike, I'd like to help you
A lot of professional games use a special shadow pass just for the self-shadowing of main characters. This way, for instance, you could get gloriously long sunset shadows while at the same time having the precise, self-shadowed nose of your protagonist. No need to impossibly tune for both ends of the spectrum.
There's a lot of effort involved in that, with or without Unity. With Unity it's a touch harder since Unity likes to handle all shadowing for you, so you'll have to go behind its back to do this work (meaning: set up your own rendertarget, make a draw calls list and render out your shadow tile to be sampled later. Since we can't access Unity's shadow collector you'd have to calculate those shadows from the material shader of your main character directly)
If that sounds roundabout, it's because there's a big gap between the concepts of a rendering pipeline and what Unity will physically allow you to do in its claustrophobic corridors.
I have to get this out of the way: if there's any way to tune away this problem, go for that first. Are you using cascaded shadows? If not then turn it on, gives you more precision up close. Besides that apply the usual: crank up the resolution of your shadow maps, use Camera.depthTexture$$anonymous$$ode = Depth ins$$anonymous$$d of DepthNormals because you get greater precision (this has deeper effects however, are you using deferred rendering by the way?)
If you have time and passion, try #1. Otherwise, or if that doesn't work, just tune your best. I know that sounds like a cop-out. You're in Unity land now.
With Unity you must resign yourself to compromise. There are so many things one wants to do in Unity that just can't be done. I broke Hable's most famous law by shipping AO in sunlight. This is inexcusable; no way around it in Unity. Forgive yourself, and let me know if #1 works!
I have this same problem, what I found to be strange is that Unity has this system working against working on a real world scale, this mechanism would have been on my priorities when dealing with a game engine I would image, so it baffles me that it does not work, save if you have your world created 10 times bigger than it should be, which then carries other problems like having the camera moving sluggishly, I haven't found a solution for this issue either... so if someone has a solution I would be grateful.
Your answer
Follow this Question
Related Questions
Shadow Artifacts SketchUp dae to Blender FBX Model 0 Answers
Shadows being received by non-shadow collectors that are depth culled by a shadow collector. 1 Answer
How to prevent holes in shadows without generating Shadow Acne? 1 Answer
Disabling dynamic shadows in deferred rendering (Unity 5) 1 Answer