r/programming • • 4d ago

A Video on How 3D Rendering Actually Works

https://youtu.be/EePTBIOgvpY?is=j1J_9DnD9m-y3sIf
26 Upvotes

4 comments sorted by

8

u/_georgesim_ 4d ago

GPUs don't use barycentric coordinates to determine which pixels are inside a triangle. Instead, they use what are called "edge functions" which tell you, for each edge of the triangle, if a pixel is on the "inside side" of the edge. The reason is that edge functions can, after a setup step, be implemented with integer additions only, which parallelize extremely well.

2

u/Dlinik 4d ago

I knew that this approach exists but I didn’t know it’s exclusively used for GPU rendering. Very interesting.

1

u/darknecross 4d ago

I randomly stumbled across a thread talking about quaternions the other day, the alternative to translation matrices, which were pretty neat.

i^2 = j^2 = k^2 = ijk = -1

1

u/Whispeeeeeer 1d ago

Also a cool way to avoid "gimbal lock"!