|
Author Topic:   Determining object visibility quick and dirty
JamesC
Member
posted June 11, 2000 01:43 AM            
Just running some ideas through the grinder... Any comments on if this would work or not?

Say you have a fixed FOV in your engine and its 90 deg. Knowing this, wouldn't it be easy to quickly determine if a object is in the FOV by creating a triangle with the 90 deg angle point at 0,0,0, then transforming that triangle by the view matrix (to get the proper camera position and viewing angle) and then doing a simple point/poly test to see if the center point of the object is inside the triangle? I know the center point test is not very accurate, but this is a quick and dirty test after all Keep in mind I am only thinking about this in 2d BTW, on the x and z plane, I'm not really worried about the y value.. (thinking of how this would work for terrain "patch" visibility testing)

IP:

Chris C
Member
posted June 15, 2000 06:12 PM         
Should work OK - basically you're just projecting the 3d view frustum (if I understand correctly) onto the landscape 2d x-z plane and turning the 3d visibility problem into a 2d one.

By using a triangle, you're making the assumption that the viewer is always looking ahead, parallel with the ground - if the viewer looks up or down the 2d projection breaks down somewhat. To do a proper 3d point in view volume test would require 6 3d inside tests (ie. for each view volume plane) compared to your suggested 3 2d inside tests - your idea, taking into account a few special cases (viewer looking up/down), would be faster. But, it's not as impressive as the speed ups you'd get by using a top-down hierarchical bounding-box/sphere technique. As I think Michael Abrash once said - "the fastest instruction is the on that is never executed" - using hierarchical techniques you can eliminate large numbers of inside tests and focus on those that likely to succeed. Of course, in conjunction with hierarchical techniques your idea will certainly improve performance if implemented correctly.

Just some thoughts!

IP:

JamesC
Member
posted June 16, 2000 03:03 PM            
Actually, after discussing it with some other people, it got even faster.. knowing that your just testing a point, if your FOV is fixed to 90, then you could treat that point as a vector and just test the angle between the look vector and the point vector and see if its greater than 45 deg, if so, its not visible. There are some problems though, and I've haven't gotten it to work correctly yet. Basically the point will have to be in camera space, so both vectors originate from 0,0,0 to get the proper angle. To do this, you could subtract the cameras position from the point, but then what about camera rotation? I was trying to pull all the camera information I needed out of a D3D view matrix, trust me, its harder than it sounds... I do have a separate camera class but I wanted to achieve the blackbox effect by not making the terrain dependent on the camera class by retrieving the view matrix when I needed it, oh well.

IP: