Fluid volume simulation

Discussion in 'Rendering Technology and APIs' started by Voxilla, Dec 27, 2009.

  1. Voxilla

    Regular

    Joined:
    Jun 23, 2007
    Messages:
    440
    EDIT: New improved version 1.3 available

    Here another volume simulator, this time simulating an incompressible fluid solving the Navier- Stokes differential equations. The simulation runs in a 200x200x200 voxel box

    The calculations make use of a well known scheme of velocity advection, Jaccobi pressure solving and making the velocity divergence free by subtracting the gradient of the pressure.

    This is the so called Semi-Lagrangian scheme. A more accurate solver makes use of the second order MacCormack technique. The simulation makes use of the latter. However it makes the simulation unstable and introduces artifacts. Limiting generated extremes can fix this, unfortunately I was not able to get this working, so the simulation runs without limiters, still the result is some visual interesting turbulent behavior.

    The amplitude of the speed vectors are visualized. To make a 3d rendering, a simple ray maximum projection is used. This shoots rays through the volume searching the maximum speed along the ray. With a linear interpolation the speed is given some color.


    Controls:
    - mouse left drags a source on a plane through the center of the volume and parallel to the screen
    - mouse right to rotate the volume
    - mouse wheel to zoom in and out
    - space bar to toggle between MacCormack and Semi-Lagrangian simulation
     
    #1 Voxilla, Dec 27, 2009
    Last edited by a moderator: Jun 6, 2010
  2. fellix

    fellix Hey, You!
    Veteran

    Joined:
    Dec 4, 2004
    Messages:
    3,338
    Location:
    Varna, Bulgaria
    Works flawlessly here, on my 5870.
    ~28 FPS with the default settings.
     
  3. CNCAddict

    Regular

    Joined:
    Aug 14, 2005
    Messages:
    288
    Fellix, are you using the 9.12 hotfix drivers? I can't get my 5850 to run the application and I have all the latest drivers. I went to rerun all of Voxillas demos and QJulia4D is the only one that now works, the others crash immediately!!!
     
  4. fellix

    fellix Hey, You!
    Veteran

    Joined:
    Dec 4, 2004
    Messages:
    3,338
    Location:
    Varna, Bulgaria
    I'm with the 9.12 hotfix and all the demos out there (DC/OCL) are trouble-free for me. ;)

    Could it be from the OS? Mine is Win7 x86 w/ all the pre-SP1 patches and hotfixes (~130 in count).
     
  5. Forrest

    Newcomer

    Joined:
    Jul 22, 2008
    Messages:
    39
    Impressive demo, psychedelic stuff! :smile:
    Getting 15 FPS on 5770 here.
     
  6. Voxilla

    Regular

    Joined:
    Jun 23, 2007
    Messages:
    440
    It's possible to make this quite a bit faster still. The Jacobi iterations are especially expensive. Now 20 of them are done, meaning 20 times reading and writing the whole volume per frame.

    With vector maths, it could be made twice faster.
    As the simulation is mostly limited by memory bandwidth, the Jacobi iterations seem like a nice candidate for shared memory. However due to the nature of the iterations I'm not sure this is possible.
     
  7. guardian

    Newcomer

    Joined:
    Jul 3, 2008
    Messages:
    12
    I'm really new to OpenCL and Direct Compute, would it be possible to implement this effect targeting D3D_FEATURE_LEVEL_10_1?

    I'm asking because I only have a Radeon 4850 gpu.

    Thank you.
     
  8. CNCAddict

    Regular

    Joined:
    Aug 14, 2005
    Messages:
    288
    WOW, this looks great especially on the Semi-Lagrangian mode. The other mode has some strange artifacts along grid boundaries. Small marks aligned orthogonally?! It would be awesome to set this up as a screensaver with some random input. Great work Voxilla, you never cease to amaze!!!

    P.S. Anyone running Windows 7 64bit RC will need 9.11 drivers. 9.12 drivers have severe problems with DX11 on the Release Candidate.
     
  9. Voxilla

    Regular

    Joined:
    Jun 23, 2007
    Messages:
    440
    The semi Lagrangian looks ok, but it is a bit too smooth as velocity gets dissipated quickly. That's where the second order MacCormack should make things better by adding more detail and less dissipation.
    The artifacts you see are the result of using no limiters, there is one in the code but I could not get it working. If there is some computational fluids specialist around there, it would be great to get some hints.
    I've got it running 40% faster now, also fluid bounces correctly of the walls, but I want correct MacCormack first before releasing something new.
     
  10. Voxilla

    Regular

    Joined:
    Jun 23, 2007
    Messages:
    440
    It would be more difficult to process volumes (3d textures) as CS 4 compute shaders can only be dispatched over 2d domains. Working around this and other limitations might be possible.
     
  11. guardian

    Newcomer

    Joined:
    Jul 3, 2008
    Messages:
    12
    So I assume that if it was OpenCL, it would have the same restrictions, needing a fairly recent GPU (DX11 class) right?
     
  12. Voxilla

    Regular

    Joined:
    Jun 23, 2007
    Messages:
    440
    I did some tests with OpenCL, but even with a DX11 GPU there are currently limitations like not being able to sample textures, at least with ATI. This is something that will get fixed in drivers later on.
    DX10 GPUs would have similar limitations as CS4 using OpenCL, it's not something that can be solved in software, the DX10 hardware simply lacks features.
     
  13. fellix

    fellix Hey, You!
    Veteran

    Joined:
    Dec 4, 2004
    Messages:
    3,338
    Location:
    Varna, Bulgaria
    That would be the case of missing support for OpenGL interops, am I correct?
     
  14. Voxilla

    Regular

    Joined:
    Jun 23, 2007
    Messages:
    440
    No, you can do texture sampling in OpenCL without OpenGL.
     
  15. guardian

    Newcomer

    Joined:
    Jul 3, 2008
    Messages:
    12
    btw, do you have pointers to articles I should read to understand what's going on? (maybe something you read before implementing the effect)

    thx
    g.
     
  16. Voxilla

    Regular

    Joined:
    Jun 23, 2007
    Messages:
    440
  17. Voxilla

    Regular

    Joined:
    Jun 23, 2007
    Messages:
    440
    I've added a new version 1.2 the artifacts are gone and speed is up by about 40%.

    This new version has a more smoky aspect and smoke bounces off the wall.
    Instead of visualizing the velocity an advected fire reaction coordinate is rendered.
     
  18. fellix

    fellix Hey, You!
    Veteran

    Joined:
    Dec 4, 2004
    Messages:
    3,338
    Location:
    Varna, Bulgaria
    ~10 frames up for the new version. ;)
    Simulation is rendering much better now!
     
  19. Talonman

    Newcomer

    Joined:
    Jan 2, 2010
    Messages:
    64
    FYI - I would love to run this on my Windows 7 64 bit, but cant seem to find enough .dll files to make it happy. :wink:
    [​IMG]
     
  20. Voxilla

    Regular

    Joined:
    Jun 23, 2007
    Messages:
    440

Share This Page

Loading...