问题描述
我正在尝试压缩法线贴图纹理,所以我正在使用ASTC 4x4.
I am trying to compress my normal map textures, so I am using ASTC 4x4.
它对其他纹理(也称为漫反射)完全有效,但是法线贴图的质量损失太大.
It works completely good for other textures (aka diffuse), but quality lost for normal maps were too big.
有没有一种方法可以直接提高法线贴图的ASTC质量?
Is there a way to improve ASTCs quality directly for Normal Maps ?
我尝试使用-normal-psnr标志,但这会使我的纹理变灰(而不是正常的蓝色)
I have tried to use -normal-psnr flag, but it makes my texture greyed (instead of normal blue)
ASTC法线图:
PNG法线贴图:
推荐答案
在参考编码器中使用正常模式压缩法线贴图会将法线贴图存储为X + Y贴图. X存储在R通道中(并在G和B中重复),而Y存储在A通道中,这就是为什么它看起来是灰色的.您需要在着色器中重建Z.基于完整的法线应该是单位长度这一事实,您不需要存储它,这会使压缩器有更多的位可用来提高质量.
Compressing normal maps using a normal mode in the reference encoder stores normal maps as X+Y maps. X is stored in the R channel (and duplicated in G and B) and Y is stored in the A channel, which is why it looks grey. You need to reconstruct Z in the shader; based on the fact that the full normal should be unit length you don't need to store it which gives the compressor a lot more bits to play with to boost quality.
vec3 normal;
normal.xy = texture(sampler, uv).ra;
normal.z = sqrt(1 - dot(normal.xy, normal.xy));
我倾向于使用5x5块(5.12bpp)的法线看起来不错,但是比这低得多的比特率会引发质量问题.
I tend to find normals look OK with 5x5 blocks (5.12bpp), but much lower bitrate than that starts to hit quality problems.
这篇关于法线贴图的ASTC的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!