r/GraphicsProgramming • • Mar 14 '26

Question Homogeneous coordinates

Post image
1.3k Upvotes

94 comments sorted by

View all comments

Show parent comment

1

u/JiminP Mar 18 '26

So basically

"Everything in game dev is linear algebra.

... except perspective transformation and affine transformation."

"How do you carry out those?"

"Linear algebra."

1

u/PersonalityIll9476 Mar 18 '26

Perspective division is genuinely not linear algebra. You can cheat affine transforms by bumping up a dimension (3d -> 4d). That's one reason why GPUs use 4x4 matrices and not 3x3.

The perspective divide causes no end of conceptual problems because it means something non-reversible happens after the geometry shader and before the fragment shader. That makes it impossible to back your way out just using equations. This is why we often pass world coordinates directly from prior stages to the frag shader, so we have a sort of "inverse function" available to us when we normally wouldn't be able to know.