12 votes
Accepted

How am I able to perform perspective projection without a near plane?

The near and far planes of a viewing frustum aren't needed for simple 3D→2D projection. What the near and far planes actually do, in a typical rasterizer setup, is define the range of values for the ...
Nathan Reed's user avatar
11 votes
Accepted

What's the difference between orthographic and perspective projection?

Orthographic projections are parallel projections. Each line that is originally parallel will be parallel after this transformation. The orthographic projection can be represented by a affine ...
joojaa's user avatar
  • 8,437
10 votes
Accepted

Perspective Correct Texture Mapping

You are on the right track but what you need to do is to calculate u/w and v/w, and also 1/w for each vertex, which you interpolate linearly in screen space in your rasterizer. Then for every pixel ...
JarkkoL's user avatar
  • 3,636
7 votes
Accepted

Is my perspective math correct?

Identifying your axes in both figures and adding the camera position to your first figure would help you understand what's going on. You could also have a single variables for all your points, ...
Soravux's user avatar
  • 371
7 votes

How am I able to perform perspective projection without a near plane?

In this case, the geometry of similar triangles ABC and ADE is used to determine the height of D via the solution of DE. It is obvious that if the near plane is at 0 (AE=0), then a division by 0 ...
Nicol Bolas's user avatar
  • 9,772
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
  • 270
5 votes
Accepted

Why does this gl_FragDepth calculation work?

What you are missing is, that in OpenGL's NDC space (i.e. clip space after division by w) all 3 coordinates are in the range $[-1,1]$. So ...
Christian Rau's user avatar
5 votes
Accepted

Why is the back of a perspective frustrum larger than the front?

It might help to think of it this way: Both the near plane and the far plane are the size that will fit onto the screen you are viewing on. The further away something is, the bigger it can be and ...
trichoplax is on Codidact now's user avatar
4 votes
Accepted

Supporting multiple camera types in a deferred renderer without specializing the shaders or in the shaders

Projective transformations (represented by 4×4 projection matrices) are invertible. You can go from NDC coordinates back to view space using the inverse of the projection matrix, in the same way that ...
Nathan Reed's user avatar
4 votes

What is this triangle sub-division scheme called?

Instead of subdividing until reaching certain edge length on screen, you should look into GPU Gems 2 article "Adaptive Tessellation of Subdivision Surfaces with Displacement Mapping" by Michael ...
JarkkoL's user avatar
  • 3,636
4 votes
Accepted

Is placing z value of vertex in w enough to achieve perspective projection in OpenGL?

The projection matrix distorts the view frustum (the volume the camera can see) into a unit cube. So everything with all coordinates in the range -1 to 1 after projection is potentially visible, and ...
russ's user avatar
  • 2,392
4 votes
Accepted

Perspective correct interpolation z-buffer

Yes, that's correct. Perspective-correct interpolation works by (for some quantity $u$ to be interpolated) calculating $u/z$ and $1/z$ at each vertex, linearly interpolating those values in screen ...
Nathan Reed'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
3 votes
Accepted

Do straight lines always remain straight when projected with a perspective camera?

"A not so simple approach". I may have messed a little bit too much with grouping the terms, do forgive my elementary math skills, it's a side effect of using tools like wolfram and mathematica too ...
lightxbulb's user avatar
  • 2,226
3 votes
Accepted

Computing perspective directly

Copying this from another thread where i posted this as the answer but as Wyck suggested, the correct answer is the first one. There is the whole derivation of it but I'll be discussing a brief ...
gallickgunner's user avatar
3 votes

Why is the back of a perspective frustrum larger than the front?

It is bigger because it fills the same view and it ts further away. It would be smaller if it wouldn't fill the same view but then it wouldn't fill the camera view and it wouldnt work. So the inverse ...
joojaa's user avatar
  • 8,437
3 votes
Accepted

Interpolate vertex attributes with $z$ AFTER homogeneous divide

The $Z$ of NDC space is related to $1/Z_\text{view}$ but not the same. With a typical projection matrix, they're related by an affine remapping, $$ Z_\text{NDC} = a \, \frac{1}{Z_\text{view}} + b $$ ...
Nathan Reed's user avatar
3 votes
Accepted

Why perspective division ( div by w) when applying the inverse to a perspective transformation?

The way homogeneous coordinates (x, y, z, w) work is that if you multiply the vector by any nonzero value, it still represents the same point in 3D projective space. These different xyzw ...
Nathan Reed's user avatar
3 votes

Rendering Hypercentric Perspective

You can approximate the view of a hypercentric camera with an ordinary 3D perspective camera if you are able to manipulate the projection matrix, and/or reverse the direction of the depth test. In a ...
Nathan Reed's user avatar
3 votes
Accepted

Existence of vanishing point

My first question is how we can say it doesn't exist, but when we see real image of railway track they intersects at X? Because human vision only sees a perspective on reality. It may appear to cause ...
Nicol Bolas's user avatar
  • 9,772
2 votes
Accepted

Getting from the default view volume to an image on the screen

The mapping from NDC space to screen space is orthographic. The x is mapped linearly from [-1, 1] to [0,viewport width], same with y and viewport height. This mapping happens after the projection ...
ratchet freak's user avatar
2 votes
Accepted

Perspective correct interpolation of normal values

Perspective correct interpolation of normals works just as it does any color or coordinate or other linearly varying attribute. Each component of each varying vector is interpolated independently as ...
GroverManheim's user avatar
2 votes
Accepted

Calculate vanishing point

Here's a hint to get you started: Parallel lines include the line through the camera. So really all you need is the direction from the camera to the vanishing point on the view plane. Then create ...
ratchet freak's user avatar
2 votes

Creating a vanishing point perspective shader

It should be possible to do this properly by using a modified projection matrix for your entire scene that has its far plane at infinity, as detailed here. That should allow you to properly render ...
Quinchilion's user avatar
2 votes
Accepted

Inverse value in a Perspective Matrix

There is the whole derivation of it but I'll be discussing a brief overview. This is for the perspective projection where the line joining the eye and the center of the projection/image plane is ...
gallickgunner's user avatar
2 votes

Why is the line from the camera to vanishing point parallel to the other parallel lines?

FYI every set of parallel lines will have their own vanishing point. The reason why there is usually only a single vanishing point (the most obvious one) talked about in an image is due to aesthetic ...
ratchet freak's user avatar
2 votes

perspective matrix derivation

The key trick is the perspective divide, This divides the position by the w component. If you swap z and w (using a identity matrix that has swapped 3rd and 4th ...
ratchet freak's user avatar
2 votes

Rasterizing spheres?

Jim Blinn's book Jim Blinn's Corner: Notation, Notation, Notation has a couple of chapters which go through this in detail with all of the edge cases. This book is a collection of essays from his ...
MPG's user avatar
  • 121
2 votes

perspective matrix derivation

TL;DR: The view frustum is the NDC box. It's just that NDC space is nonlinear because it occurs after the perspective divide by w. The tops and sides of the frustum are parallel in NDC space. All ...
Wyck's user avatar
  • 410
2 votes
Accepted

Which perspective projection matrix to use

Even though you can find multiple slightly different formulations for the perspective matrix on the internet, they all do more or less the same thing. They project everything inside a space with the ...
wychmaster's user avatar
  • 1,251

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