Skip to main content
GameDev.net gamedev.net
🔒 Locked

Depth issues with deferred rendering

Started by Ruggostein Sep 13, 2010 at 5:30 AM 2 replies 1.1k views
Original Post
Ruggostein
Ruggostein
I'm trying to do a deferred render system that works using only RGB8 render targets. The only problem for now was saving the depth in a way that I could use it later for position reconstruction.

But of course, 8 bits would only allow 255 different Z values, and visualizing the depth buffer shows this, lots of banding.


The depth is stored as
float z = (gl_FragCoord.z/gl_FragCoord.w) / zFar;

Reducing the zFar from 1000 to 100 produced better results, but there should be better solutions.
For the depth reconstruction I need (gl_FragCoord.z/gl_FragCoord.w), as I use the inverted projection matrix method.
But this division yields values in the [0.99 , 1.0] most of the time, and when this is stored to the depth buffer, everything is mapped to 255.

I still have one more G-buffer channel, so what I need is a way to encode (Z/W) in two different channels. This is where I'm blocked. If it were integer values, I would know how to pack a 16-bit value into two 8-bits, but with floating point values, I don't have an idea, anyone knows?
Danny02
Danny02
8 bits a just to less precission for a depth target, why not use a 32bit single channel texture?

that most results are betwen 0.9-1.0 is because the depth is quadratic and not linear
Ruggostein
Ruggostein
I'm avoiding using float textures, as this should run on most hardware with mrt support.
I found this
http://www.ozone3d.net/blogs/lab/20080604/glsl-float-to-rgba8-encoder/

I trying to figure how to modify this to store a float in a vec3 or vec2 instead of vec4.
n00body
n00body
I've tried using that packing code to store depth information, and it always produces artifacts. You need real 16/32-bit int/floats for your RTs to avoid artifacts.

[Hardware:] Falcon Northwest Tiki, Windows 7, Nvidia Geforce GTX 970 [Websites:] Development Blog |

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.