Importing Normal Map at Run-time Creates Odd Behavior

I need to be able to import my normal maps at run-time. I have successfully managed to import the data and create and assign the texture. However I am getting unexpected results:

What you’re seeing there is the exact same plane and material except rotated 90 degrees each time. For some reason I’m getting different lighting based on the rotation of the object.

I’ve pasted a small sample of the two texture RGBA values HERE. I’ve copied the red channel over to alpha and nulled the red and blue channel as per some advise elsewhere on the net. If I don’t at least copy the red over to the alpha channel it won’t work at all.

I have confirmed that it is the normal map causing the problem as I can pause my game and replace the imported normal map with one that has been imported through the Unity Editor Importer and it instantly works fine.

Based on the data above it appears that Unity does more than some simple transposing of the data. I’m guessing it regenerates the red and blue channels, but even the red cahnnel is slightly different. I’m fairly confused.

Does the answer to this help?

Hey Jaimi,

Thanks for replying. Unfortunately not - I have used the method there to get normal maps to a state where they are above.

The imported texture that should be used as normal map (the blueish normal maps, not grayscale) has to be ARGB32. The strange behavior with the light comes from incorrect alpha values, they need to be 0.5 for correct lightning.

You have to import PNG’s with exactly half-transparent pixels.