Skip to main content
Share Your Experience: Take the 2024 Developer Survey
15 votes

Why do GPUs divide clip space Z by W, for position?

If you are doing a perspective image and your model has implicit intersections then, if you use "linear Z", those intersections will appear in the wrong places. For example, consider a simple ground ...
Simon F's user avatar
  • 4,261
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
  • 25.1k
11 votes

Why are width and height divided by 2 in the perspective projection matrix?

Because $x_{proj}$ doesn't vary from $0 \to width$, it varies from $-\tfrac{width}{2} \to \tfrac{width}{2}$. What's important is not the width, but the minimum and maximum values of $x_{proj}$. ...
Dan Hulme's user avatar
  • 6,830
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
7 votes
Accepted

Zoom in orthographic vs perspective projection

Perspective projection changes the size of an object as it's distance changes, while orthographic projection does not. That is part of the definition of those projection types. To simplify things a ...
Alan Wolfe's user avatar
  • 7,801
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,832
7 votes

Why do GPUs divide clip space Z by W, for position?

Using Z/W for the depth buffer goes deeper than just clipping against the near and far planes. As Simon alluded to, this has to do with interpolation between the vertices of a triangle, during ...
Nathan Reed's user avatar
  • 25.1k
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
6 votes

Solving a problem from *Foundations of Computer Graphics*:

Let me try to make my comment into a complete answer. The general idea is to build a linear system using those 6 point pairs and solve for the desired 12 unknowns. You may find this paper[1] useful ...
TheBusyTypist'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
5 votes

Projected points and screen coordinates

It's not 100% clear what the author means here, but I'll choose to interpret "screen coordinates" as "pixel coordinates". These would be related to the projected points by a 2D coordinate ...
Nathan Reed's user avatar
  • 25.1k
5 votes
Accepted

What is this graphical effect called?

I don’t think there’s a formally established name for it, but it’s generally known as distortion, warping, or refraction. It works by taking an already rendered version of the current frame, sampling ...
Noah Witherspoon's user avatar
4 votes

Need a reputable source for the formula for the shape of Earth's horizon

The curve you are seeking is just the intersection of a plane (the back of the camera) and a right circular cone. This is not really a question about the earth, or views of planets from space; it's ...
bubba's user avatar
  • 348
4 votes
Accepted

3D projection that increases objects' size as they become more distant

After a quick google of 'Inverted perspective' I found out that you have five different names for it; Reverse perspective, inverse perspective, inverted perspective, divergent perspective and ...
bram0101's user avatar
  • 1,605
4 votes
Accepted

How to derive a perspective projection matrix from its components?

The second matrix translates the eye [...] You don't do that in a projection matrix. You do that with your view matrix: Model (/Object) Matrix transforms an object into World Space View Matrix ...
Tare's user avatar
  • 1,566
4 votes
Accepted

Need help with change of basis (world to camera frame)

Since the transformation that is asked for includes a translation (the camera is located at a position other than the origin), you will indeed have to use homogeneous coordinates to describe this ...
Michael Kenzel's user avatar
4 votes
Accepted

How to unproject cursor with orthographic projection

I am still not 100% sure, if I understood your question, because of this sentence: Now however with orthographic projection the far and near plane are of the same size, so we can't calculate the ...
wychmaster's user avatar
  • 1,251
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
  • 25.1k
4 votes
Accepted

$(x, y, 1)$ is 2D homogenous coordinates or 3D homogenous coordinates?

If you have $(x,y,z) \in \mathbb{R}^3$ and you relate it to $(x/z, y/z) \in \mathbb{R}^2$ then you have interpreted $(x,y,z)$ as one possible representation of the 2D vector $(x/z, y/z)$ in ...
lightxbulb's user avatar
  • 2,226
4 votes
Accepted

Is it possible to make a projection matrix to not project in the center?

It's not possible to cut a hole in the image by altering the projection matrix, no. However, you can mask out rendering in that region by using the depth test or stencil test. For example, before ...
Nathan Reed's user avatar
  • 25.1k
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

Creating Sparks using Code

For the lightning, I recommend using a midpoint displacement algorithm. You start with a line segment between any 2 points A and B (this works in either 2D or 3D). Calculate the midpoint of the ...
user1118321's user avatar
  • 3,421
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
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

What is this graphical effect called?

Rasterizers will probably handle it as a post processing effect. While doing ray tracing/marching it's possible to bend the rays while incrementing at each step.
Felipe Gutierrez's user avatar
3 votes
Accepted

$P^2$ vs projection plane

In computer graphics the projection plane is most commonly defined as a plane perpendicular to the camera at a specific distance from the camera (the distance is often labeled $g$). It is the plane ...
pmw1234's user avatar
  • 3,219
3 votes
Accepted

Difference between transformation and projection?

A projection is a kind of transformation. A transformation is any modification of a coordinate that expresses that coordinate relative to a coordinate system that is different from its original ...
Nicol Bolas's user avatar
  • 9,832
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,832
3 votes
Accepted

When fitting 3d cuboids into a box, how to find the order of drawing (in a 2D projection) so that the cuboids don't appear to overlap?

Let's get our orientation straight first. When I speak of a direction, I mean the direction relative to our viewpoint. So the "front" face of a cuboid is the face nearest the camera; "...
Nicol Bolas's user avatar
  • 9,832

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