Culling optimizations
Posted: Mon Jan 08, 2007 9:31 am
I added this:
http://sourceforge.net/tracker/index.ph ... tid=540678
let me explain some of the problems in the old frustum culling:
This code is doing something strange! i belive is moving the camera frustrum to 'pseudorandom' position conected by the node location.
Personaly i don't belive the camera frustrum should be oriented/moved/scalled! to the node position because we want to to the culling on the actual pozitions .. + unuseful operations ...
Any way what is this doing is not really important because there are more important problems.
An other error i think is that isFrontFacing say if the edges and the plan have the same 'view' orientation and no not give any real useful culling information. Obviously 2 boxes will have many plane orientation / edge orientation.
But the biggest problem is that
is not doing any think.
Even if isFrontFacing will be classifyPointRelation or whatever there will ALWAYS! be edges what will be in front/oriented with the plane.
So right now the EAC_FRUSTUM_BOX is an more CPU expensive version of EAC_OFF.
Also doing directly frustum_box culling with out checking box culling will result in bad performance and lot of not needed calculations.
Also very important the EAC_OFF from the iscenenode constructor should be EAC_FRUSTUM_BOX or at least EAC_BOX. We want some default culling!
http://sourceforge.net/tracker/index.ph ... tid=540678
let me explain some of the problems in the old frustum culling:
Code: Select all
//transform the frustum to the node's current absolute transformation
core::matrix4 invTrans(node->getAbsoluteTransformation());
invTrans.makeInverse();
frust.transform(invTrans);
Personaly i don't belive the camera frustrum should be oriented/moved/scalled! to the node position because we want to to the culling on the actual pozitions .. + unuseful operations ...
Any way what is this doing is not really important because there are more important problems.
Code: Select all
for (i=0; i<scene::SViewFrustum::VF_PLANE_COUNT; ++i)
{
bool boxInFrustrum = false;
for (int j=0; j<8; ++j)
{
if (frust.planes[i].isFrontFacing(edges[j]) )
{
boxInFrustrum = true;
break;
}
}
if (!boxInFrustrum)
{
visible = false;
break;
}
}
An other error i think is that isFrontFacing say if the edges and the plan have the same 'view' orientation and no not give any real useful culling information. Obviously 2 boxes will have many plane orientation / edge orientation.
But the biggest problem is that
Code: Select all
for (int j=0; j<8; ++j)
{
if (frust.planes[i].isFrontFacing(edges[j]) )
{
boxInFrustrum = true;
break;
}
}
Even if isFrontFacing will be classifyPointRelation or whatever there will ALWAYS! be edges what will be in front/oriented with the plane.
So right now the EAC_FRUSTUM_BOX is an more CPU expensive version of EAC_OFF.
Also doing directly frustum_box culling with out checking box culling will result in bad performance and lot of not needed calculations.
Also very important the EAC_OFF from the iscenenode constructor should be EAC_FRUSTUM_BOX or at least EAC_BOX. We want some default culling!