Blending in Detail几种方式的总结

Secondary Maps 又叫Blending in Detail
几种不同的NormalMap叠加方案

1 错误的叠加方案:
Blending in Detail几种方式的总结

float3 n1 = tex2D(texBase,   uv).xyz*2 - 1;
float3 n2 = tex2D(texDetail, uv).xyz*2 - 1;
float3 r  = normalize(n1 + n2);
return r*0.5 + 0.5;

叠加方案1
Blending in Detail几种方式的总结

float3 n1 = tex2D(texBase,   uv).xyz;
float3 n2 = tex2D(texDetail, uv).xyz;
float3 r  = n1 < 0.5 ? 2*n1*n2 : 1 - 2*(1 - n1)*(1 - n2);
r = normalize(r*2 - 1);
return r*0.5 + 0.5;

叠加方案2
Blending in Detail几种方式的总结

float3 n1 = tex2D(texBase,   uv).xyz*2 - 1;
float3 n2 = tex2D(texDetail, uv).xyz*2 - 1;
float2 pd = n1.xy/n1.z + n2.xy/n2.z; // Add the PDs
float3 r  = normalize(float3(pd, 1));
return r*0.5 + 0.5;

Blending in Detail几种方式的总结

叠加方案3
Blending in Detail几种方式的总结

float3 r = normalize(float3(n1.xy + n2.xy, n1.z*n2.z));

附原文地址:https://blog.selfshadow.com/publications/blending-in-detail/