View frustum culling questions

zeboidlund

So, I'm trying to implement frustum culling. The thing here is that before I can do that, I need to understand some things.

First of which, is plane intersection:

My understanding is that a plane can be defined via 3 points; let's call them p0, p1, and p2.

Given that, we know that the plane's normal can be computed as follows:

(psuedo-code)

vec3 edge0 = p1 - p0;
vec3 edge1 = p2 - p0;

vec3 normal = normalize( cross( edge0, edg1 ) ) // => edge1 X edge2 / length( edge1 X edge2 );

Now, let's say we have a function which basically tells us whether or not a given point "crosses" the plane in some way.

(moar pseudo-code)

bool crossesPlane( vec3 plane[3], vec3 point )
{
    vec3 normal = getNormal( plane ); // perform same operations as described above
    float D = dot( -normal, plane[ 0 ] ); // plane[ 0 ] is arbitrary - could just as well be the 2nd or 3rd point in the array

    float dist = dot(normal, point) + D; 

    return dist >= 0; // dist < 0 means we're on the opposite side of the plane's normal. 
}

The logical reasoning behind this is that, since the view-frustum contains six separate planes ( near, far, left, up, right, bottom ), we'd want to grab each of these six planes and essentially "pass" them to the crossesPlane() function, for an individual point (one point, six tests for that point).

If one of these six calls to crossesPlane() returns false, then we want to cull the point in question, thus effectively resulting in the point being culled by the frustum, and of course the point won't be rendered.

Questions

  • Is this a correct approach to a properly culled view-frustum?
  • If so, would taking an arbitrary list of vertices for a given polygon, and performing this test on each of the vertices using this method, be an effective way of going about it?
  • While AABBs can be used in place of polygon's/meshes for cull tests, are they still commonly used for this scenario, and are they still considered the "general" goto approach?

Note

If there are any implementation differences worth mentioning between D3D and OpenGL for this, it would be certainly appreciated.

mattnewport
  • Yes, this is essentially the correct approach for frustum culling points.
  • No, performing this test on each vertex individually is not an effective way of culling an arbitrary polygon. Consider the case of a single very large triangle that intersects the frustum: all of it's vertices may be outside the frustum but the triangle still intersects the frustum and should be rendered.
  • AABBs can be used for frustum culling and are often a good choice, although you still have to handle the case of an AABB having all of it's vertices outside the frustum but intersecting the frustum. Bounding spheres make the inside / outside test somewhat simpler but tend to have looser bounds around the objects they contain. This is often a reasonable tradeoff however.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

CodeIgniter View Input Questions

From Dev

Processing camera frustum() and perspective() rotations

From Dev

How to draw frustum in opengl

From Dev

OpenGL Frustum Pedagogy

From Dev

Frustum and sphere intersection

From Dev

OpenTK/OpenGL Frustum Culling Clipping Too Soon

From Dev

lwjgl texture culling incorrect

From Dev

How To Draw A Frustum in OpenGL

From Dev

Back face culling for linestrips

From Dev

Java OpenGL - Calculating orthographic frustum for isometric view

From Dev

Back face culling in SceneKit

From Dev

React native list view questions

From Dev

Efficient frustum culling while using shaders

From Dev

Choice of sphere/frustum overlap test

From Dev

3D to 2D projection using view frustum has issues with translation

From Dev

Is is possible to calculate the view frustum with only the: aspectRatio, y_scale, x_scale and frustum_length?

From Dev

View frustum culling questions

From Dev

View Frustum Culling corner cases

From Dev

Libgdx view frustum culling inside actor.draw()

From Dev

How to draw frustum in opengl

From Dev

Frustum and sphere intersection

From Dev

Is the "top" of a view frustum considered the top of the near plane?

From Dev

Orthographic Frustum?

From Dev

Cross Viewport oclussion culling

From Dev

View frustum culling for animated meshes

From Dev

Does culling affect animation

From Dev

Current frustum culling effects results in flickering objects in openTk

From Dev

Babylon.js disable frustum culling for SolidParticleSystem?

From Dev

Instance geometry Frustum culling