Strange frustum problem...

Started by
14 comments, last by cozzie 13 years, 6 months ago
Thanks, knowing this I would suggest the following approach:

One time loading/initializing:

- calculate radius for full mesh/object
- calculate radius for subobjects
- calculate 8 AABB corners for subobjects

RenderFrame:

- update camera
- occlusioncull
- if full mesh/object visible:
- for each sububject: check if sphere's in frustum
- for each subobject: check against 8x AABB box
- if both true, then render

OcclusionCull:

- check if full mesh/object is in frustum, using radius and sphere in frustum
if so, full mesh visible = true

Would this be a good approach?

I also considered keeping track per full and sub-object if it has to be checked using boundingbox or sphere, but I doubt if that will help.

Crealysm game & engine development: http://www.crealysm.com

Looking for a passionate, disciplined and structured producer? PM me

Advertisement
Quote:- if full mesh/object visible:

If, by "full" you mean some portion is visible, that looks like a good approach. Certainly precalculating as many parameters as possible will give benefits.

As you obviously realize, the fastest draw for a triangle is one that's not drawn at all.

Take note, cozzie, that, if you're concerned about performance, you might want to do some profiling to make sure your algorithm is, in fact, showing some benefit under actual game conditions.

Quote:I also considered keeping track per full and sub-object if it has to be checked using boundingbox or sphere, but I doubt if that will help.

Probably of less benefit than the frustum culling you're already going to do. But, at the expense of a single bool variable per object (if it can be precalculated) and a single "should-I-check-AABB?" statement, there may be a marginal benefit.

Please don't PM me with questions. Post them in the forums for everyone's benefit, and I can embarrass myself publicly.

You don't forget how to play when you grow old; you grow old when you forget how to play.

Hi
I implemented the 8x AABB boundingbox check, not very clean code yet, but first to see if it works.

Here it is:

// one time per subobject			mAttrBoundingBox[obj].boxArray[0].x = mAttrBoundingBox[obj].min.x;			mAttrBoundingBox[obj].boxArray[0].y = mAttrBoundingBox[obj].min.y;			mAttrBoundingBox[obj].boxArray[0].z = mAttrBoundingBox[obj].min.z;			mAttrBoundingBox[obj].boxArray[1].x = mAttrBoundingBox[obj].max.x;			mAttrBoundingBox[obj].boxArray[1].y = mAttrBoundingBox[obj].min.y;			mAttrBoundingBox[obj].boxArray[1].z = mAttrBoundingBox[obj].min.z;			mAttrBoundingBox[obj].boxArray[2].x = mAttrBoundingBox[obj].max.x;			mAttrBoundingBox[obj].boxArray[2].y = mAttrBoundingBox[obj].max.y;			mAttrBoundingBox[obj].boxArray[2].z = mAttrBoundingBox[obj].min.z;			mAttrBoundingBox[obj].boxArray[3].x = mAttrBoundingBox[obj].min.x;			mAttrBoundingBox[obj].boxArray[3].y = mAttrBoundingBox[obj].max.y;			mAttrBoundingBox[obj].boxArray[3].z = mAttrBoundingBox[obj].min.z;			mAttrBoundingBox[obj].boxArray[4].x = mAttrBoundingBox[obj].min.x;			mAttrBoundingBox[obj].boxArray[4].y = mAttrBoundingBox[obj].min.y;			mAttrBoundingBox[obj].boxArray[4].z = mAttrBoundingBox[obj].max.z;			mAttrBoundingBox[obj].boxArray[5].x = mAttrBoundingBox[obj].max.x;			mAttrBoundingBox[obj].boxArray[5].y = mAttrBoundingBox[obj].min.y;			mAttrBoundingBox[obj].boxArray[5].z = mAttrBoundingBox[obj].max.z;			mAttrBoundingBox[obj].boxArray[6].x = mAttrBoundingBox[obj].max.x;			mAttrBoundingBox[obj].boxArray[6].y = mAttrBoundingBox[obj].max.y;			mAttrBoundingBox[obj].boxArray[6].z = mAttrBoundingBox[obj].max.z;			mAttrBoundingBox[obj].boxArray[7].x = mAttrBoundingBox[obj].min.x;			mAttrBoundingBox[obj].boxArray[7].y = mAttrBoundingBox[obj].max.y;			mAttrBoundingBox[obj].boxArray[7].z = mAttrBoundingBox[obj].max.z;// check functionbool CD3dcam::BoxInFrustum(BOUNDINGBOX *pBoundingBox){	float fDistance;	for(int i=0;i<6;++i)    {		for(int bc=0;bc<8;++bc)		{			fDistance = D3DXPlaneDotCoord(&mFrustumPlane, &pBoundingBox->boxArray[bc]);			if(fDistance >= 0) return true;		}	}	return false;}

Unfortunately everything is still rendered/ returned as true.
Probably has something to do with return true to early, although I don't understand. Will try some things.

If you see something that's wrong, please let me know.

Crealysm game & engine development: http://www.crealysm.com

Looking for a passionate, disciplined and structured producer? PM me

Use debugger, or debug on paper. We can do it for you, but why should we?
You don't have to check all 8 corners of the AABB. Google 'aabb plane test', 'box plane test', 'aabb frustum culling', or similar terms, and you should find some example implementations.

In particular, look for references that talk about the 'n-vertex' and the 'p-vertex' (I think that's the terminology that's often used). This actually still isn't the fastest method available (I don't believe), but it seems to be better documented than the alternatives.
Good point :)

Solved it, I was looking for something difficult, but it was something stupid.

I did this: BoxInFrustum(&mD3dMeshes[oc].mAttrBoundingBox) which had to be
BoxInFrustum(&mD3dMeshes[oc].mAttrBoundingBox[obj]).
Stupid.

Got it all working know, that's for the help.
Next thing I'll do is do a much larger testscene and see if it's quicker or nog to keep track of 'check 8x AABB' or not.

Crealysm game & engine development: http://www.crealysm.com

Looking for a passionate, disciplined and structured producer? PM me

This topic is closed to new replies.

Advertisement