Question

I need additional theory on view frustum culling to better understand how to implement it. I understand that ray casting is involved in order to figure out what objects are in front, thus figuring out which objects not to render.

I am concerned about CPU usage. From what I understand, I should be casting out rays by my camera's width * height, and maybe increase the amount of rays depending how far the camera sees. Additionally, I would have to multiply that by the amount of object in the scene to verify which is closest to the ray.

Is my understanding of this concept accurate? How exactly could I do this more efficiently?

edit:

The goal is to achieve some type of voxel engine where the world can be sub-divided-up using an oct-tree. It could consist of hundreds of thousands of cubes.

Was it helpful?

Solution

I don't think view frustum culling involves ray casting usually.

Normally you'd just z-transform all your geometry and then clip any polygons whose vertices fall outside of the viewport, or whose z value is greater or less than the near/far clipping planes.

Ray casting would be a lot more expensive, as you are essentially testing each pixel in the viewport to see if there's a polygon behind it, which is potentially NUMBER_OF_PIXELS * NUMBER_OF_POLYGONS math operations, instead of just NUMBER_OF_POLYGONS.

EDIT:

Oh, I see: You're trying to create a voxel-space world like Minecraft. That's a bit different.

The trick there is to make use of the fact that you know the world is a grid to avoid doing calculations for geometry that is occluded by cubes that are closer to the camera.

I'm still not sure that ray casting is the best approach for this - I suspect you want something like an oct-tree structure that lets you discard large groups of blocks quickly, but I'll let somebody with more experience of building such things weigh in ;-)

EDIT 2:

Looks like somebody else on StackOverflow had the same problem (and they used octrees): Culling techniques for rendering lots of cubes

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top