OpenGL Rendering flow density field

This topic is 3490 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

Hi guys, I am using the Lattice Boltzmann Equation to simulate condensation of vapor. The code is run in Matlab and the end result is a [x,y,z,time] matrix which I want to render using openGL. Now my question to you is how can this be done efficiently? Currently I am doing it in Matlab by simply plotting points with size and color dependent on the density at the location. Naturally openGL should be able to offer some more sophisticated solutions with transparency. Ultimately having some vapor (smoke) - water effect with raytracing wouldn't be too shabby but I am not really sure of how I would go about this. What can be done is that a cutoff density can be used in order to separate the vapor from water. Any ideas?

Share on other sites
Maybe you can do something with iso-density volumes (I just made that word up).

These are volumes in space that have approximately the same density. If your minimal density is 0 kg/m3 and maximum 1000 kg/m3, you could split your space up into 5 iso-density volumes. For example:

0-200,
200-400,
400-600,
600-800,
800-1000.

You need to generate 5 meshes that define these volumes, and render them using different levels of transparency. To generate these, you can goolge for "marching cubes" or "iso-surfaces".

I've never done such things, so there might be way better sollution.s

Hope this helps. :)

Share on other sites
For more fine-grained detail you could do raycasting on your dataset. For a basic rundown see here and this is an open-source raycasting implementation.

Share on other sites
Thanks guys, amazingly quick :P

Yeah this will definately get me started, read about marching cubes in a publication that achieved some excellent graphics. Thanks

edit:
On second thought I should actually start with my 2d..

given a 2d scalar matrix is there any software I can use to make a nice render? Such as pixel shading

http://i44.tinypic.com/vsnls7.jpg

for example given an image or a scalar field such as above, how could I make the blue part become smoke and the red part become fluid?

[Edited by - ponja on May 19, 2009 6:39:59 AM]

Share on other sites
In the 2D case, there isn't really much you can do, if you want it to look 'realistic'. Shading on a flat 2D surface is pretty boring, basically just a linear interpolation of intensity. Transparency won't look like much either, you will need a background for it to even show.

I suppose you could make it look like a thin cross-section, by using a slightly noised semi-transparent color for the vapors and a refracting material for the water, with a non-transparent border (since at a grazing angle the water surface is not transparent), and put it over e.g a checkered background for the transparency and refraction to take effect.

If you plan on generalizing to 3D later however, just skip the 2D part as the same techniques will hardly be applicable to 3D and still look good.

Share on other sites
Thank Morrandir that's helpful. The problem is that most of my heavy computations will be for 2d as 3d is unneccessary and as such I will have many final pictures in my report which will be 2d so it is necessary I try to make them look good.

Something like that wouldn't be too shabby. I guess I'm quite limited with Matlab though so when moving to c++ with just pure data I guess I have lots of options to choose from.

Share on other sites
Based solely on density information there isn't really that much you can do. The video you linked has velocity information, which drives a particle system and makes it look fancy :)

Share on other sites
I do have velocity information as well as pressure so everything should be available. Particle system is fine for animation but for stills is there anything I could use there to improve the visualization?

I found a great software for the 3d case which does volume rendering for me immediately =) so that's fine now.

Share on other sites
In that case, I would probably go with a particle system + blur. It would give the gaseous part a nice sense of 'flow', even on a still image. You can do a simple blur by blending together colors over 2-3 frames of an animation.

If you won't need animation at all, maybe you could 'cheat' a little, and not use a particle system (which would be the tough part to code). Instead you could use a static image, e.g. colored dots distributed evenly, and blur that directionally. Basically for each point, look at the velocity, choose the blur kernel most appropriate for the direction, do convolution. This is off the top of my head, so you'd need to experiment a bit to make it look just right, but has promise and is super easy to code.

Share on other sites
Very helpful, thank you

1. 1
2. 2
3. 3
Rutin
20
4. 4
khawk
14
5. 5
frob
12

• 9
• 11
• 11
• 23
• 12
• Forum Statistics

• Total Topics
633656
• Total Posts
3013191
×