Game Development Community

dev|Pro Game Development Curriculum

Scriptable Near Clipping Plane

by D Robinson · 09/11/2007 (9:39 am) · 2 comments

Download Code File

Torque 1.5.2 has the near clipping plane set at a constant hard-coded 0.1 units. Whereas this may work fine for spacious environments, it can cut off geometry that is very close to the camera. Wouldn't it be nice to be able to adjust it?

This small patch adds a console variable $nearClippingPlane that lets you change the near clipping plane of all cameras to the given value. From the engine, this constant is accessible as Camera::gNearClippingPlane.

It should also be noted that the near clipping plane has a direct affect on Z-buffer precision. As you move the near clipping plane closer, you will see more and more Z-"fighting" in the distance as the precision goes down. Conversely, moving it farther away will give you better Z-buffer precision and produce less Z-"fighting" (but will cut off more objects close to the camera).

Apply this patch to the "engine" folder of your environment. It will affect camera.cc/.h, editTSCtrl.cc, game.cc, guiPlayerView.cc and showTSShape.cc. This is my first attempt at producing a patch file, so please be patient with me if it's not right.

About the author

Recent Blogs


#1
02/17/2008 (3:12 pm)
This looks interesting, but is there a way to get the modifications in anything other than a patch file? Those don't work for Macs, as far as I know.
#2
08/12/2008 (10:24 pm)
good...