Getting Started

π

Community-Contributions

Developer Tools

1st Generation Looking Glass Interfaces

Software Licenses & Code Redemptions

Legacy Products

Camera

The goal with the camera is to emulate what the human eye would see if the 3D scene were real in physical space. The easiest way to think of this is imagining that the screen at the base of the Looking Glass were a window pane: a flat rectangular portal through which we're viewing the 3D objects.

Field of View

The 8.9" Looking Glass screen is roughly 4.75" vertically. If we assume the average viewing distance for a user sitting at their desk is about 36", our field of view should be about 14Β°. There is no correct answer, as it all depends on your expected user's distance from the Looking Glass, but we've found the most success using this figure.

FOV

View Cone

The Looking Glass has a valid viewing angle of about 40-50Β° total, or 20-25Β° in each direction from center. Due to refractive properties of the glass itself, the digital view angle that we find that renders best is 35Β°. We emulate this in software by starting our view rendering -17.5Β° from center and moving to +17.5Β° from center.

View Cone

The most intuitive approach to this might be to choose a pivot point and let the camera revolve 35Β° around it, but that produces an effect called **toe-in**, which is not what we want. Remember the window pane analogy: if there were a window grill at the same depth as the screen, we'd want it to be drawn flat on the screen from all viewing angles, not rotated from the sides.

ββ

ββ

Offset

Toe-in

Frustum

To achieve this, we want to move the camera horizontally (change the view matrix) and shift the frustum in the opposing direction (change the projection matrix). We also want to keep the near clipping plane close to emulating the real depth of the Looking Glass; it's okay to let it come forward a little bit, but it quickly becomes unbearable if it's too far out. For the far clipping plane, we can get away with a little more recess, because the difference between each view is less intense way out back.

Frustums

The focal plane, or zero parallax plane, is where all the views converge. This virtual plane is analogous to the physical screen at the base of the Looking Glass. When framing subject matter to be displayed in the Looking Glass, it's best to center it within this focal plane, because that's where the subject will appear as crisp and in focus as possible.

Offset

It's important to keep that in mind when choosing an approach to positioning the camera and calculating offset. There are a number of values that are determined by one another, so we want to be able to control the most useful values, and let the rest be determined -- the most useful being the camera size and focal plane position. The FOV was already set previously, based on our imagined average user distance.

Camera Offset

Given a value Camera Size (which is the vertical radius of the focal plane), the FOV, and the center position of the focal plane, we can determine how far back the camera should be positioned locally on the z axis. Once we know that, we can also determine what the offset should be, given the offset angle for each view.

The code would look something like this:

1

// set up the camera with the view and the shader of the rendering object

2

void HoloPlayContext::setupVirtualCameraForView(int currentViewIndex, glm::mat4 currentViewMatrix) {

3

// field of view is always 14 according to measurement

4

const float fov = glm::radians(14.0f);

5

// calculate the camera distance, which is actually static when camera size keeps the same

6

float cameraDistance = -cameraSize / tan(fov / 2.0f);

7

// start at -viewCone * 0.5 and go up to viewCone * 0.5

8

float offsetAngle = (currentViewIndex / (qs_totalViews - 1.0f) - 0.5f) * glm::radians(viewCone);

9

// calculate offset

10

float offset = cameraDistance * tan(offsetAngle);

11

// calculate the offset that the camera should move

12

// move the camera by offset and camera distance at x and z direction

13

viewMatrix = glm::translate(currentViewMatrix, glm::vec3(offset, 0.0f, cameraDistance));

14

float aspectRatio = getWindowRatio();

15

// main projection is always the same

16

projectionMatrix = glm::perspective(fov, aspectRatio, 0.1f, 100.0f);

17

// changes the projection matrix to be parallel

18

projectionMatrix[2][0] += offset / (cameraSize * aspectRatio);

19

}

Copied!

Feel free to experiment and adapt this approach to your project's needs!

Last modified 1yr ago

Copy link