Using face normals for back-face culling

Started by
23 comments, last by GuybrushNivek 21 years, 4 months ago
Following your description of what you are doing i assume that you are rotating and translating your vertices in a way that your camera is always placed at the origin (i.e. if your virtual camera is at (10,10,20) you translate your vertices by (-10,-10,-20)) and your world moves around it. Am i right? If, then simply take the vertex data from the triangle because this is already the vector from your camera (0,0,0) to the vertex. If not, your vector is -c+a where c is the camera position and a the triangle vertex.

Edit: To answer your question: I'm doing backface culling in camera-space in this particular engine.


[edited by - EgonOlsen on November 20, 2002 3:59:40 PM]
Advertisement
No, actually...

The object is rotating around itself...and is then added into space...(eg...all vertices are added 1000....so the objects centre is at 1000 , 1000 , 1000)

My camera can zoom and zoomout is all, but occupies its own coordinates...I have addressed the problem in my engine tho...I translate my coordinates last...(I rotate them and the normals first, then cull) and THEN add the perspective translation to the vertices...It works fine. :-)

BTW, the link you sent, the Java applet...was this you...it is cool.

:-)
:-)
Well, what i really meant was: Are you doing culling in camera-space?

Edit: The applet is just a simple demonstration of what is possible with the engine. But software rendering (even in Java) is quite a small market...

[edited by - EgonOlsen on November 20, 2002 4:34:12 PM]
Ready4Dis: Your algorithm is wrong. I know many people use it, nevertheless it is wrong. Have a close look at EgonOlsen´s picture and you can see that a triangle can be visible even though the normal is pointing away from you (with your method B will be culled away even though it is visible).

quote:Original post by GuybrushNivek
If (x3-x1)*(y2-y1)-(x2-x1)*(y3-y1)>=0 then drawtriangle()


Let´s have a look at what the above is doing: It is calculating the z component of a cross product of the vectors (x3-x1, y3-y1) and (x2-x1, y2-y1), and thus calculates the z of a normal vector.

So you do a z>=0 test.

This test is correct, if you use x1, x2, x3, y1, y2, y3 as coordinates _after_ doing the projection (i.e. after dividing each of them by z). Then it will work. Otherwise it is just wrong.
quote:Original post by EgonOlsen
Edit: To answer your question: I''m doing backface culling in camera-space in this particular engine.
[edited by - EgonOlsen on November 20, 2002 3:59:40 PM]


Your engine is much more impressive than mine, but I liked java 3D-engines also a little back then:
Raumschiff Kenterpreis

This topic is closed to new replies.

Advertisement