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

Discussion in 'Shaders' started by danamuise, May 9, 2023.

1. ### danamuise

Joined:
Sep 15, 2022
Posts:
17
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?

2. ### burningmime

Joined:
Jan 25, 2014
Posts:
845
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.

mandisaw and danamuise like this.
3. ### bgolus

Joined:
Dec 7, 2012
Posts:
12,201
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.