Pico 8 3D Rendering: Near Plane Clipping
Now we have a working camera, and triangles are drawn from the most distant to the nearest. We’re getting very close to a complete renderer. The main issue remaining is that when we walk into one of the cubes, everything goes haywire. This is down to the division by z in the projection function. If z is 0, then infinity is returned, and we get odd results. If z is negative, then we get warped triangles and inverted rendering. What we need to do is detect when triangles are too close to the screen, or are behind the camera and skip rendering them.