# Tag Info

6

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

Scale the object proportional to its depth (z in camera space) and it will retain the same size on screen regardless of its position in world space. Additionally, you might also wish to scale the object proportional to the field of view so that it retains the same screen size regardless of the camera zoom. (Specifically, scale it by tan(fov/2)). Finally, ...

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 ...

2

You can construct a rotation matrix from an "axis", or 3 vectors. This is done by calculating 3 direction (normalized) vectors for the 3 axis of our new rotated coordinate system, they are forward, up and right vectors. In your case let's say we have 2 vectors called v1 and v2. we can produce a direction from them via (glsl psuedo code): vec3 ...

1

Something like this should work: forward_direction = normalize(-current_cam_pos) right_direction = (forward_direction.y, -forward_direction.x, 0) angle = uniform(-pi/4, pi/4) new_direction = (cos(angle) * forward) + (sin(angle) * right) new_pos = new_direction * how_far_you_want_to_move Some notes: The normalize will blow up due to a division by 0 if your ...

1

The velocity vector becomes your forward vector, just normalize it. The up direction doesn't change, use whatever version up the camera usually uses. The last vector (call it the "right hand" vector) is the cross product of up, and forward. Then, do a second cross with the forward vector and the right hand vector to guarantee an orthonormal basis. ...

1

I'm assuming the rotation matrix generated from the arcball is 2D, so I think there are a few clear top level steps. But I'm not sure about the details of some of them. First you'll need to extend the 2D rotation to 3D which should be easy. Next you'll need to rotate the rotation matrix itself so its axis aligns with your Forward vector. I'm not certain how ...

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

This is an interesting question, as intuitively we would think that the image size of the object will be 50% of the image width. However, upon some playing around with triangles, I found this to not be the case. For example, take a look at the diagram below. Here we have two overlapping triangles, one with angular diameter of 50 degrees (representing the ...

1

@ Physician --- We can use trigonometry and set-up a condition whereby the horizontal angle of view will be 100° On a full frame 35mm camera format demotions 24mm by 36mm, mount a 15mm lens and horizontal angle of view will be 100° On an APS-C compact, the frame size is 16mm by 24mm. Mount a 10mm lens and the horizontal angle of view is 100° In other words, ...

1

I have a 2D region defined by 4 points in 3D space. I want to position my camera so that it looks at the region, with a settable variable determining which side it looks at,... The first thing you need to do for this is to define a convention that specifies which side is the front and which one is the back of your plane depending on the ordering of your ...

1

Since homography is not my topic, I can't really tell if I am missing some important edge cases, but after some research, I think I got the basics. I will use the same variable names, the guy in the video uses on slide 15 (slide numbers are in the bottom right corner on the red background). You start by defining 4 points in the plane $X$ where you say you ...

1

The Kinect SDK has a skeletal tracking demo in the c++ api (BodyBasics). The skeleton you get is the same "topology" unless it fails to acquire the skeleton. So you can easily compare the left shoulder of two captures as you always know which point it is. You'll have to experience with metrics. A simple point to point metric would probably be sufficient ...

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

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