Culling scene objects in flash

Not being satisfied with my current methods for object culling I set out on a new adventure in actionscript.

The most common method is culling spheres against the view frustum in world space, and from what I have seen in implementations in other engines it is not very efficient.
(you can be checking the spheres against up to 6 planes in 3d space)

The current technique I was using was to project all my objects bounding box vertices to screen space then from there it is a very trivial check to see if any of those points are in the viewport and if so, then render the object. The downside to this method is that it requires all the bounding boxes vertices to be projected into world space then on to the screen, that means that an individual matrix is required per object and must be regenerated whenever the object moves.

My latest efforts get round the need for these matrices, here be the demo(s).
(still a few kinks in it but the idea is solid I think)

500 cubes
1000 cubes
5000 cubes beware it may destroy your machine
(if you could report any frame-rates with specs that would be ace and appreciated)

all the cubes are rendering perspectively correct textures too.

mouse wheel to move camera in/out CAUTION: the further out you go the more work it’s gotta do to render so be gentle!!

if people are interested how I did it, be sure to ask, and once I have worked it out myself (some crazy hacky math in there) then I can explain 🙂

will also up some other demos that better showcase what is going on… have tested this with over 20,000 cubes and still hit 30fps as long as only a minimal number are required to be rendered.

b

6 Responses to “Culling scene objects in flash”

  1. very impressive! keep it up !
    (TWSS) I know..
    🙂

  2. sindney says:

    This is awesome!
    Can’t wait to try it out!
    😛

  3. Emil says:

    Hey,

    Nice examples, all running 30 fps on my machine.

    I was wondering if you had any examples on where to learn about the relation between model view and camera matrices. I’ve found some resources but they’re all for objective c.

    //total 3d noob

  4. bwhiting says:

    a little example of how stuff works

    If it would help I could put together a small article on matrices and flash and put it up next week. I think for a lot of people they are quite hard to grasp as a concept in 3d.

    b

  5. Dominik says:

    Hi,
    good job on your demo there but i have a little remark for your 5000 cube one. I saw that u put all those cube very far from the camera making them very small and fast to render. Just saying because i saw the same thing at the site of away 3d. Triangles size cannot be expected so for an example its not good to use this.

    Have a good day,

    Dominik

  6. bwhiting says:

    cheers for your feedback but there was method to my madness 🙂

    this is a demo for culling, showing that large numbers of objects can be culled at little expense.
    ideally the rendering would be off all together, but just numbers are less interesting than seeing some cubes as well.
    if I had but the cubes closer the rendering cost would have countered the speed of the culling too much I think.

    ben

Leave a Reply