# Tag Info

## Hot answers tagged camera

5

Yes, you can use an off-axis projection matrix. This is what I use in my code (note: I shift the centre upwards, not left as you do in your example.) void camera_setAspectRatio(float aspect, float zNear, float zFar, bool offaxis) { // create a projection matrix const float f = 1.0f / tanf(fovy_radians/2.0f); fovx_radians = 2.0f * ...

5

The missing step If you already understand how to generate a secondary ray, then you have already grasped the difficult part. All you need to do now is find the colour that this secondary ray results in. This is exactly the same process as using the primary ray to find a colour, in basic ray tracing. After repeating this for a large number of secondary ...

4

The space at which you transform your vertices is completely up to you, because it depends on what algorithms and kind of effects that you are trying to achieve. As of my personal experience, I usually shoot rays in world space because eventually we all need some sort of "world-space" acceleration data structure, such as a space-partition tree, that gathers ...

3

It depends a little how you construct the matrix. I assume that you use the function perspective_matrix from your library, which actually works pretty much like good old gluPerspective). But what this actually does is nothing else than use the more general function frustum_matrix, which in turn creates a common arbitrary view frustum matrix, like good old ...

3

No, it's not. The way many of the 3D sensors work is by projecting an infrared pattern onto the surface and measuring how it distorts. But with a 2D image, the pattern will simply be projected onto the flat 2D image, not onto the objects in the scene. So the 3D sensor will only sense a flat card. Other methods work by combining 2 images taken with different ...

3

First we can calculate the physical diameter of CoC in the image plane, given the lens parameters. This equation is from Wikipedia – Circle of confusion: $$c = {|S_2 - S_1| \over S_2} {f^2 \over N(S_1 - f)}$$ where the variables are: $c$: the physical CoC diameter in the image plane $S_1$: focal distance (the distance at which a subject would be in ...

2

The problem is that instead of a camera-to-world matrix, a world-to-camera matrix is being made by glm::lookAtRH. This is because GLM is a math library made for OpenGL. In OpenGL, you do not move the 'camera' as there is no camera in OpenGL. You move the whole world the other way around, so that it lines up in the frustum. The lookAtRH method returns a ...

2

Your math looks correct to me. Your terminology is a little off - technically what you are creating here is just the 'view' matrix rather than the 'modelView'. If you're just drawing a single sphere at the origin then it doesn't make a difference, but normally the modelView is unique for each object in a scene - it's the object's model-to-world transform ...

2

Promoting my comment into an answer since it identified the problem... The issue is confusion between degrees and radians for the angle parameter. GLM, up to version 0.9.5, was very inconsistent in how it dealt with angles, accepting degrees for some functions and radians for others. This behaviour could be overridden with #define GLM_FORCE_RADIANS before ...

1

What you are asking about is 'mouse picking'. If a user clicks a pixel on the screen how can you get corresponding world space coordinates of an object being clicked on. Imagine a ray from that pixel, through the view volume all the way to the far plane. That ray is a set of all possible points the user is clicking on. So we want to perform ray/poly ...

1

Here's a basic camera with panning (some parts removed for brevity). It's not arcball but should get the idea across. Basically it just transforms some directions of a plane in view space to one that is in world space. rotate and pan are called on mouse move with the change in mouse position. // Updates the view matrix based on parameters void updateCam() {...

1

This is pretty straightforward matrix math and can be found on Wikipedia. It's quite elaborate, though, if you want to learn the math behind it and the other types of projection that exist. I will encourage you to checkout either Real-Time Rendering or Computer Graphics, Principles and Practice.

1

The answer is: it depends. When the preview is active in your camera app, the camera is always taking pictures so that it can provide a live preview image. The CCD is constantly binning and resetting charge accumulated from photons hitting it. The phone is also processing the captured image and displaying it - all this requires battery power. So if the ...

1

Fortunately your scenario is rather simple, your camera is on a line directly perpendicular above and centered on the quad you're concerned about. So what you want is for the quad to fill the whole screen, I assume (more or less) exactly the whole screen, i.e. the size of your projected quad in window space is your entire viewport. The mathematics of this ...

1

First of all instead of taking Cross(WorldUp, Front/LookAt) you can use Gram-Schmidt orthogonalization to produce an orthogonal vector that's close to the WorldUp vector. Then you take the cross of this orthogonal vector and the look at to get the side vector. However as you mentioned this'd fail if the vectors are parallel. Hence the usual solution is to ...

1

You can't have a camera with collinear look/front and up vectors. It doesn't make geometric sense. The whole point of the up vector is to disambiguate roll. As russ says, for a "first-person" camera it's reasonable to always use world-up for the up vector and simply lock the pitch angle to within (say) 85 degrees of horizontal, to avoid degenerate cases. ...

1

As the documentation describes it, it looks like each group of three parameters is a vector in 3D space. The first three are the position of the “eye”, the next three are the position it’s looking at, and the last three are the “up vector”, i.e. the direction of an arrow pointing out of the top (…sort of—more detail below) of the eye. The positions aren’t ...

Only top voted, non community-wiki answers of a minimum length are eligible