- Home /
How do I light a sprite in a 3D environment?
Hi, I'm making a 2.5D game, where 2D sprites are in a 3D environment. I'm using URP and I have a problem with lighting the sprites. The sprites are lighting up from behind, and not front. I tried with directional, spot and point lights but the result is the same no matter what official shader I use they only light up when they receive light from behind. Front light has no effect whatsoever on the sprites.
I spent the entire day looking for a solution but to no avail. Only solution I saw someone else mention is making the game object with the "sprite renderer" on, a child of another gameobject and rotate it 180 degrees on Y. But that is not an option for me cause I'm using custom scripts to rotate that game object already.
So can there be a custom shader? Can one be created using shadergraph maybe? I know some others have faced the same problem but did anyone really solve it?
Thanks.
Answer by VernRowan · Jul 20, 2020 at 04:22 PM
Ok, this problem apparently occurs because at some point I enabled "GPU Instancing" under the materials "Advanced" options. Material is using the shader "URP/SimpleLit" with its Albedo set to the sprite texture. So if anyone else runs into this kind of lighting problem in their projects "GPU Instancing" might be why the lighting is acting weird.
Your answer
![](https://koobas.hobune.stream/wayback/20220613003547im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Render sprite only on top of a specific sorting layer 1 Answer
2d lighting effect 1 Answer
Unity 2D blur lit shader 0 Answers
Outline set of tiled sprites 0 Answers
Screen Depth giving me artifacts in Intersection Shader. 1 Answer