Skip to main content
GameDev.net gamedev.net
🔒 Locked

3D clipping

Started by jho Jul 11, 2000 at 2:57 AM 9 replies 650+ views
Original Post
jho
jho
Hi, can someone advise me on how to do 3D clipping.. (not in OpenGL or DX) I have already done it for the front Z plane, it was not hard, but what about the sides, there are 4 sides. In perspective projection, do these 4 sides actually "pan" outwards? I''m just clipping lines right now, TIA
TPH
TPH
I know how to clip polygons using homogenous coordinates against the six planes, if that''s of any use?
jho
jho
Yes please explain how do you clip with the perspective camera..
Would it be expensive to perspective transform first and 2D clip it? Since the perspective transform just a subtraction and a couple of mults.
TPH
TPH
If you clip in 2D won''t you have lost some of that important 3D Z-dimension information required for lighting?

You maybe clipping lines at the moment, but at some point you''ll want to move on from there.
Ingenu
Ingenu
My advice :
Do everything you can in 3d space.
Suppress as much polys as you can ASAP !

3D Clipping will suppress many triangles, and such, decrease the amount of work in the projective ''module''.


Do your backface culling in 3d using surface normal, you''ll suppress many polys too, that won''t need to be transformed and projected.

You must have the LESS possible ammount of polys when you come to transform and project !

All IMO, and based on many 3D engine coders experience.

-* So many things to do, so little time to spend. *-
-* So many things to do, so little time to spend. *-
jho
jho
I don''t understand how you can clip the lines with the side planes before the perspective divide (Z)?

consider one of the lines far away from the camera, going from outside the left clipping plane to inside the view volume
Now, we clipped it before perspective divide


----|snap|---------->

now you do perspective divide, the new clipped line is shorter due to perspective foreshortening..
then it''s not right.. the clipped is not sticking to the screen edge anymore..

|
| ------->
|
|

Right?







TPH
TPH
You can clip after the perspective divide - this is what I''ve done with polygons.

You can determine the intersection of a line against any of the planes using some simple maths.

Can provide if you want.

jho
jho
Hi, I''m still debating whether I should do clipping with 3D planes or in 2D window or not.. basically I have this fully software engine, it ONLY DO LINEs in 3D perspective projection, No lighting, no Z buffer, no solid filling.. In this case would 2D clipping be better, it seems there''s a lot of operations and checking involved in clipping with 5-6 planes and finding intersections.

I mean I''m not afraid of the difficulty of 3D clipping; but I would like to choose whatever be fastest for a line rendering engine.
Ingenu
Ingenu
Not using hardware acceleration nor polygons...


Then use 2D clipping.
3D clipping is necessary when you want to reduce the T stage cycles.
It works nice with polygons and normals.



-* So many things to do, so little time to spend. *-
-* So many things to do, so little time to spend. *-
TPH
TPH
Wait a minute - I got that wrong. You can clip after the perspective projection, and BEFORE the perspective divide.

Sod it, if all you want is lines, clip in 2D. Can recommend the Cohen-Sutherland clipper using bitwise out-codes. Easy to implement and pretty fast.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.