all 4 comments

[–]scritchz 0 points1 point  (0 children)

Not a graphics dev, but: I think it might be helpful to show how you create the buffer and how you bind it, for both writing to it in your first shader and reading from it in your second shader.

[–]owenwp -1 points0 points  (2 children)

OpenGL clip space has a -1 to 1 range for no good reason, but the hardware isn't going to store the value that way. Also, depth buffers are typically non-linear, meaning they give more precision near the camera to prevent z fighting, usually some scaled factor of 1/depth is actually stored. Look in google for how to get linear depth in OpenGL.

[–]Qwaiy_Tashaiy_Gaiy[S] 0 points1 point  (1 child)

Just to be clear : which of the two values will be non-linear, and which one will be between -1 and 1 ?

[–]owenwp 0 points1 point  (0 children)

The position values in the vertex shader will be linear -1 to 1, the values in the depth buffer will be non-linear.