184 12.AGenericMultiviewRenderingEngineArchitecture
Figure 12.5. Overview of the multiview rendering architecture.
multiview components support the same number of views. As shown in Fig-
ure 12.5, the scene is first rendered multiple times after activating a specific cam-
era view and a specific view buffer target. This generates the rendering content to
be used by the attached multiview compositor, which outputs its result to the re-
gion of the rendered viewport. The last step is performed by the operating sys-
tem, which swaps the final frame buffer holding the multiview content to be
shown on the target displays.
The sample code provided in Listing 12.1 can add full support for anaglyph-
based stereo-view rendering using our architecture without any other modifica-
tions to the application code.
CameraStereoView& camera(CameraStereoView::create(*camNode));
// Set standard parameters.
// (aspect ratio, far-near dist., field-of-view, etc.)
camera.setEyeSeparation(0.3); // stereo-specific
camera.setFocalDistance(25.0); // stereo-specific
MVBuffer_Cfg mvbParams;
mvbParams.viewCount = 2;
mvbParams.type = MVBufferType_Offtarget;
mvbParams.offtarget.colorFormat = ImageFormat_RGBA;
mvbParams.offtarget.sharedDepthStencilTargets = true;
mvbParams.offtarget.sharedFrameBuffer = true;
Scene
data
Target
3D
displays
Multiview
camera
Multiview
buffer
Multiview
compositor
Render
12.4TheMultiviewCamera 185
// Attach the components to viewport.
RSys.getViewport(0)->mCamera = &camera;
RSys.getViewport(0)->attachMVCompositor(new MVC_Anaglyph);
RSys.getViewport(0)->attachMVBuffer(new MultiViewBuffer, mvbParams);
Listing 12.1. Setting up a basic multiview rendering pipeline in an application.
12.4TheMultiviewCamera
Multiview rendering requires each of the views to be rendered with view offset
parameters, so that the eyes can receive the correct 3D images. To ease the con-
trol of cameras in multiview configurations, our architecture provides a mul-
tiview camera concept that is integrated into our basic multiview rendering
pipeline.
To be able to easily manipulate cameras within a generic multiview architec-
ture, we define a single interface, the multiview camera. This interface allows for
specialization of different configurations through class inheritance. Implementa-
tions can integrate most of the multiview-specific functionality (e.g., activating a
specific view) in a generic camera class, and single-view cameras can therefore
be treated as simple multiview cameras.
As usual, the camera object is used to identify view and projection transfor-
mation matrices that are applied to 3D mesh vertices. The view matrix depends
on both the camera position and the multiview camera parameters that offset the
view position from a reference camera transformation. The same approach ap-
plies to the projection matrix—both basic intrinsic parameters (such as field of
view, near and far clip plane distances, and aspect ratio) and multiview configu-
ration parameters (such as focal length) can affect the final result.
In our design, a single multiview camera object aims to reflect a group of
perspective-projection cameras. Each view is rendered using perspective projec-
tion, which implies that the multiview camera has the properties of a perspective
camera and can thus inherit from a perspective camera component, as shown in
Listing 12.2. Intuitively, in multiview configurations, one wants to be able to
control a single camera object that would internally calculate all view-specific
parameters with respect to the base camera position and orientation. The view-
specific perspective projection and view transformation are generated using an
active view number, and this active view number needs to be automatically man-
aged by the main renderer. Internal camera parameters are specified by extending
the multiview camera interface and defining the required parameters that affect
the view and projection matrix setup.
186 12.AGenericMultiviewRenderingEngineArchitecture
Also, each specific multiview camera implementation can define a single
bounding volume to be used for one-time object culling over all views. The actu-
al geometry covered inside a multiview volume is likely to be nonconvex, which
can make precise intersection tests with the scene bounding volumes computa-
tionally less efficient. To set a single, shared culling frustum for a multiview
camera, a larger frustum that covers the multiview volume needs to be set up.
The corners of a suitable approximation for an extended multiview culling frus-
tum can be composed from the outermost corners of each view-specific frustum.
// Base camera interface provides basic multiview operations.
class Camera
{
public:
// Get/set aspect ratio, near-far distance, field of view, etc.
virtual uchar getViewCount() const; // returns 1 as default
virtual void setActiveView(uchar viewIndex); // default no-op
virtual const Matrix4& getViewMatrix() const;
const Matrix4& getProjectionMatrix() const;
const BoundingVolume& getFrustum() const;
protected:
mutable Matrix4 mProjMatrix_Cache;
mutable BoundingVolume mFrustum_Cache;
bool mProjMatrixMatrix_dirty, mFrustum_dirty;
virtual void updateProjMatrix() const = 0;
virtual void updateFrustum() const = 0;
};
class CameraPerspective : public Camera
{
...
};
class CameraMultiView : public CameraPerspective
{
public:
12.4TheMultiviewCamera 187
void setActiveView(size_t viewIndex);
protected:
uchar mActiveView;
};
class CameraStereoView : public CameraMultiView
{
public:
// Set/get focal distance and eye separation.
const Matrix4& getViewMatrix() const;
protected:
float mFocalDistance, mEyeSeparation;
void updateProjectionMatrix() const;
};
Listing 12.2. Projection and view matrix management for stereo rendering.
The remainder of this section focuses on the special case of stereo cameras
and describes the basic parameters that can allow easy and intuitive manipulation
of the camera matrices. The concepts described in this section can be extended to
multiview configurations that require more views.
As shown in Figure 12.6, different approaches can be applied when creating
stereo image pairs. In the figure, d denotes the separation between the eyes. Par-
allel and oriented frustums use the basic symmetrical perspective projection setup
for each view and offset the individual camera positions (and the camera orienta-
tions, in the oriented frustum case). The skewed frustum approach modifies the
perspective projection matrix instead of updating the camera orientation, so the
two image planes are parallel to the zero-parallax plane.
The camera view position offset depends on the right direction vector of the
base multiview camera and the d
parameter. If the base camera is assumed to be
in the middle of the individual view points, the offset distance is simply
2
d for
each view. To generate skewed frustum projection pairs, assuming that the frus-
tum can be specified with left-right, bottom-top, and near-far values, as is done
188 12.AGenericMultiviewRenderingEngineArchitecture
Figure 12.6. Basic approaches for setting up stereo camera projection frustum pairs.
for the OpenGL function glFrustum(), only the left and right values need to be
modified. The offset
Δ
x
for these values can be calculated using the formula
Δ
2
dn
x
f
,
where n is the distance to the near plane, and f is the focal distance. Note that the
projection skew offset
Δ
x
is added for the right camera and subtracted for the left
camera.
Figure 12.7 shows a simple diagram that can be used to derive the relation-
ship among the angle shift s, the eye separation d, half field-of-view angle
, and
the focal distance f. By using trigonometric relationships and the fact that lines
intersect at the point
p in the figure, the following equation can be derived:

22
2
1tan tan
2tan 1 tan
d θ s
f
s θ
.
As expected, a smaller angle shift s results in a larger focal distance, and the eye
separation parameter d affects the focal distance linearly.
Figure 12.7. Derivation of the relationship between the angle shift s, the eye separation d,
and the focal distance f.
Right
d
Right
d
Right
d
Parallel frustums (no focal distance) Oriented frustums Skewed (asymmetric) frustums
focal distancefocal distance
z
x
2
d
2
d
p
f
θ s
θ s
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset