Normal maps turn red with DirectX 11 enabled

alt text

For some reason when I enable Use Direct3D 11 in the Player settings this happens. There’s nothing unusual with the map, it’s just a normal map with the Texture Type set to Normal map. No idea what could be wrong here :frowning:

I tried searching but I haven’t seen anything like this issue.

Edit: Furthermore I found that this is a problem in the shader and not just import settings. I use

UnpackNormal(tex2D(_Normal, TRANSFORM_TEX(i.uv0.rg, _Normal)))

and without any texture plugged in it shows the correct color. Weirdly as soon as I add a texture it turns all red, even if I set my texture to not be a normal map (if I do this the texture appears correct in the preview unlike the original image I posted). I’ve linked an image of this
right here.

I’ve solved this, sort of.

In place of UnpackNormal I did the conversion on my own. This appears correct on the mesh even when the Texture Type is set to Normal map (appearing that red color in the preview window) and with it set to Advanced and bypassing sRGB (where it appears the correct 8080ff normal color) as the other images I posted show.

				fixed3 normalLocal = tex2D(_Normal, TRANSFORM_TEX(i.uv0.rg, _Normal));
				normalLocal.rg = normalLocal.rg * 2 - 1;

When Unity shows the preview of the normal map it must be showing it with UnpackNormal being used or something. Here’s why it doesnt work:

inline fixed3 UnpackNormalDXT5nm (fixed4 packednormal)
{
	fixed3 normal;
	normal.xy = packednormal.wy * 2 - 1;
	return normal;
}

This is apparently called by UnpackNormal and pulls the alpha channel from the normal map rather than the red channel, and sets that to the red channel. This is really strange, like Unity isn’t handling compression settings correctly with DX11 for some reason. This is beyond my knowledge though and I didn’t find any compression settings that worked. For thoroughness here’s the results using my conversion. First is the local normals. You can see the preview still looks wrong. The second is an NdotL, looks fine!
alt text
alt text