@ ThE_JacO…thanks for the direction. I took your advise and did a quick exploratory research on how to write shaders. It looks like RenderMonkey supports OpenGL Shading Language and so, that might be my pick for this project because my code is entirely built on C++ and OpenGL. FYI, I use Visual Studio as a platform for running my solver.
I would still need more direction on this. I saw some simple tutorials to write a basic shader with a simple illumination model with a light source etc. But i have no clue as to how can I even start thinking in terms of rendering a smoke with a custom shader? Let me briefly explain what I am currently doing to display my smoke on the screen (just so you have some idea about what I am talking about)…
void draw_density ( void )
{
int i, j, k;
float _x0, _y0, _x1, _y1, hh,
float d000, d010, d100, d110, d001, d011, d101, d111; //to store density values
hh = 1.0f/150.0f;
glBegin ( GL_QUADS );
for ( i=0 ; i<W ; i++ ) {
x = (i-0.5f)*hh;
for ( j=0 ; j<H ; j++ ) {
y = (j-0.5f)*hh;
for(k=0; k<D; k++) {
d000 = S->St->gridCell[i][j][k];
d010 = S->St->gridCell[i][j+1][k];
d110 = S->St->gridCell[i+1][j+1][k];
d100 = S->St->gridCell[i+1][j][k];
d001 = S->St->gridCell[i][j][k+1];
d011 = S->St->gridCell[i][j+1][k+1];
d111 = S->St->gridCell[i+1][j+1][k+1];
d101 = S->St->gridCell[i+1][j][k+1];
_x0 = i*hh;
_y0 = j*hh;
_x1 = _x0 + hh*k*0.3f; //X transformed from 3D to 2D
_y1 = _y0 + hh*k*0.3f;//Y transformed from 3D to 2D
glColor4f ( d000, d000, d000, d000 );
glVertex2f(_x0, _y0);
glColor4f ( d010, d010, d010, d010 );
glVertex2f(_x0,_y0+hh);
glColor4f ( d110, d110, d110, d110 );
glVertex2f(_x0+hh,_y0+hh);
glColor4f ( d100, d100, d100, d100 );
glVertex2f(_x0+hh,_y0);
glColor4f ( d001, d001, d001, d001 );
glVertex2f(_x1, _y1);
glColor4f ( d011, d011, d011, d011 );
glVertex2f(_x1,_y1+hh);
glColor4f ( d111, d111, d111, d111 );
glVertex2f(_x1+hh,_y1+hh);
glColor4f ( d101, d101, d101, d101 );
glVertex2f(_x1+hh,_y1);
}
}
}
glEnd();
Basically, I have all the scalar (density) values stored in a 3D array, which I am using as color values to draw the quads. Also, I am transforming X and Y values from 3D to 2D by a simple projection formula (_x1 = _x0 + hhk0.3f), although this conversion doesnt seem to have that big a difference. I still only see a 2D flat image. My guess is if I could somehow use these scalar values in my custom shader ( which I am yet to learn to write :-p), will they be able to render properly as a 3D smoke? If I sound too vague, well, that’s how my understanding of shaders and rendering is still. If you need any other specific information about my code, I can provide that. But please please, help me with this part. I would highly appreciate it!
Thanks again.