Adventures in culling
by Kevin Johnson · in Torque Game Engine Advanced · 11/13/2005 (10:50 am) · 5 replies
Ok, so I got simple bounding box occlusion working for most object types..
(dif->dif,dts->dts,dts->dif)
Following Clarks optimization resource, now i'm getting some pretty good results..
From ingame tests i'm seeing 20-50% increase in fps across the board. The bad news is i'm getting alot of false positives..so I've decide to move the check to use convex hull volumes. I wanna do something like this:
then loop through shell's poly list to determine the edgelist.
But the above code crashes when calling the buildconvex for the object (in this case TSStaic ~line 405.
I'm not sure I'm calling this the right way, and the only place i see a real usage for buildconvex() is in convex.cpp. so can someone give me a quick look and verify im using buildconvex correctly, or maybe point me in the right direction?
edit:updated code.
(dif->dif,dts->dts,dts->dif)
Following Clarks optimization resource, now i'm getting some pretty good results..
From ingame tests i'm seeing 20-50% increase in fps across the board. The bad news is i'm getting alot of false positives..so I've decide to move the check to use convex hull volumes. I wanna do something like this:
const Box3F& rBox = pObj->getWorldBox();
// using occlusion hull volumes
Convex *shell = new Convex();
pObj->buildConvex( rBox,shell); then loop through shell's poly list to determine the edgelist.
But the above code crashes when calling the buildconvex for the object (in this case TSStaic ~line 405.
// See if this hull exists in the working set already...
Convex* cc = 0;
CollisionWorkingList& wl = convex->getWorkingList();
KABOOM--> for (CollisionWorkingList* itr = wl.wLink.mNext; itr != &wl; itr = itr->wLink.mNext) {
if (itr->mConvex->getType() == TSStaticConvexType &&
(static_cast<TSStaticConvex*>(itr->mConvex)->pStatic == this &&
static_cast<TSStaticConvex*>(itr->mConvex)->hullId == i)) {
cc = itr->mConvex;
break;
}I'm not sure I'm calling this the right way, and the only place i see a real usage for buildconvex() is in convex.cpp. so can someone give me a quick look and verify im using buildconvex correctly, or maybe point me in the right direction?
edit:updated code.
#2
You could correct for this by figuring out the average percentage of false positives, and use that value as an error metric. Basically scaling (shrinking) the bounding boxes to reduce the number of false positives. Of course, too much shrinking will cause false negatives...
11/13/2005 (2:42 pm)
On a sidenote: How many false positives were you getting with your bounding box method? I wonder how much of the 20-50% improvement is actually from not rendering those false positives.You could correct for this by figuring out the average percentage of false positives, and use that value as an error metric. Basically scaling (shrinking) the bounding boxes to reduce the number of false positives. Of course, too much shrinking will cause false negatives...
#3
@rustan - the false positives are actually due to the caching method i am using. ie if an object is culled this frame , dont check again for ~ 15 frames. My occlusion check function relys on castrays, so its not really something i can do every frame without reaching a point of diminishing returns..
11/13/2005 (3:08 pm)
@brian - I was under the impression that after buildConvex returns, shell would point to the convexhull just generated for pObj, or is that not how it works?@rustan - the false positives are actually due to the caching method i am using. ie if an object is culled this frame , dont check again for ~ 15 frames. My occlusion check function relys on castrays, so its not really something i can do every frame without reaching a point of diminishing returns..
#4
buildConvex fills the convex that you pass in with information about itself. If you look at the TSStatic::buildConvex call specifically, you can see it:
convex = shell in your case.
Hope that helps.
11/13/2005 (5:06 pm)
Kevin,buildConvex fills the convex that you pass in with information about itself. If you look at the TSStatic::buildConvex call specifically, you can see it:
// Create a new convex.
TSStaticConvex* cp = new TSStaticConvex;
mConvexList->registerObject(cp);
convex->addToWorkingList(cp);convex = shell in your case.
Hope that helps.
Torque Owner Brian Richardson
// using occlusion hull volumes Convex* shell = 0; ... CollisionWorkingList& wl = convex->getWorkingList();You're passing shell into BuildConvex, which you've initialized to 0. So the working list you've gotten back is invalid.
You might want to create a BoxConvex to pass into the function, the box should be init'ed to the area that you're interested in getting polys back for.
(These are all guesses of course..heh)