   Rendering flow density field
  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?   
  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.sHope this helps. :)   ;  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.   ;  Thanks guys, amazingly quick :PYeah this will definately get me started, read about marching cubes in a publication that achieved some excellent graphics. Thanksedit: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 shadinghttp://i44.tinypic.com/vsnls7.jpgfor 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];  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.   ;  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.   ;  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 :)   ;  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.   ;  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.   ;  Very helpful, thank you   