Bump/normal mapping in an unlit shader? Is it possible?

Hello, I have seen other posts with this question and the usual response is why would you do that, just use a surface shader . I am working on a mobile project that requires the maximum performance, we can make any shader we want as long as it’s single-pass & unlit, oh and we can’t use any lights. (it’s like game dev in the 90’s :)) I have also been asked to create realistic water. With lots of research I have created a decent texture distortion UV flow map in an unlit shader, but the key ingredient for realistic water is light reflection via an animated normal map. When learning shaders I remember making self-illuminating unlit shaders, faking the diffused lighting on surfaces using dot products and matrices, very tedious. I was thinking about going down that route, but I don’t even know if I can connect that to a bump map, or even how that would work. Does anyone have any advice on faking a reflected light on a normal or bump map?

That doesn’t work by definition – a normal map modifies the way the surface reacts to light, and if there’s no light, there’s no reacting to it. The most basic shading equation is “N dot L” – that is, the dot product of the surface direction (N) and the light direction (L) gives you the intensity of the light. A bump/normal map lets you vary the surface direction across a flat surface (eg a single triangle) using a texture.

However, you can certainly fake a directional light. Just pick some arbitrary direction that the sun is shining from for your light vector.

2 Likes

You should ask yourself what is a “lit” vs “unlit” shader at their core?

In my mind, as soon as you added code to do a dot product between the surface normal and a direction vector, you’ve written a lit shader. It might not use Unity’s lighting systems, but it’s still lit. All those dot products and tedious matrices, that’s what you need to do normal maps too.

As for how to do it, Unity’s documentation has some simple examples of how to do normal maps.

I might suggest just taking the “Unlit/SkyReflection Per Pixel” shader, and using your own cubemap with the sun visible and no more if you’re trying for maximum performance. Though I’d be concerned about your flow map setup as those can be quite expensive on mobile. Sometimes a flipbook and maybe some UV panning / warping can get you pretty far.

2 Likes