• Create Account

### #ActualAshaman73

Posted 16 October 2012 - 12:46 AM

Right now I'm putting nx and ny into r and g, and it would be nice if I could put (linear depth)*(sign(nz)) into b and a.

I'm excatly doing this with a very simple encoding/decoding without any problem:

encoding: [depth=0..1]
scaled_depth = depth*2048.0;
result.x = floor(scaled_depth);
result.y = fract(scaled_depth);

decoding:
result = dot(encoded_depth.xy, vec2(1.0/2048.0,1.0));


A standard depth/stencil buffer have only 24 bits too, so this works for me for lightning, particle depth tests etc.

PS: a fast decoding could be useful too

### #1Ashaman73

Posted 16 October 2012 - 12:44 AM

Right now I'm putting nx and ny into r and g, and it would be nice if I could put (linear depth)*(sign(nz)) into b and a.

I'm excatly doing this with a very simple encoding/decoding without any problem:

encoding: [depth=0..1]
scaled_depth = depth*2048.0;
result.x = floor(scaled_depth);
result.y = fract(scaled_depth);

decoding:
result = dot(encoded_depth.xy, vec2(1.0/2048.0,1.0));


A standard depth/stencil buffer have only 24 bits too, so this works for me for lightning, particle depth tests etc.

PARTNERS