I am creating a sprite based game in 3D space (like Hollow Knight did it). I want to use normal maps for my sprites and am using Shader Graph with the URP (3D) for this.
Since I have 2D sprites, in most instances I want them to be lit up from any light source that is close by, no matter whether it is somewhat behind or in front of the sprite. Normal maps however include the Z component as blue color. That means that my sprite will NOT get lit up if the normal map determines that I am lighting the backside of the sprite rather than the front. X and Y (R and G) ignore that of course, still lighting up the sprite regardless of what Z coordinate the light is shining from. The result is what you see in the images I attached. No possible blue value has given me the desired result. It ranges from: “Light up backside” to “Fully dark” to “Light up frontside”, but no “Light up both”.
Here is what it looks like when the lightsource is in front. It’s what you would expect a normal map to look like:
Here is what it looks like when the lightsource is behind the sprite. Only X and Y values are working now, while the Z values are completely dark.
This is the shader graph I used for this:
I want the normal map to be treated equally, regardless of whether the lightsource is in front of behind the sprite.
I figured I could just slightly modify the code of whatever interprets normal maps to think that light is always in front of an object, only caring about the absolute distance…but I after generating code for the shader and seeing an incredibly large amount of seemingly repeating lines of code, I quickly got discouraged. Not that I was able to make any sense of it to begin with.
For sprite-based games in 3D space that use normal maps, this seems like it should be a fairly common problem, yet I could not find anyone talking about it even after many…many hours of google and discord searches. Maybe I have missed something obvious? I am feeling pretty desperate regardless. Any help would be greatly appreciated!



