More Lengyel.

This commit is contained in:
ed committed 2026-08-28 18:42:55 -04:00
1 parent c825ba0f06
commit 667f8ca53e
92 files changed
+3968

No files matched your search

@@ -0,0 +1,72 @@
---
title: "I've decided to make this explanation public, in case someone else is also interested."
type: archive
source: twitter
source_url: "https://x.com/pikuma/status/1931455040965009503"
author: "pikuma.com"
handle: pikuma
post_id: "1931455040965009503"
date: 2025-06-07
archived: 2026-08-28
draft: false
tags:
- archive
- twitter
- pikuma
description: "I've decided to make this explanation public, in case someone else is also interested."
in_reply_to: ""
---
## Source
- URL: https://x.com/pikuma/status/1931455040965009503
- Author: pikuma.com (@pikuma)
- Posted: 2025-06-07 20:55:41
## Thread
**1/** **@pikuma** ^1931455040965009503
I've decided to make this explanation public, in case someone else is also interested.
First, let's write down the operations on z without the matrix:
Pay attention to how we have a multiplication and a subtraction. Let's look at the multiplication first.
Our goal is to normalize the original z values so they are all from 0 to 1, where znear is 0 and zfar is 1.
Keep in mind that we are not showing here the perspective divide (division by the original z). The actual normalization (from 0 to 1) will occur after we divide things by the original z later. In other words, because the normalized z value will (in the perspective divide) still be divided by the original z value, it is normalized between 0 and zfar. The division by the original z value (inside w) will make it actually normalized between 0 and 1.
Therefore, the first thing we do is to normalize values between znear and zfar. This can be achieved using the fraction 1/(zfar-znear).
At the same time, we want our z values that are equal to zfar to be transformed to zfar, since the perspective divide is going to normalize that back to 1. We can accomplish this by scaling things by zfar. This gives us an intermediate result of zfar/(zfar-znear).
These steps take care of the zfar mapping and explain the multiplication part of our formula.
...continues 👇
![](https://pbs.twimg.com/media/Gs3l5rdWcAALHS6?format=png&name=orig)
![](https://pbs.twimg.com/media/Gs3mAbnW4AAW3WJ?format=jpg&name=orig)
![](https://pbs.twimg.com/media/Gs3mdZgXcAArODD?format=png&name=orig)
![](https://pbs.twimg.com/media/Gs3mmdXWcAAZ57r?format=png&name=orig)
**2/** **@pikuma** ^1931455044877971797
Finally, we also want the z values that are equal to znear to be transformed to 0. We can accomplish that by offsetting (subtracting) *something* from the previous intermediate result. This is what we called the "difference between the eye and the near plane" in our lecture.
Imagine for a second that we have a z value that is exactly znear. If we multiply this value with the previous intermediate result zfar/(zfar-znear), we get (znear*zfar) / (zfar - znear). Therefore, this is the "correction" we need to apply to transform our z values that are equal to znear to be equal to 0.
All of these steps will give us the final entries of the projection matrix to help us perform the desired z normalization.
In our lectures, I also chose to call zfar/(zfar-znear) as lambda (λ). This is just notation and does not change anything in the meaning of our z normalization formula.
After we multiply our vertex with the projection matrix we proceed to do the perspective divide (division by the original depth value, which is saved inside w). Only after the perspective divide is that our z value will be in the range [0,1] for depth values between znear and zfar.
I hope this breakdown helps you connect things. I like to discuss things in a high-level and postpone an actual algebraic derivation if possible. If you want a proper derivation of the perspective projection matrix, one of our students created a great video with his explanation of it: https://www.youtube.com/watch?v=k_L6edKHKfA.
![](https://pbs.twimg.com/media/Gs3nNX5WUAAHfSs?format=png&name=orig)
![](https://pbs.twimg.com/media/Gs3nk5oWEAA-q_K?format=png&name=orig)
**3/** **@EricLengyel** ^1931542043433836638
**@pikuma**
Please note that ever since z buffers have been floating-point (about a decade now), the best practice is to map znear to 1 and zfar to 0 and use a reversed depth test. This gives you much greater depth precision for objects rendered far from the camera. See FGED2, Chapter 6.
**4/** **@pikuma** ^1931669715165860205
**@EricLengyel**
Right on! I was discussing this on a Discord server with HiddenAsbestos a couple of months ago for his flight sim experiments. :)
@@ -0,0 +1,37 @@
---
title: "@KentoAsashima @pikuma @rygorous You could, but the information needed to construct the projection matrix in the first place includes the values of s and g that I mentioned above."
type: archive
source: twitter
source_url: "https://x.com/EricLengyel/status/1960798301269450968"
author: "Eric Lengyel"
handle: EricLengyel
post_id: "1960798301269450968"
date: 2025-08-27
archived: 2026-08-28
draft: false
tags:
- archive
- twitter
- pikuma
description: "@KentoAsashima @pikuma @rygorous You could, but the information needed to construct the projection matrix in the first place includes the values of s and g that I mentioned above."
in_reply_to: ""
parent_post_id: "1960778289288765939"
---
## Source
- URL: https://x.com/EricLengyel/status/1960798301269450968
- Author: Eric Lengyel (@EricLengyel)
- Posted: 2025-08-27 20:15:19
## Branch
**1/** **@EricLengyel** ^1960798301269450968
**@KentoAsashima** **@pikuma** **@rygorous**
You could, but the information needed to construct the projection matrix in the first place includes the values of s and g that I mentioned above. You already have exactly what you need, and going through the projection matrix just adds extra steps.
## Related
- Spine: [[archive/threads/pikuma/2025-08-26-assuming-the-risk-of-appearing-extremely-dumb-in]]
@@ -0,0 +1,52 @@
---
title: "Assuming the risk of appearing extremely dumb in front of everyone here but, how would you find and explain your rationale for the value of the angle β in the diagram below? Someone told me that my approach is wrong so I just want to check that I'm not going crazy."
type: archive
source: twitter
source_url: "https://x.com/pikuma/status/1960444602227269928"
author: "pikuma.com"
handle: pikuma
post_id: "1960444602227269928"
date: 2025-08-26
archived: 2026-08-28
draft: false
tags:
- archive
- twitter
- pikuma
description: "Assuming the risk of appearing extremely dumb in front of everyone here but, how would you find and explain your rationale for the value of the angle β in the diagram below? Someone told me that my approach is wrong so I just want to check that I'm not going crazy."
in_reply_to: ""
---
## Source
- URL: https://x.com/pikuma/status/1960444602227269928
- Author: pikuma.com (@pikuma)
- Posted: 2025-08-26 20:49:51
## Thread
**1/** **@pikuma** ^1960444602227269928
Assuming the risk of appearing extremely dumb in front of everyone here but, how would you find and explain your rationale for the value of the angle β in the diagram below? Someone told me that my approach is wrong so I just want to check that I'm not going crazy. 😐
![](https://pbs.twimg.com/media/GzTl-eyXwAAxMV0?format=jpg&name=orig)
**2/** **@EricLengyel** ^1960464041023070434
I see nothing wrong with thinking of β as the angle rotated away from the −x axis as you open the field of view from the z axis by the angle fov/2 = β. But if it's the normal vector you're ultimately after, I think it's best to compute with the aspect ratio s = w/h and focal length g = s / tan(fov/2). The unit-length inward-pointing normal vector of the right frustum plane is then simply (−g, 0, s) / sqrt(g² + s²). The other three side planes have similarly simple forms in terms of g and s. See FGED2, Section 6.1 for more details.
**3/** **@pikuma** ^1960471322858770840
**@EricLengyel**
Thank you. 💪 This was recorded years ago and I'm thinking of re-designing this module. I'll definitely consider your take. Even though this is just computed once I salwe the sqrts so I want to think about proper cost tomorrow with a bit more time and with a clear mind.
**4/** **@KentoAsashima** ^1960778289288765939
**@pikuma** **@EricLengyel**
Why not the Gribb and Hartmann method as outlined by @rygorous where we use the perspective matrix axes? See https://fgiesen.wordpress.com/2012/08/31/frustum-planes-from-the-projection-matrix/
The extremes of our frustum are where the different axis components will be 1 or -1 thus we can use the corresponding axes directly.
Branches: [[archive/threads/pikuma/2025-08-26-assuming-the-risk-of-appearing-extremely-dumb-in/2025-08-27-EricLengyel-you-could-but-the-information-needed-to-construct]]
+2
View File
@@ -13,5 +13,7 @@ tags:
- [[archive/threads/pikuma/2023-08-23-nobody-cared-about-graphics]]
- [[archive/threads/pikuma/2023-11-16-unpopular-opinion]]
- [[archive/threads/pikuma/2024-06-12-hardware-os-are-extremely-more-complex-now-and]]
- [[archive/threads/pikuma/2025-06-07-ive-decided-to-make-this-explanation-public-in]]
- [[archive/threads/pikuma/2025-08-19-you-need-to-walk-before-you-run]]
- [[archive/threads/pikuma/2025-08-26-assuming-the-risk-of-appearing-extremely-dumb-in]]
- [[archive/threads/pikuma/2026-05-26-nobody-cracks-open-a-programming-book-anymore]]