TransWikia.com

How can I cast light onto a sprite in 3D environment?

Game Development Asked by Vern Rowan on November 2, 2021

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 I’ve got almost nothing. 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.

One Answer

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.

Answered by Vern Rowan on November 2, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP