9.5.12

The right tools for the right job


Last year I bought a Wacom Bamboo tablet to enjoy my free time studying some digital art with Krita and MyPaint. I lent it to my girlfriend for a few months after 2011 Christmas so she could have some fun too. Angela was here in Natal last week (while the Lakademy was happening in Porto Alegre, south of Brazil ) and she brought it back. I askd her to bring it to me so I could use it while I am working in my GSoC project.


just a test i made when Krita 2.4 was still in Alpha 3

It takes some time to get used to this kind of input device but after that it's really fun to do things with it. I really love drawing, but the reason why I bought a tablet was that my  painting skills it's quite low. I get jealous very easily from other artists works.
Anyway, another point: Angela bought my Qt4 book too, since I had left it in Teresina after I moved to Natal.

I am not a KDE (not even a Qt ) experienced programmer, so the book will help a lot in some things I am doing. For instance, I corrected some points in my granular particles simulation and now I have some right values in it's output. Although some errors persists, I got some key values right. It's just some numbers in a text file, but as soon I eliminate some Batman lyrics (NaNs are one of my nightmares), the next step it's to pass the generated values to a sequence of QImages and see if the particles got the right pixels and the right movements.

a speed painting Angela made with my wacom

As I said in previous posts, this project it's not a easy one. It requires a real-time approach to a not so common particle type. The simulation I did have some serious performance drawbacks. For just a few particles (200 particles in the data set randomly initialized and distributed in a euclidean plane of size 100x100 units) the simulation takes almost 3 minutes to run 1000 steps, with a few wrong outputs !! It's a really bad result.

After that, I gathered a handfull of books related to the topic. Physics and engineering are the fundamentals, but a real-time approach it's the more important feature in the project. I got a book with my university advicer about real-time collision detection in the hope that it will help me do a better job in this simulation.

Real-time collisions, linear algebra, engineering math and Qt/C++ : the tools for the job
Another point is that I'm thinking of trying to see the actual state of it using a OpenCL approach. I have access to a relative good computer in the university: a i3 intel processor with 4Gb of RAM with a NVidia graphics board. With that, what need to be done it's some self-training in this tecnology. I never coded in OpenCL before and the talk around here is that it's really hard. I check it out with a few OpenCL tutorials and I have to agree with the guys: it's really tough. A simple hello world pass through all kinds of concepts, from context creation, through devices association to kernel programming. Fortunately, I found a few books about it too.

Anyway, if you want to check it out the actual state of my simulation, the repository is hosted in my gitorious account. I did not allowed merge requests since the code it's quite unstable, but it's well commented and have some references if you want to understand it better. I'm already writting another post with the theory behind the simulation, doing a more extensive and well detailed explanation of the concepts (some few drawings and formulas for our enlightment :)

Until next round!

5 comentários:

  1. Sounds like you're off to a good start! I wonder if there may be ways to "cheat" something like this rather than simulating every single particle of sand. Like how most fluid sims don't simulate every molecule of water, but usually use a lower resolution 3d grid made up of 3d vectors. In many ways sand acts more like a fluid until it's isolated from other large masses. Not that I really have any idea, not being a programmer, but I do wonder. Anyway, good luck (especially if you try the openCL approach!). Most of all, have fun and learn a lot!

    Bugsbane

    PS Angela's obviously very talented, too. Nice speed painting!

    ResponderExcluir
  2. Thanks Bugsbane!

    I'm doing the most simple simulation as cited in this book http://is.gd/OvSRyH.
    In a more advanced chapter it cites the use of a window to limit the amount of particles per step. This is probably the next phase for this simulation, right after passing the current state for the QImages.

    Now, as a matter of fact, sand acts like fluid when large amounts of it move at the same time. A close concept is smoothed-particle hydrodinamics, which simulates real fluid particles like water, oil or even wind. However, this model have some attractive forces between particles, messing up with the opportunity to use this theory to simulate sand, since grains don't have cohesive forces. I think that in the due time I'll find where I can do some optimizations, removing some unnecessary calculations (I already had removed some, but generated previous errors. Instead, I did the complete simulation so I could see if the theory really works).

    Anyway, thanks again for the reply!

    Ps.: Angela thanked your compliment too! :)

    ResponderExcluir
  3. rapaz é tão bom ler o blog de um brazuka no planet KDE que da até vontade de chorar =D , como é que se faz pra fazer parte?

    ResponderExcluir
  4. Olá Jonathas!

    No topo da pagina do Planet KDE (http://planetkde.org/ ) tem o link Add Your Blog dando as guidelines de como adicionar seu blog no agregador. No entanto, para fazer parte do Planet KDE é mandatório que você já contribua para o projeto de alguma forma, como por exemplo design, artwork, promoção ou código.

    Nós estamos precisando muito de pessoas para contribuir na parte de arte e design, então se você quiser nos ajudar de alguma forma nesse aspecto você é mais do que bem-vindo. Se você estiver interessado, dê uma olhada nesses links:

    http://community.kde.org/Getinvolved/art (Guia de como contribuir no projeto)
    http://pinheiro-kde.blogspot.com.br/ (Blog do principal designer do KDE )
    http://kde-look.org/ (Pagina para customizar o KDE)

    Qualquer coisa, dê as caras la na lista do Kde-Brasil (https://mail.kde.org/mailman/listinfo/kde-br) e receba nossas boas vindas!

    Um abraço

    ResponderExcluir
  5. One very easy thing to do with usually great payoffs is to subdivide the simulation domain (the image) into a regular grid, with a cell size roughly on the order of the neighborhood search you want to do. When you drop particles assign them to the cells, and for simulation you simply have to search the current cell and neighboring cells for potential interactions, instead of potentially the whole domain. You can even use a quadtree for better memory efficiency - subdivide based on the number of particles per cell up to a minimum cell size, that way you'll have adaptive subdivision based on how your particles are distributed :)

    opiesche at gmail dot com

    ResponderExcluir