Compact Normal Storage for small G-Buffers

非常好的总结了deferred shading下normal压缩的方式,

GPU performance comparison in a single table:

  #1: X & Y #3: Spherical #4: Spheremap #7: Stereo #8: PPView
Encoding, GPU cycles
Radeon HD2400 1.00 17.00 3.00 4.00 11.00    
Radeon HD5870 0.50 0.95 0.50 0.50 0.80    
GeForce 6200 1.00 12.00 4.00 2.00 12.00    
GeForce 8800 7.00 43.00 12.00 12.00 24.00    
Decoding, GPU cycles
Radeon HD2400 1.00 17.00 3.00 4.00 11.00    
Radeon HD5870 0.50 0.95 0.50 1.00 0.80    
GeForce 6200 4.00 7.00 6.00 4.00 12.00    
GeForce 8800 15.00 23.00 15.00 12.00 29.00    
Encoding, D3D ALU+TEX instruction slots
SM3.0 1 26 4 5 17    
Decoding, D3D ALU+TEX instruction slots
SM3.0 8 18 9 8 22    

Quality Comparison

Quality comparison in a single table. PSNR based, higher numbers are better.

Method PSNR, dB
#1: X & Y 18.629
#3: Spherical 42.042
#4: Spheremap 48.071
#7: Stereographic 44.147
#8: Per pixel view 38.730

最后是crytek所采用的sphere map为最好

代码为:

half2 encode (half3 n, float3 view)

{

half2 enc = normalize(n.xy) * (sqrt(-n.z*0.5+0.5));

enc = enc*0.5+0.5;

return enc;

}

half3 decode (half4 enc, float3 view)

{

half4 nn = enc*half4(2,2,0,0) + half4(-1,-1,1,-1);

half l = dot(nn.xyz,-nn.xyw);

nn.z = l;

nn.xy *= sqrt(l);

return nn.xyz * 2 + half3(0,0,-1);

}

你可能感兴趣的:(Compact Normal Storage for small G-Buffers)