Skip to content

Rendering internals

Christian Schlinkmann edited this page Mar 31, 2016 · 5 revisions

Clipping Planes of the Camera

The near and far planes of the camera are set dynamically according to the scene dimensions. Other frustum planes are derived from the position, orientation and fieldOfView (horizontal) of the active <view> and the aspect ratio of the <xml3d> element.

Frustum Culling

Objects in the scene are culled based on their axis-aligned bounding box. The box is calculated from the positions of the vertices, however a bounding box can also be supplied manually:

<float3 name="boundingBox">-10 -20 -30 20 20 20</float>

The bounding box should be given in object space. This can be useful for large objects with changing mesh data, since the bounding box would be re-calculated each time the mesh changes.

It's also useful for meshes that are deformed by a vertex shader (eg. a shader that extrudes the vertices of a mesh some distance along an axis) because the bounding box that XML3D generates would no longer match the rendered object. This can lead to improper frustum culling and broken mouse interaction.

If Frustum Culling is not desired it can be deactivated globally via the options interface:

XML3D.options.setValue("renderer-frustum-culling", false);
Clone this wiki locally