Particles in BGE Update: Collisions

We have collisions!
Check out the video to see how it looks

This is a preview of collisions working in our OpenCL Particle System addition to the Blender Game Engine. We can collide against triangle meshes of objects that are marked as colliders. The particle system and the objects can be manipulated through the logic bricks in real-time. The particles are also now rendered using global coordinates so that moving and rotating the emitter does not move the whole system.

On a Macbook Pro we can collide 1000 particles against 1000 triangles in a scene at about 50fps, with another advancement using bounding boxes to optimize that my DSC advisor Gordon wrote we should see about a 5x speedup. I just need to implement it into Blender! Also if one uses a lot less triangles (or carefully chooses the meshes you want to collide against) you can maintain 60fps. For now I’m showing “worst case” performance until we tune it and add more options to compare it to (bounding box, bounding sphere). On the GTX 480 (Fermi architecture) running on Ubuntu we can do 65k particles against the same 1000 triangles at 60fps. The fps doesn’t dip below 60 until about 100k particles.

Now that we see it working, I have a lot of cleaning up and benchmarking to do. Stay tuned for a more complete writeup!

13 thoughts on “Particles in BGE Update: Collisions

  1. Pingback: Tweets that mention Particles in BGE Update: Collisions | enj -- Topsy.com

  2. Blenderificus

    !!!!!!! wow wow wow. This in trunk would be AWESOME!!! cant wait to see the next demo

  3. Bo

    Wow that’s amazing ! thanks so much for your efforts .. I was wondering is your work also applicable for the regular viewport ? or just the game engine ? And if not, any plans for it ?

  4. Georg

    Thanks for sharing this development vids and a little of the technical insight. Keep going.

  5. Martin Lindelöf

    In my dreams after Ian has done his thesis, and gets to become ocl multicore computing master ! he helps other blender devs speed up their part of the code that takes a lot of computing.

    I mean we have Nicholas doing bullet physic integration, and next version of it. 3.X will have OCL acceleration. so for the viewport speed ups we might get it for free. :)

    anyways, you mentioned Gordon the advisor, helping you speed the collisions when using custom shapes (ie. not bounding boxes) using triangular meshes. But doing the speed up by somehow using the bounding boxes, is that like … using the bounding boxes as calculations , until the particle that’s gonna hit it, enters the objects bounding box then it switches over and goes through the triangles to find the collision point?.

    anyways 5x speedups sounds awesome!

  6. enj Post author

    Martin,

    I still have a lot to learn! I do hope we can see more OCL adoption in Blender as time goes on.

    As for the collisions, yes that is right, only the bounding boxes are checked against until one is hit, then it checks against the triangles inside. I have a lot more reading to do on that subject, apparently you can do some cool stuff with spatial hashing (but things like kd-trees don’t port well to the GPU)

  7. Lukas Tönne

    Hi Ian!

    This is great work! I have just “discovered” OpenCL and i am totally excited about the idea of using it in combination with the simulation nodes :D
    Atm the these node trees are using “classic” multithreading on the CPU and an ad-hoc batch processing model: data from the scene (currently only vertex positions and some basic particle attributes) is copied into fixed-size batches, which are then processed per node by available worker threads. It is already very efficient as far as one can tell from the simple arithmetic nodes i made so far, but i’d gladly replace this with OpenCL for increased efficiency and better parallel design.

    Currently i’m further improving the node interface capabilities to combine them with the RNA, so that basically all the properties in Blenders API can be used inside the node trees with a generic GetData/SetData node. When this works i’ll start digging deeper into OpenCL (your tutorials are awesome!) Any help would of course be appreciated, maybe we can actually join forces some day?!

    Cheers
    Lukas

    PS: i love the turtle ;)

  8. enj Post author

    Lukas,
    Your work is very impressive! I’d be happy to help if I can, and I hope our projects can converge, OpenCL should be able to speed up many things in Blender :)

    About my previous kd-tree statement and spatial hashing, there are a few relevant papers anyone interested could check out:

    Popov et al. Stackless kd-tree traversal for high performance GPU ray tracing. Computer Graphics Forum (2007) vol. 26 (3) pp. 415-424

    Rozen et al. GPU bucket sort algorithm with applications to nearest-neighbour search. Journal of the 16th Int. Conf. in Central Europe on Computer Graphics, Visualization and Computer Vision (February 2008)

  9. Alex Fraser

    This is really exciting stuff. We are exploring this area at work at the moment, and it would be great to be able to use Blender. I hope there will be room in my project for collaborating with you.

  10. Phil

    How well does your code scale on Ati Equipment?

    Again very impressed with what you are doing with OpenCL. I am looking forward to your new updates.

  11. enj Post author

    @alex looking forward to seeing what you guys are doing! hopefully Blender comes into play :)

    @Phil at the moment we need to test more on ATI hardware (our lab is all NVIDIA’s at the moment). I do have at least one friend with an ATI card but would appreciate any help on that front.

  12. Pingback: Adventures in OpenCL Part 2: Particles with OpenGL | enj

Comments are closed.