- Home /
Unlit shader that receives shadows?
I currently have a procedurally generated scene of a number of objects, all with baked textures. Their shaders are thus set to "unlit" given that the lighting plays no part in the scene. I would however love to have realtime shadows - they can't be baked because the scene is generated at runtime.
Does anyone know of an unlit - or alternative - shader that would allow me to do this?
Answer by SmilingCatEntertainment · Mar 13, 2016 at 01:49 PM
I wound up solving this issue without using a special shader.
Since I was already billboarding my quads with baked textures to the camera, I just adjusted my billboarding code a bit to billboard the normals to the directional light's angle instead of the camera position. This ensures that the lighting is never affected by the angle of the directional light. Then I just used the Standard Shader in Cutout mode.
mikelo actually got me thinking about the solution with his comment "maybe you can... ignore normals", and I suddenly thought, "What if instead of ignoring the normal, the normal always faced the directional light, to the same effect?"
Answer by mikelortega · Jun 01, 2015 at 11:15 AM
I would only use unlit for light emitting materials. Use Standard (in Unity 5) or diffuse (in previous versions). If your scene is too dark, try with a higher ambient color and intensity with these materials, this way you won't have problems with shadows.
The problem is that I have baked lighting, if I light using a directional light then I do not get the kind of scene lighting that I require and if I were to turn up Ambient Lighting to 1 to compensate (leaving the directional light to only cast shadows) then I wouldn't get any shadows.
Thanks for the answer though!
With ambient light set to 1 you get shadows, give it a try :)
I would try setting a low intensity directional light with a high strength shadow. Set your directional light to "Realtime" so it doesn't affect your baked lighting.
Yeah that's just it - the only way to get shadows with ambient light is to turn the directional light's intensity up which is something that's not really practical given that the scene parts have already been lit and balanced in another application. Even if I set the lights intensity to 0.2 (which adversely effects the baked textures to a decent degree) the shadows are still pretty faint despite their strength being set to 1.
I think a vertex shader is the only practical option for solving the problem unfortunately :)
$$anonymous$$aybe you can tweak the Standard shader to ignore normals... but I cannot help you with that :)