Liam
Liam

Reputation: 20970

Multiple view frustum clipping

The function gluPerspective() can be used to set near Z and far Z clipping planes.

I want to draw a scene clipped at a certain far Z plane, and draw another scene beyond this Z plane. Is it possible to do this clipping twice per frame?

Upvotes: 2

Views: 1126

Answers (3)

rotoglup
rotoglup

Reputation: 5283

A possibility is to assign different depth ranges for the scenes. Some pseudo code would be :

  glDepthRange(0.5, 1.0)
  draw_far_scene
  glDepthRange(0.0, 0.5)
  draw_near_scene

You have to setup your projection matrices to perform the proper clipping for the near / far scenes.

The depth ranges assignment is needed to prevent the depth buffer to 'merge' both renderings.

Upvotes: 1

epatel
epatel

Reputation: 46051

You might need to do a draw the farthest scene first and do a glClear(GL_DEPTH_BUFFER_BIT); before you draw the nearest scene.

Upvotes: 1

shoosh
shoosh

Reputation: 79021

There's no reason you shouldn't be able to do this.

Simply setup the first perspective, draw the first scene and then setup the second perspective and draw the seconds scene, all within the drawing of the same frame.
This is generally referred to as multi-pass rendering.

Upvotes: 1

Related Questions