Jump to content
  • Advertisement
Sign in to follow this  
Icebraker

OpenGL Linear z-values in OpenGL?

This topic is 4309 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello everybody, I have a question concerning the depthvalues in OpenGL : Is there a mode which allows me to use linear depth-values instead of the standard non-linear? Thx, Icebraker

Share this post


Link to post
Share on other sites
Advertisement
You can use a vertex shader to get W-Buffering (which results in Z-Buffering).
There is an article for DirectX (MVP site) about linear (sp) Z values which uses the W buffer.

I'm not at my normal computer, so I don't have the link ready.

[EDIT] Quick google found it:
http://www.mvps.org/directx/articles/using_w-buffers.htm

I have successfully used that in OpenGL in the past.

Share this post


Link to post
Share on other sites
Thx a lot for your reply. This is the sort of thing I am looking for. Unfortunately, the commands are for direct3D, but I'm using OpenGL. Does anybody know the OpenGL commands to turn off the non-linear z-value?

Thx

Share this post


Link to post
Share on other sites
Quote:
Original post by Icebraker
Thx a lot for your reply. This is the sort of thing I am looking for. Unfortunately, the commands are for direct3D, but I'm using OpenGL. Does anybody know the OpenGL commands to turn off the non-linear z-value?

Thx

I think you missed the point.

There aren't "commands" to turn it off.
You need to do a bit of math to change the non-linearity to linearity (is that a word?).

The math is the same.

I'll post the vertex shader code when I get home.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!