Sign in to follow this  
supagu

front plane clipping

Recommended Posts

ive got clipping working in my software renderer, the only problem im having is clipping with the front plane. i suspect the problem is due to the world view projection matrix causing the poly to be flipped/inverted/mirrored as it goes behind the focal point. my poly appears to be mirrored/flipped. Any tips on how to fix this problem?

Share this post


Link to post
Share on other sites
You need to do clipping before you do the perspective projection. The usual way is to leave vertices in homogeneous space and then clip to [+w,-w] in each direction x,y,z (or for some APIs, z clips to [0,+w] instead). This sounds bizarre if you're not used to homogeneous math, but it's the simplest way to do things in the end. You should be able to find some decent summaries of this online - it's a standard part of any 3D pipeline.

Share this post


Link to post
Share on other sites
The poly should never go through the focal point as it has to be clipped first, so that this case never happens.

The perspective transformation matrix transforms your geometry into clip space with -1 <= x/w, y/w, z/w <= 1. (If you are using the full unit cube as clip space like opengl does it. DirectX has another definition of clip space)

You have to clip triangles which has vertices which are outside this unit cube. This can be determined by simple tests with x < -w || w < x. Similarly for the other coordinates.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this