- Home /
Light not applying to rotated 2D sprite
I'm lighting up my 2D scene with some point lights and a directional light (so it's not pitch black outside of the point lights). I've created a material for 2D sprites which is affected by these lights. It all works fine until I rotate the sprite around the y axis, at which point the sprite gets darker, eventually becoming black when the y rotation is 180.
My guess is that the lights are "above" (in terms of z) the sprite - the sprite's z position is 0, and the light's z position is -1, but even so, when the sprite rotates, wouldn't the light also apply to the other side? It's like it just applies the light once and then forgets about it, so when I rotate the sprite, I'm looking at the "unlit" side, but shouldn't it become lit as it rotates? (I don't know much about how lighting works).
So the way I see it I could either mirror the sprite for when I want it to "rotate" and just not actually rotate it, although this means duplicating sprites and checking in code to see which sprite should be drawn, OR I could have "two point lights at a time", i.e. where I previously had one at z position -1, I'd also have another at z position 1, so that both sides of the sprite are lit. But both of these seem really cumbersome and probably unnecessary.
Here's my point light:
And my sprite I want to light up:
Answer by Nephtis · Jun 03, 2018 at 09:54 AM
Originally, I had a directional light in my scene which was pointing down towards my 2D plane. I just added another directional light facing the other way on the other side of the plane to light the other side of the sprite. Although I'm still not sure why the sprite doesn't become lit as it rotates, this seems to work for now.
Answer by luoboa · Apr 04, 2020 at 09:27 AM
Try rotating the sprite +180 degrees; it seems for me only one side of the spritesheet was being affected by light.
Answer by Zirok_ · Dec 03, 2021 at 12:29 AM
I figured this out, this happens when you have more than two light sources affecting to a single sprite, i don't know why but the solution is to delete one of the light sources or set its culling mask to every layer exept where your sprite component is. hope this helps
Your answer
Follow this Question
Related Questions
Torchlight effect in 2D 3 Answers
Directional light 2D 0 Answers