Handy fragment shader "trick" splitting / storing results exceeding 8-bits in multiple 8-bit color channels ( when rendering to a signed 32-bit RGBA RenderTarget ). Example illustrates the concept of storing a 16-bit depth map in 2 channels.
Code: Select all
void main()
{
int depth = gl_FragCoord.w*65536;
int byte1 = depth/256;
int byte2 = depth-byte1*256;
gl_FragColor = vec4(byte1/256.0,byte2/256.0,0.0,1.0);
}
8-bit : Way too little
16-bit : Usually sufficient
24-bit : More then enough
32-bit : Overkill
K