Skip to main content
GameDev.net gamedev.net
🔒 Locked

Z Buffer Range

Started by Dr Pain Dec 8, 2002 at 12:47 PM 0 replies 600+ views
Original Post
Dr Pain
Dr Pain
Is it possible to specify the Z-buffer range to be -1.0 to 1.0, instead of the default 0.0 to 1.0, and if so, how? I need to do this in order to use some camera routines that are generic between DirectX and OpenGL. Also, are there any consequences of going from -1.0 to 1.0 that I should be aware of? Thanks, Dave
S1CA
S1CA
You **might** have success with setting the new range in the viewport structure passed to IDirect3DDevice*::SetViewport().

A simple alternative would surely be to alter the OpenGL style projection matrix just before it gets passed to D3D so that the post projection Z coordinates are in the range used by D3Ds clipper (0 to 1).

The driver on a T&L chip is very likely to be doing this for one of the APIs anyway (i.e. the clipper in the chip will either take D3D *or* OpenGL style Z ranges and the driver will alter the passed matrix accordingly).

Your code probably needs to alter matrices anyway to convert handedness and cope with OpenGL using "modelview" versus D3D separating the matrices etc...


Try either on the Reference Rasteriser, if the clipping is all screwed up, it won''t work on most hardware, otherwise it probably will.

--
Simon O''Connor
Creative Asylum Ltd
www.creative-asylum.com
Simon O'Connor | Technical Director (Newcastle) Lockwood Publishing | LinkedIn | Personal site

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.