0

What is the most common/simplest/fastest way to depth-test for a certain range?

pass if (currentDepth-offset < newDepth && newDepth < currentDepth)

  • currentDepth := value in the depth buffer
  • offset := constant (know at compile-time and for all fragments the same)
  • newDepth := depth of the fragment

Ideally, the function glDepthFunc(...) would be more flexible.

genpfault
  • 51,148
  • 11
  • 85
  • 139
Fabian
  • 1,982
  • 4
  • 25
  • 35
  • Are you asking about desktop OpenGL or OpenGL ES? They're not the same, you know. – Nicol Bolas Apr 26 '12 at 19:48
  • I'm using OpenGL 4.2. That being said, I follow the OpenGL ES 2.0 way of doing things. So to answer your question: It would be great, if it could be done with OpenGL ES 2.0, but if there is an easier/faster way in OpenGL 4.2, I'll gladly adjust my coding style. – Fabian Apr 26 '12 at 22:27
  • Is "currentDepth-offset" a constant value? Is it some constant + the depth (in window space), is it a constant+depth in camera/eye space, or is it some arbitrary value? – Nicol Bolas Apr 26 '12 at 22:58
  • "currentDepth-offset" is not constant. I'm having the "constant + the depth (in window space)" case. – Fabian Apr 27 '12 at 06:41

1 Answers1

0

Is glPolygonOffset what you're looking for? (Depending on what you want with that offset, of course).

Ani
  • 10,826
  • 3
  • 27
  • 46