How would I get the 2D point light positions in a shader using the Universal Render Pipeline in Unity?
I’m trying to simulate a 3D effect by reducing light intensity from lights that are above a sprite in the Y position.
I duplicated the Sprite-Lit-Default shader and easily managed to change the output by doing a lerp between the sprite’s default color and black.
I Just changed
o.color = v.color;
to
o.color = lerp(v.color, black, lightYPos);
The problem is that I can’t really get the Y pos from the light sources, and I only know it works because I manually set the lightYPos from 0 to 1 for testing.
Anyone knows how I can manage to get the point lights positions from a shader?
The effect I’m trying to achieve is like this one:
This is from a Gamastra article where the Graveyard Keeper developers share how they did some of the effects in their game.
They say that “There is a shader that calculates the distance between a light source and a sprite on the vertical axis. If it’s positive (the light source is in front of the sprite), we illuminate the sprite like we always do, but if it’s negative (the sprite is blocking the light source), then the intensity of lighting is fading depending on the distance at a very quick rate.”
But they don’t share any info about the shader itself.
Would love some help on how I can retrieve point lights positions in the URP 2D Sprite Lit Shader…