How do you set up a Normal Map in a fragment shader (3D)?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Geaxle
:warning: Old Version Published before Godot 3 was released.

When trying to use NORMALMAP in a 3D fragment shader I get some weird effect. On a sphere (for a planet) when I load the normal map through the shader I don’t see any visible effect in height, but it makes a weird effect with a curved specular reflection at the poles. If I raise the NORMALMAP_DEPTH, reflection seems to be shifted (west) and I still do not get a sense of height. All this seem to work perfectly if I just use a standard fixed material though.

I made an imgur album to show exaclty what is my issue: Fragment Shader pole view - Album on Imgur

I have also found one other person at least who had the exact same issue as I do: https://www.youtube.com/watch?v=J2-jXHsTvI4

So I am assuming that I am missing something when setting up my material/shader. Is there some options or other specific things I need to do on top of the code? How would you do the exact same thing as the fixed material through code?

(of course this might also just be a bug)

:bust_in_silhouette: Reply From: Geaxle

I went through the code on github to check how the fixed material worked. The solution is:

NORMALMAP = tex(normalMapTexture, UV).xyz * vec3(2.0,2.0,1.0) - vec3(1.0,1.0,0.0); NORMALMAP_DEPTH = normalMapDepth; //float