SetViewport MinZ and MaxZ problem

Started by
1 comment, last by Talisman 22 years, 8 months ago
Hi, I want to use MinZ ans MaxZ in SetViewport function to render a polygon which will clear the z-buffer with the value I want, by setting MinZ ans MaxZ to this value. The SetViewport call works and a call to GetViewport tell me that paramaters are the good ones. But on screen, nothing change, as if MinZ = 0.0 and MaxZ = 1.0. I use the same technique in OpengL with glDepthRange and it works perfectly. Is this a DirectX bug ? a wrong render state ? ... Eric
Advertisement
Instead of rendering a polygon to clear the z buffer, why don't you just... clear the z buffer?

pDevice->Clear(0, NULL, D3DCLEAR_ZBUFFER, 0, MyNewValue, 0);

I don't think SetViewport renders anything or changes the current buffer contents (if I understand you correctly), it justs sets up the device for subsequent rendering. (it's been awhile, but I think SetViewport in OpenGL does more under the hood than in DX8)

In both OpenGL and DX, calling clear is much more efficient than rendering a rectangle if you are actually just clearing.

Edited by - CrazedGenius on August 7, 2001 10:25:04 AM
Author, "Real Time Rendering Tricks and Techniques in DirectX", "Focus on Curves and Surfaces", A third book on advanced lighting and materials
I am agree that clear the z buffer is more efficient but the region to clear is not a rectangle, it is a surface generated by the projection of a striped polygon.
SetViewport change the projection matrix and the viewport matrix. If Minz and Maxz = 1.0, then, z value after projection which is between -1.0 and 1.0 will be transform between 1.0 and 1.0 so 1.0 for the final value, the one which will be written in the z buffer. That''s what happen in OpenGL but not in DirectX. The value written in the z buffer apear to be in the range 0.0, 1.0. :-(

This topic is closed to new replies.

Advertisement