Archived

This topic is now archived and is closed to further replies.

MButchers

Backface Culling

Recommended Posts

hello there, im using Mark Morleys code for bounding sphere occlusion and it works great however i am now implimenting backface removal and for some reason its not working. Im doing the following Get the clip planes for the frustum ( these all face inwards ). ViewNormal = 1st 3 elements of near clip plane (x,y,z). Multiply the quads normal by the objects current transformation matrix. If DotProduct(ViewNormal,QuadNormal) > 0 then RenderQuad. Can anyone see anything obviously wrong, Thanks Mark.

Share this post


Link to post
Share on other sites
Let me try to draw some art:
^
| /
| |
| /
|
*
Well... * is the eye position, the arrow your ViewNormal and the other thing a quad.
Clearly, the quad´s normal is facing in the direction of the ViewNormal, even though the quad is possibly visible (Draw this clearly on a piece of paper, and you will see what I mean).
But you can adjust this simply. Just take any point on your quad. Let´s call it a. Then calculate
ViewNormal = a - eyePosition
and then your test on DotProduct(ViewNormal, Quadnormal) > 0 will work.

I now see something else that could be wrong. You must take care that you multiply the quad´s normal with the linear part of your transformation matrix (no translation). As you only want to rotate the normal, not translate it. So make the fourth row (or column, depends on your math) 0.

Share this post


Link to post
Share on other sites
Cheers,

shall give that a go,
I had already noticed the bug with translating the
normal ( specular highlights wizzing around with
object as it rotates ) All fixed now

Many thanks

Mark.

Share this post


Link to post
Share on other sites