PDA

View Full Version : Rendering the the back of the z-buffer



kevinhoque
10-18-2002, 01:11 AM
I would like to render a 3d object so that all the zbuffer values generated would corrospond with the back of the z-buffer. I don't have the option of turning off z-buffer writes so any other ideas would be appreciated. In d3d I would simply set the near and far values of the viewport to 1.0 to achieve this effect. Could a modified projection matrix in opengl accomplish the same thing?

Thanks in advance
Kevin

Bob
10-18-2002, 01:40 AM
Not sure I understand what you mean, but try this. It will draw the object as usual, but generate depth values at the far clip plane only.



glDepthRange(1.0, 1.0);

kevinhoque
10-18-2002, 02:00 AM
Cheers Bob. That's precisely what I was after. The odd thing is that until you mentioned it today I hadn't ever noticed this gl function. Shows how much I know!!

Thanks again
Kevin

Kilam Malik
10-18-2002, 04:38 AM
Just an idea I got when reading this... in some games you only want to render to special portions of the screen (e.g. cockpit of a plane is a static picture). Many people tell to accomplish this by rendering the portions of the screen which should be visible to the stencil buffer. Then you render the landscape with a stencil buffer op which only writes where the stencil buffer is 1.

But if I would render my cockpit bitmap with glDepthRange(1.0f, 1.0f), then I could render the landscape afterwards directly without stencilbuffer. But I would have to render the cockpit on a polygon which has the windows as holes...

Should be faster, as you don't need a stencil buffer in the second pass.

Kilam.


[This message has been edited by Kilam Malik (edited 10-18-2002).]