View Full Version : Frustum Planes Culling

Phoenix

04-22-2002, 01:20 AM

Hi!

I was just trying to implement a frustum-culling function for my videogame and I found a tutorial on the net about this topic.

The problem is that the author doesn't explain the most important thing: ***HOW to "extract" frustum-planes equations from the perspective-matrix!***

He just gives some code like this:

-------------------

// This will extract the RIGHT side of the frustum

m_Frustum[RIGHT][A] = clip[ 3] - clip[ 0];

m_Frustum[RIGHT][B] = clip[ 7] - clip[ 4];

m_Frustum[RIGHT][C] = clip[11] - clip[ 8];

m_Frustum[RIGHT][D] = clip[15] - clip[12];

------------------------

I can't understand why do I have to perform this operation in order to get the plane equation...Is anybody able to explain this to me???

Thanx in advance!

knackered

04-22-2002, 05:30 AM

http://www.markmorley.com/opengl/frustumculling.html

satan

04-22-2002, 08:20 AM

Originally posted by knackered:

http://www.markmorley.com/opengl/frustumculling.html

and where exactly on that page explains the author why his equations work?

i think it is nearly the same that phoenix read and it definitly has the same problem

just saying how it is done, but not the math behind

and as i read phoenix question he does not want just another 'just-do-this-article' but the math

correct me phoenix if i am wrong

btw i am quite interested in it, too

any help welcome

knackered

04-22-2002, 08:40 AM

Phoenix: "thing: ***HOW to "extract" frustum-planes equations"

Satan: "explains the author why his equations work"

"How" and "why" mean radically different things, satan.

If you want to know why, then learn about projection matrices - I haven't got a 'nice-and-easy' link for you, so you'll have to do some work yourselves.

Phoenix

04-22-2002, 08:59 AM

Thanks for your help first of all! http://www.opengl.org/discussion_boards/ubb/wink.gif

Anyway Satan has fully understood my problem...I just want to know the math behind it!...it is too easy to rip a bunch of code-lines and to paste them in your own source. I dont like this, also because I'm very interested in math and geometry.

I searched really a lot on internet about frustum-culling and I found five or six tutorials about it, and believe me, none of their authors explains WHY that method work, and they re-used the same code that I have posted...so I think that I will have to understand it by myself...if you have any suggestion, keep me updated http://www.opengl.org/discussion_boards/ubb/wink.gif

Thanx!

Byebye!

satan

04-22-2002, 09:47 AM

Originally posted by knackered:

"How" and "why" mean radically different things, satan.

i know, but you have to see that many people here are not native english speakers (me included) and instead of sticking to words you have to CAREFULLY read the posts in order to give as much help as possible

if you can not help, just say i cannot help or do not answer and that's it

it would have been nice to get an easy link (phoenix said why) although this is of course an ot question, if there is no such information phoenix and i will do it on ourselves (hope you don't mind, phoenix, that i speak here in your name, too)

no offense meant

p.s.:and i also know that the advanced forum is not the right place, but that's an often discussed problem of this board

[This message has been edited by satan (edited 04-22-2002).]

xtwombly

04-22-2002, 09:57 AM

Pheonix,

I'd recommend getting ahold of a copy of Computer Graphics: Principles and Practice (Foley J, et. al.) Its not cheap, but is quite thorough in its coverage of the underlaying mathematics of 3D graphics and has been well worth the cost to me.

XT

davepermen

04-22-2002, 09:59 AM

as far as i know, he takes the plane-equations of the unit-cube and transforms them back.. and because they are quite simple, he optimized it to this code..

the unit planes are, i guess like that:

left = 0x+1y+0z-1=0 => y-1=0

right: -y+1=0

etc..

and then he backtransformed then.. or so.. http://www.opengl.org/discussion_boards/ubb/smile.gif

hope it gave an inspiration..

Phoenix

04-22-2002, 10:01 AM

Don't worry satan ;-)

I 100% agree with you...anyway I can't see any big difference from "WHY that method work" and "HOW that method work"...if anybody would have been able to explain the "HOW", I would have understood the "WHY" and vice-versa...simple! eheeheh http://www.opengl.org/discussion_boards/ubb/smile.gif

I hope to see next replies with useful suggestions http://www.opengl.org/discussion_boards/ubb/wink.gif

BYE

Phoenix

04-22-2002, 10:05 AM

Daveperman!

Your answer seems to be perfect: I think you got the right solution to the problem!

Now I am going to try it with paper&pen and I will let you know...

Thanx!

davepermen

04-22-2002, 10:40 AM

permEn... grmbl.. http://www.opengl.org/discussion_boards/ubb/smile.gif

knackered

04-22-2002, 11:06 AM

I take it you both didn't appreciate the link then?

Grumble, grumble.... http://www.opengl.org/discussion_boards/ubb/smile.gif

satan

04-22-2002, 11:39 AM

Originally posted by knackered:

I take it you both didn't appreciate the link then?

Grumble, grumble.... http://www.opengl.org/discussion_boards/ubb/smile.gif

i surely would have if it would not have been in my bookmarks already

no need to grumble http://www.opengl.org/discussion_boards/ubb/smile.gif

and to davepermen:

that was nearly to easy, sometimes i think i am just to stupid or lazy or both http://www.opengl.org/discussion_boards/ubb/smile.gif

thx

and now back to 'my' beginners forum

Phoenix

04-23-2002, 12:45 AM

Good morning friends http://www.opengl.org/discussion_boards/ubb/wink.gif

for Knackered: thanx for the link (marmokley) but my problem arose just after I read that article on that page! ;-) as you can see nobody can't explain the math behind it...you will find the same lackness on other tutorials like that on other pages.

for DavepermEn http://www.opengl.org/discussion_boards/ubb/smile.gif I felt like you have enlighten my mind but know I am not sure at all about your solution: can you explain it better?

You suggested to have a unit-cube and to let it be transformed by the matrix projection: the problem is that if you have a unit-cube it WON'T be necessarily be transformed in the frustum pyramid!

If you have a parallelepiped and want it to be perfectly transformed in the frustum you have to "model" it with the same dimensions of the top,right,bottom,up,near,far and you CAN'T have these information....I think I'm still in trouble so I need another inspiration http://www.opengl.org/discussion_boards/ubb/wink.gif

Phoenix,

I think what davepermen is saying that you should apply the inverse of the projection transformation to the unit cube (since by definition the projection transformation is the transformation that will tranform the viewing frustum to the unit cube).

Note, 'unit cube' in this case is the cube with faces at x == 1, x == -1, y == 1 etc. so in fact the cube's edges have length 2, not 1.

This inverse calculation can be short-circuited because the plane equations of the unit cube are so simple (a lot of elements are zero). The source code probably contains the results of these calculations.

HTH

Jean-Marc

Phoenix

04-23-2002, 02:46 AM

Yes!

JML and DavepermEn: you are right! sorry if I misunderstood your posts: I should have read them more carefully...your method is the right way to proceed! ... It is just a matrix multiplication but since the planes equation of the unit cube contains a lot of 0 all the multiplications simplify!

Thank you!

Hope this discussion will be useful to other videogame-math addicted http://www.opengl.org/discussion_boards/ubb/wink.gif

Phoenix

04-24-2002, 12:23 AM

Mmmm...I still have a little doubt...I 100% agree with you: also according to me you should have to backtransform the planes of the unit cube by multiplying by the inverse projection matrix...so I have two questions: why the source code of the frustum culling routine just get the real projection matrix (and NOT the inverse) and simply multiply it by the modelview??? then it multiplies the result by the normal-vectors of the unit cube and that's all???...

and anyway...the OpenGL documentation says that if you call gluPerpsective or glFrustum TWO perspective matrices are produced: R and R^-1, but HOW can you get the inverse matrice??....sorry If I have post a sort of beginner question http://www.opengl.org/discussion_boards/ubb/wink.gif

Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.