- Home /
Shader: How can my unlit material receive a uniform shadow?
I'm testing my 2D game in a 3D environment, to make use of lighting and colliders, similar to how Enter the gungeon was made.
In the pictures below, I have a cube (fridge) and an orthographic camera angled down 22 degrees, and a point light to the right.
We hand draw textures that has shadows, but we want some objects to cast shadows on floors and walls. However, I want to avoid any gradients, and only have either 100% the original unlit color, or a shadow, for example 30% black.
I made an illustration of three images: 1) Unlit shader, here it doesn't receive any shadows, it's 100% unlit 2) Standard shader, it receives shadows correctly, but the wall is gradiently coloured depending on the position of the light 3) Custom shader (Faked in photoshop) what I want it to look like.
Also I'd like the same material (the fridge) to react to light, but only "all or nothing", so if there is a blue light for example, the entire fridge is tinted blue, without any gradients. But I guess this might be a different part of the shader?
Thanks!
Answer by sarahnorthway · Jul 11, 2019 at 08:57 PM
You may have better results with a high-intensity Directional Light than a Point Light.
Unfortunately it's difficult for an object to receive shadows from other objects without also receiving shadows from itself (thus having un-uniform lighting), but this is more a problem for curved shapes than flat planes and I don't think it's an issue here.
Another solution might be using a Projector component which is typically used to cast shadows under moving characters.
Thanks for the ideas. I would be needing point lights. So it doesn't seem to solve the issue, and it seems as it would be possible to make a custom shader for this.
We are possibly going to go all 2D ins$$anonymous$$d, so this was mostly an experiment of what could be done. Thanks!