hi all!
I’ve got a question: what does the texture type normal does? i need to use a normal without this set, but inside the shader the result is too different…
seems that the rgb channels o fa texture type normal are all the same…
Setting normal changes the texture to be linear (Bypass sRGB) and swizzles the color channels.
DTXnm is a DTX5 texture with the red channel of the normal map stored in the alpha channel of the texture and the red and blue channels blacked out. The green channel of the normal map remains as the green channel of the texture.
You can use an uncompressed RGBA with that same layout and it should work.
If you’re doing mobile, or a platform that doesn’t support DXTC textures they’re left unmodified in their RGB layout.
thanks @bgolus !
now it’s all more clear!
and a question: is there a way to avoid the message that unity tells that the normal map is not tagged with normal texture?
If you’re using built in shaders, not that I know of, no. If you’re using custom shaders just don’t add [normal] before the texture property definition. It’s only purpose is to give that warning.
Hey, I have one question.
I’ve tryed do this
float3 tex = tex2D (_NormTex, IN.uv_MainTex);
o.Normal = UnpackScaleNormal(fixed4(0, tex.g, 0, tex.r), _NormalPower);
But result is not the same with usual normalmap.
Only when I adding tex.b in red channel it will be close
o.Normal = UnpackScaleNormal(fixed4(tex.b, tex.g, 0, tex.r), _NormalPower);
So. I would like to know is it right way or maybe I’me doing something wrong))
Why are you doing this swizzle? What platform are you running? What version of Unity? Are you using a custom packed normal map texture?
The swizzle is correct if you’re using a normal map texture that is not set to import as a normal map and the platform is desktop or console. However as of 2017.1 or so they added support for BC5 normals, which is a two channel compressed texture format. To support that with out changing every shader they used a trick I think I first saw from Insomniac back in 2005 or so. That trick is to use both the red channel and the alpha channel when unpacking by multiplying then together.
Try: fixed4(1.0, tex.g, 0.0, tex.a)
using 2017.20f3. I would like to put my own data in 2 channels. So I have only 2 channels for nomalmap information)
for pc, texture type: default. also I put all textures in texture2DArrays
Don’t fully understood what information I should put in tex.a and where tex.r in this expression?
Sorry, that should have been:
fixed4(1.0, tex.g, 0.0, tex.r);
The only change to what you have is setting the first component to 1.0.
Personally I would just skip using the built in UnpackScaleNormal function and write your own version to ensure its unpacking correctly.