Drake
Drake C++ Documentation
ClippingRange Class Reference

Detailed Description

Defines the near and far clipping planes for frustum-based (OpenGL) RenderEngine cameras.

Guidance on selecting clipping plane values

This documentation is targeted toward those who are unfamiliar with the OpenGL rasterization pipeline. For in-depth explanations about how the clipping range defines the viewing volume, see the discussion on projective transforms. For more detail on its effect on determining occlusion (which geometries are in front), try "A Hidden-Surface Removal Survival Kit".

The short summary

  • The clipping range defines the distance of the closest and farthest things that can appear in the rendering.
  • Objects that cross the planes placed at those distances get clipped.
  • Make the range as small as reasonably possible to get the best occlusion (a.k.a. z-buffer) results.
  • For depth cameras, make sure your clipping range always includes your valid depth range.

The longer discussion

Given that the clipping range defines what you can/can't see in the camera, it might be tempting to just put an arbitrarily large range in (e.g., starting 1 micrometer away and going up to 1 million kilometers away). By doing so, you know everything you put into your scene will appear. If making sure things are visible were the only factor, this would be fine.

Rasterization pipelines render objects in arbitrary order but have to be able to determine which objects are in front of other objects as they go. They achieve this by creating a "z-buffer". It is a measure of the depth of the triangle that rendered to a particular "pixel". When two triangles both want to color the same pixel, the triangle with the smallest z-value is typically selected.

The z-buffer has fixed precision. That fixed precision is spread over the entire available depth range (as defined by the clipping range). The greater the range, the less precision the z-buffer has per meter of depth. A small range may have the ability to distinguish objects separated by 1 mm. But a large range may only be able to distinuish objects separated by 1 m. Two objects with measurably different depths relative to the camera, can become indistinguishable in the z-buffer due to these precision issues; the object that ends up in front is due to random chance. This will lead to artifacts where two objects near the same depth will flicker back and forth in front of each other (sometimes called "z fighting").

So, it is best to define the smallest clipping range that will include the objects of the scene that you care about most.

#include <drake/geometry/render/render_camera.h>

Public Member Functions

 ClippingRange (double near, double far)
 Constructs the ClippingRange. More...
 
double near () const
 
double far () const
 
Implements CopyConstructible, CopyAssignable, MoveConstructible, MoveAssignable
 ClippingRange (const ClippingRange &)=default
 
ClippingRangeoperator= (const ClippingRange &)=default
 
 ClippingRange (ClippingRange &&)=default
 
ClippingRangeoperator= (ClippingRange &&)=default
 

Constructor & Destructor Documentation

◆ ClippingRange() [1/3]

ClippingRange ( const ClippingRange )
default

◆ ClippingRange() [2/3]

ClippingRange ( ClippingRange &&  )
default

◆ ClippingRange() [3/3]

ClippingRange ( double  near,
double  far 
)

Constructs the ClippingRange.

Exceptions
std::exceptionif either value isn't finite and positive, or if near >= far.

Member Function Documentation

◆ far()

double far ( ) const

◆ near()

double near ( ) const

◆ operator=() [1/2]

ClippingRange& operator= ( const ClippingRange )
default

◆ operator=() [2/2]

ClippingRange& operator= ( ClippingRange &&  )
default

The documentation for this class was generated from the following file: