# Generating blue normal map channel from red and green channels

I have a normal map texture where the blue channel is used to store some other map of information since it is normally used in a program which calculates the blue channel from the red and green channel automatically. Now I want to use that same texture in Blender and figured it shouldn't be too hard to do the math in the node editor so it jus works regardless of which normal map I use. However, it doesn't seem to work. The result I get has shading issues quite similar to how it looks without any information in the blue channel. This is despite me having found the formula and I believe created it accurately in the node editor. Does anyone have any idea why this wouldn't create the desired results?

The formula I found to generate the blue channel is "B = sqrt(1 - ((R * R) + (G * G)))" • Blender uses OpenGL format for normal maps. Maybe you need to invert the green channel? – Jackdaw Aug 9 '19 at 4:25
• Also... the texture node should be set to use Linear or Non-Color Color Space. – Jackdaw Aug 9 '19 at 4:46
• In case somebody wonders why you can drop the blue channel: If it's a tangent space normal map it only stores vectors in the hemisphere with a positive Z component. Since we also know that it's a unit vector, we can retrieve the Z component by subtracting the squared components of X and Y from 1, because we know the unit vector has a magnitude of 1. sqrt(X^2+Y^2+Z^2)=1 can be transformed to Z=sqrt(1-X^2+Y^2). This trick doesn't work for object space normals because they store the full unit sphere. That's the point I missed when I wrote my answer late at night :) – Robert Gützkow Aug 9 '19 at 6:36
• Thanks for the suggestions guys. I changed the color space to Non-Color which changed the result a bit but still doesn't look how it should. The engine these normal maps are used in is OpenGL so shouldn't have to invert the green channel. I tried anyway but didn't fix it. – Karl Høybye Aug 9 '19 at 17:05