# Normals and back face culling with field of view angle

This topic is 3818 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

This is a repost. It might have been posted in the wrong forum.. First, hello! This is my first post. I have hit a wall, and can't find a straight forward answer to what I think is a somewhat mundane concept of 3D graphics engines..... I can calculate a plane normal, and rotate it, and do a simple dot product to the cameras out vector(0,0,-1) and cull all the right faces. But that is only if the object is directly in front of the camera. If the object or camera is translated so that the object is rendered in a corner of the screen, i am culling the same polys that I would if the object were directly in front of the camera. To me this seems like a problem. With the field of view angle, if the object is translated enough away from the center of the cameras viewport (origin) to "stretch" I SHOULD be able to see polys that I wouldn't see if the object were directly in front of the camera. But I am culling them away. I turned the alpha down on the polys when they render so I can see if anything is rendering behind, and in this scenario where I am culling polys on the side of the object that is being exposed to the camera...I am not culling the polys on the opposite side of the object that is no longer being exposed to the camera... But again, if I put that object that is not culling right in the corner of the screen back in the center, it culls right...? Hopefully that makes since... Does the fov play a roll in back face culling? Do I need to be using the homo coordinate? (that is what I call it, the fourth homogenous coordinate..told you, I'm not a professional) Am I not translating the normals right? Right now I am translating my 3 point normal vector with a 3x3 matrix that is comprised of the objects rotation in camera space. Then I get the dot product of that vector with the camera out (0,0,-1). and bam. almost right..... thanks for putting up with my ramblings... j

##### Share on other sites
The FOV shouldn't come into it. If your camera /view point/ is on the back side (half space) of a face then it should be culled away. Substitute the viewpoint into the plane equation for your world space triangle, and if the result is negative, cull.

If you choose to do backface culling post-transform (including projection), then you just need to look at the sign of the z-component of the transformed face normal.

##### Share on other sites
Quote:
 Original post by crowley9If you choose to do backface culling post-transform (including projection), then you just need to look at the sign of the z-component of the transformed face normal.

This will cull visible triangles in some cases, so it doesn't work. I'm not sure how to characterize those cases, but try to imagine that a triangle that is very close to the left clipping plane, but the negative angle (i.e., the angle measured from the left) it creates with the X-axis is larger than the angle between the X-axis and the left clipping plane. If it's normal points away from the camera, the above test will cull it away, but in fact it's front side is visible.

I wish I could upload a sketch, but I don't know how...

##### Share on other sites
I am sure that this does work. The angle between the x-axis and the left clipping plane is always 90 degrees, so I think you are thinking of a different scenario (most likely pre-perspective transform?).

##### Share on other sites
If I'm getting this right, you need to dot the normal with the camera_origin to vertex vector (no need to normalise this vector). The vertex can be any of the polys vertices.

##### Share on other sites
Quote:
 Original post by crowley9The angle between the x-axis and the left clipping plane is always 90 degrees, so I think you are thinking of a different scenario (most likely pre-perspective transform?).

It sounds like you are referring to the clip planes in clip space. I was thinking about them in camera space (though re-reading your first reply I see that's not what you meant). I'm not sure if this problem occurs in clip space or not.

##### Share on other sites
Quote:
 Original post by StonemonkeyIf I'm getting this right, you need to dot the normal with the camera_origin to vertex vector (no need to normalise this vector). The vertex can be any of the polys vertices.

Not quite. The plane containing the triangle is N.x - d = 0 (N is the normal, d is a constant). Substitute the camera position P as x to get N.P - d. If this last value is greater than 0, the normal is visible, otherwise it is not.

Quote:
 Original post by Gage64It sounds like you are referring to the clip planes in clip space. I was thinking about them in camera space (though re-reading your first reply I see that's not what you meant). I'm not sure if this problem occurs in clip space or not.

No it doesn't - after the final transform has been applied all visible rays are perpendicular to the XY-plane. The sign of the z component therefore determines the orientation.

##### Share on other sites
Quote:
 Quote:Original post by StonemonkeyIf I'm getting this right, you need to dot the normal with the camera_origin to vertex vector (no need to normalise this vector). The vertex can be any of the polys vertices. Not quite. The plane containing the triangle is N.x - d = 0 (N is the normal, d is a constant). Substitute the camera position P as x to get N.P - d. If this last value is greater than 0, the normal is visible, otherwise it is not.

I'm not quite sure then, I use the method I described but in model space by transforming the camera coords and it works perfectly although doing the culling and lighting in model space doesn't allow for scaling. Basically it tests to find which side of the plane (poly) that the camera is on by calculating the dot product of the normal and the vector from the camera to any point on the plane (C-P).N where C is the camera coords, P is any point on the plane, N is the normal.

##### Share on other sites
StoneMonkey: That should work too: (C-P).N = N.C - N.P = N.C - d. Effectively, they are equivalent (except that d can be factored out of the computation and stored for efficiency).

##### Share on other sites
Wouldn't d have to be recomputed for each triangle whenever the camera or the object moves?

1. 1
2. 2
3. 3
Rutin
20
4. 4
khawk
14
5. 5

• 9
• 11
• 11
• 23
• 12
• ### Forum Statistics

• Total Topics
633655
• Total Posts
3013187
×