very basic shader

I have a shader to darken the parts of a sprite that face away from a vector2 light source…

Now, to make the shader dynamic, I need it to get updated information about relative position of the light source…

So I would like to pass my fragment shader a vector2 that represents the difference between the position of the light, and the position of the sprite being shaded…

Will I have to store my position vectors in vertex data and pass it through the vertex shader to the fragment shader?

Assuming that all sprites in the batch use the same light, the light position can be a shader constant. SpriteBatch vertices already have position data. You can use it to calculate the relative light position, either in the vertex, or, in the pixel shader.

1 Like

Yeah, at the end of the day, I think Ima end up using the sprites to manipulate/shade the individual LIGHT, rather than using the light to shade the sprites within the scene… So the position of the light WOULD be fixed, at the center of each light.