- Home /
Limit Amount of Light Applied to Sprite
Hi all! I've been bashing my head at this for a few days while trying to learn shader sorcery and I'm still not grasping what I need.
My end goal here is to make a replacement to the "Sprites Diffuse" shader that has a cap to the amount of light it can receive. Basically, unlit, the sprite should appear black. However, when lit, the sprite should gradually become brighter until it gets to its normal image.
Currently, this is not the behaviour exhibited by Unity. When you apply to much light to a sprite, it "whites out." The sprite information is lost as the pixels turn white.
I notice that the "Sprites Diffuse" shader uses a surface shader to add the lighting. Or, at least, I think that's what I'm getting out of it. I'd rather do this in the fragment or vertex portions, to give smoother lighting. I managed to get lighting working, as in I could get the vertices "lit" or "unlit" but I couldn't figure out how to apply light strength or distance.
Could anyone nudge me in the right direction?
*edit: The only other thing I wanted this shader to do was to not account for the Z depth of the light versus the sprite so that lights don't have to be moved manually to effect sprites. This is kind of a "stretch goal" for the shader, though, as I have a feeling the answer to this will be kind of obvious once I know how to apply the lighting properly.