As of May 31, 2023, we have updated our Code of Conduct.

Hot answers tagged

6 votes
Accepted

Render with camera perspective off-center

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.) ...
Bram's user avatar
  • 260
5 votes
Accepted

Depth of Field in Path Tracing: What do I do with the secondary ray?

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 ...
trichoplax is on Codidact now's user avatar
4 votes
Accepted

OpenGL - How to increase view space coordinate range in X and Y axis

I was converting the angle to radians twice guys. Moral of the story is to take breaks when coding.
gallickgunner's user avatar
4 votes

How to keep an object constant in screen space?

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 ...
Nathan Reed's user avatar
  • 24.4k
4 votes
Accepted

Camera Model View transformation in Ray Tracing

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 ...
vgs's user avatar
  • 311
3 votes

Modify camera matrix so that it renders a "chunk" of the frustum

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 ...
Christian Rau's user avatar
3 votes

Creating depth map from a 2-D image?

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 ...
user1118321's user avatar
  • 3,391
3 votes
Accepted

Deriving blur from real optical formulae

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(...
Nathan Reed's user avatar
  • 24.4k
2 votes

Please, help me to understand why my raytracing camera rotates in wrong directions?

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 ...
bram0101's user avatar
  • 1,595
2 votes
Accepted

Correctness or otherwise of the procedure for generating an orbiting camera in WebGl

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 ...
russ's user avatar
  • 2,332
2 votes
Accepted

How to rotate a camera?

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 ...
russ's user avatar
  • 2,332
2 votes
Accepted

Given two 3d vectors, find the rotation matrix between the two

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 ...
PaulHK's user avatar
  • 2,312
1 vote
Accepted

Unknown array of floating point numbers. View matrix?

Yep, that looks like a view matrix. A matrix can be stored in either row- or column-major order; that one appears to be column-major. As you’ve identified, the last row / column of it (the values you’...
Noah Witherspoon's user avatar
1 vote
Accepted

How to ensure that a randomly-generated velocity vector moves the camera forward within a valid arc?

Something like this should work: ...
Noah Witherspoon's user avatar
1 vote
Accepted

How compute new camera parameters given a velocity vector?

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"...
pmw1234's user avatar
  • 2,832
1 vote

How to use trackball for rotating an camera matrix in eye frame

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 ...
luser droog's user avatar
  • 1,343
1 vote
Accepted

Does angular diameter to FoV ratio equal object's image to total image ratio?

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 ...
Elijah Nicol's user avatar
1 vote
Accepted

Does an object spanning percentage of the Camera's FoV correlate with the object's image percentage?

@ 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 ...
Alan Marcus's user avatar
1 vote

Calculate the position and rotation needed to have a camera look at a certain region

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 ...
wychmaster's user avatar
  • 1,233
1 vote
Accepted

Perspective Raytracing

Let the horizontal FOV be given as theta (in radians), and the vertical FOV be given as phi (in radians). The we know that: $$\tan\frac{\theta}{2}=\frac{w}{f}, \tan\frac{\phi}{2}=\frac{h}{f}$$ Let ...
lightxbulb's user avatar
  • 1,951
1 vote
Accepted

How can I reproduce the MatchMoving/MotionTracking technique from Just Dance?

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 ...
Andrew Wilson's user avatar
1 vote

Camera Implementation without Limitations

Attach your camera to some pivot (in a transformation hierarchical sense). Rotate the pivot rather than the camera (do not use look at). It boils down to using $T_{pivot} R_{pivot} T_{cam} R_{cam}$. ...
lightxbulb's user avatar
  • 1,951
1 vote
Accepted

Can pixels on the image plane be mapped to world space coordinates?

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,...
Gabriel Rohweder's user avatar
1 vote

Translate an arcball camera upwards or left-right

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 ...
Andrew Wilson's user avatar
1 vote
Accepted

Understanding of Camera Up Vector

What if the camera rotate around its gaze direction? The v rotates while the t stays the same. The camera's orientation is defined by two directions: g and t. If the camera "rotates around its gaze ...
Nicol Bolas's user avatar
  • 9,378
1 vote
Accepted

Equation for camera projection

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 ...
beyond's user avatar
  • 315
1 vote

How does cell phone display image or video even before you start to capture?

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 ...
Wyck's user avatar
  • 400
1 vote
Accepted

How to calculate camera distance so that after projective transformation a quad is filling the whole screen

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 ...
Christian Rau's user avatar
1 vote

How to get camera Right vector when Front vector and WorldUp vector are collinear

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 ...
gallickgunner's user avatar
1 vote

How to get camera Right vector when Front vector and WorldUp vector are collinear

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 ...
Dan Hulme's user avatar
  • 6,650

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