Polygon Clipping

I stumbled across a cool website of a programmer who did source code reviews of games that had gone open source (doom3, quake, etc). a lot of first person shooters. He had a post dedicated to how to clip polygons, with source code and explanations. it’s in C, but you could easily port it over.



@matkatmusic - According to this page

“A TBDR graphics processor automatically uses the depth buffer to perform hidden surface removal for the entire scene, ensuring that only one fragment shader is run for each pixel. Traditional techniques for reducing fragment processing are not necessary. For example, sorting objects or primitives by depth from front to back effectively duplicates the work done by the GPU, wasting CPU time.”


“Because tile memory is part of the GPU hardware, parts of the rendering process such as depth testing and blending are much more efficient—in both time and energy usage—than on a traditional stream-based GPU architecture. Because this architecture processes all vertices for an entire scene at once, the GPU can perform hidden surface removal before fragments are processed. Pixels that are not visible are discarded without sampling textures or performing fragment processing, significantly reducing the calculations that the GPU must perform to render the tile.”

In other words, running any extra polygon clipping to cull vertices is probably duplicating what is already happening.

oh, well, I was just posting it to share some knowledge. there’s a lot of good stuff on his site, and that was one of the good bits.

agreed, I had a look, thanks. And it gave me the idea for a post.