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

opengl scale

Started by fenghus Jul 20, 2003 at 9:43 AM 0 replies 1.1k views
Original Post
fenghus
fenghus
Hi! I''m having some trouble getting the size/scale of everything right. So far i''ve just been winging it, but when adding a gun model to my FPS view, it seems i need to make the gun huge in order not to clip it to early in Z. I''m aware that I can change the near clipping plane distance (i''m using gluPerspective()) but lowering it too much gives me z-fighting where my water meets land. So, my question is; does anyone have a good figure for opengl units / meter and gluPerspective settings to match? Or, is it impossible to get good Z-values for both large landscapes AND very close objects, such as FPS holding a gun - do I need to use different z-settings when rendering close objects somehow?
Brother Bob
Brother Bob
Draw your scene in two passes and with two near and far clip plane setups. Far away clip planes for the landscape and close clip planes for objects close to you (like the gun in your hand). Then use glDepthRange to split the depth buffer values for the different ranges.

For example, the landscape could be drawn with near=1 meter and far=1000 meter, mapping the values the range [0.1, 1] in the depth buffer (glDepthRange(0.1, 1)), and then set near=0.01 meter and far=1 meter and map it to the range [0, 0.1] (glDepthRange(0, 0.1)).

Topic Locked

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

Sign in to reply to this topic.