glPolygonOffset and GLSL

Hi,

I have a large outdoor scene where i use the logarithmic depth buffer method described here:

http://outerra.blogspot.com/2009/08/logarithmic-z-buffer.html

This works nicely and my depth precision is extremely good. However, I need to render some runways with runway markings, and for this I have used glPolygonOffset. Now, it appears that when I write to the gl_FragDepth in the shader, the glPolygonOffset is disabled.

Is there any way to read out the offset values in the shader? Any built-in uniforms or similar?

This z-buffer method is implemented in all my material shaders, and I would rather not have to define this as a new uniform variable in all my various shaders.

Any idea how to fix this?

Now, it appears that when I write to the gl_FragDepth in the shader, the glPolygonOffset is disabled.

Of course it does. glPolygonOffset changes what the computed depth is. If you’re overriding the computed depth, it will have no effect.

Is there any way to read out the offset values in the shader?

Not for polygon offsetting. You could pass the offset values to the shader and use shader logic to compute the offset for your computed depth, though.

I understand that, but I kind of hoped that the offset parameters would be passed as global uniforms like many other parameters from the fixed function pipeline.

Adding these parameters as shader uniforms will be difficult in my engine, but I guess I can (mis)use some other global uniform, such as a random clip plane or fog parameters or something.