ok, got it
your VOLUMETEXTURE, is not really an alpha channel its a mask.
so continuing with your step 4...
4) Render your VOLUMETEXTURE to the SCREENTEXTURE
using glBlendFunc(GL_DST_COLOR,GL_ZERO);
5) Then you render the SCREENTEXTURE on top of your whole scene using this:
glColor4f(1.0f,1.0f,1.0f,your_blending_factor);
glBlendFunc(GL_SRC_ALPHA,GL_ONE);
or, this:
glColor4f(1.0f,1.0f,1.0f,your_blending_factor);
glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
Problem building a heat effect using a particle engine (with screenshots)
Hi snisarenko, and thx for helping. What do you mean exactly with
4) Render your VOLUMETEXTURE to the SCREENTEXTURE
using glBlendFunc(GL_DST_COLOR,GL_ZERO);
Do you mean i just render the VOLUMETEXTURE on top of the whole scene too ?
4) Render your VOLUMETEXTURE to the SCREENTEXTURE
using glBlendFunc(GL_DST_COLOR,GL_ZERO);
Do you mean i just render the VOLUMETEXTURE on top of the whole scene too ?
-penetrator
Do you mean i just render the VOLUMETEXTURE on top of the whole scene too ?
I mean you render your VOLUMETEXTURE on top of the whole scene in you SCENETEXTURE (you render to the SCENETEXTURE itself), not in the frame buffer. Then you render your modified SCENETEXTURE on top of the actual scene. Hope its clear
P.S. the way your trying to do this is not the fastest. You should try it with particles instead of a cone volume.
[edited by - snisarenko on April 18, 2004 6:29:01 PM]
Do you mean i just render the VOLUMETEXTURE on top of the whole scene too ?
I mean you render your VOLUMETEXTURE on top of the whole scene in you SCENETEXTURE (you render to the SCENETEXTURE itself), not in the frame buffer. Then you render your modified SCENETEXTURE on top of the actual scene. Hope its clear
P.S. the way your trying to do this is not the fastest. You should try it with particles instead of a cone volume.
[edited by - snisarenko on April 18, 2004 6:29:01 PM]
The fastest and cheapest way to do it is to smear oil on your screen were the heat should be. Works great for still images
you don''t really need the second texture (volume texture) - render the texture using a colour mask of glColorMask(1,1,1,0) - so the alpha stays black - assuming that you clear it to black - then when finished rendering the scene, set glColorMask(0,0,0,1) and render the cone as white (or better yet, render many cones of different size additivly, so you get a blur for the volume)...
When rendering the texture onto the screen, just use simple alpha blending (glBlendFunc(GL_SRC_ALPHA,GL_SRC_ONE_MINUS_ALPHA);...
that should work a treat.
go one step further with a shader to add some shimer and your done.
| - My project website - | - email me - |
When rendering the texture onto the screen, just use simple alpha blending (glBlendFunc(GL_SRC_ALPHA,GL_SRC_ONE_MINUS_ALPHA);...
that should work a treat.
go one step further with a shader to add some shimer and your done.
| - My project website - | - email me - |
Finally i found out how to make it work, thanks to everybody. If you take a look at this page , you will see that i''m rendering a simple quad with a texture which is the result of two "modulated" textures (through a fragment program). Any idea on how to get rid of the black area, making i.e. transparent with the blackground ? I tried with several blendfunc combinations and didn''t work.
This is the render() function:
void render( void )
{
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
glClearColor(1,1,1,1);
setShaderConstants();
glMatrixMode( GL_MODELVIEW );
glEnable( GL_VERTEX_PROGRAM_ARB );
glBindProgramARB( GL_VERTEX_PROGRAM_ARB, g_vertexProgramID );
glEnable( GL_FRAGMENT_PROGRAM_ARB );
glBindProgramARB( GL_FRAGMENT_PROGRAM_ARB, g_pixelProgramID );
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glActiveTextureARB( GL_TEXTURE0_ARB );
glBindTexture( GL_TEXTURE_2D, g_textureID_1 );
glActiveTextureARB( GL_TEXTURE1_ARB );
glBindTexture( GL_TEXTURE_2D, g_textureID_0 );
glLoadIdentity();
glTranslatef( 0.0f, 0.0f, -3.8f );
glRotatef( -g_fSpinY, 1.0f, 0.0f, 0.0f );
glRotatef( -g_fSpinX, 0.0f, 1.0f, 0.0f );
glColor4f(0,1,0,1);
glInterleavedArrays( GL_T2F_C3F_V3F, 0, g_quadVertices );
glDrawArrays( GL_QUADS, 0, 4 );
glEnd();
glDisable( GL_FRAGMENT_PROGRAM_ARB );
glDisable( GL_VERTEX_PROGRAM_ARB );
SwapBuffers( g_hDC );
}
If you "feel" like it, at this link you can download the complete VC++ project (it''s about 270Kb). It''s a modified version of a Kevin Harris tutorial which i found very useful.
This is the render() function:
void render( void )
{
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
glClearColor(1,1,1,1);
setShaderConstants();
glMatrixMode( GL_MODELVIEW );
glEnable( GL_VERTEX_PROGRAM_ARB );
glBindProgramARB( GL_VERTEX_PROGRAM_ARB, g_vertexProgramID );
glEnable( GL_FRAGMENT_PROGRAM_ARB );
glBindProgramARB( GL_FRAGMENT_PROGRAM_ARB, g_pixelProgramID );
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glActiveTextureARB( GL_TEXTURE0_ARB );
glBindTexture( GL_TEXTURE_2D, g_textureID_1 );
glActiveTextureARB( GL_TEXTURE1_ARB );
glBindTexture( GL_TEXTURE_2D, g_textureID_0 );
glLoadIdentity();
glTranslatef( 0.0f, 0.0f, -3.8f );
glRotatef( -g_fSpinY, 1.0f, 0.0f, 0.0f );
glRotatef( -g_fSpinX, 0.0f, 1.0f, 0.0f );
glColor4f(0,1,0,1);
glInterleavedArrays( GL_T2F_C3F_V3F, 0, g_quadVertices );
glDrawArrays( GL_QUADS, 0, 4 );
glEnd();
glDisable( GL_FRAGMENT_PROGRAM_ARB );
glDisable( GL_VERTEX_PROGRAM_ARB );
SwapBuffers( g_hDC );
}
If you "feel" like it, at this link you can download the complete VC++ project (it''s about 270Kb). It''s a modified version of a Kevin Harris tutorial which i found very useful.
is the texture2 all look like that or is it''s alpha channel completely white?
| - My project website - | - email me - |
| - My project website - | - email me - |
the RGB of texture 2 you are showing is black with a white oval, is the alpha channel also like this? or is the alpha channel completely white, or, does the texture not have an alpha channel, in which case it''s treated as completely white?
because if it is completly white, then your output will always have alpha value of 1, so it won''t be transparent, and it will have a black background.
BTW. also, you don''t need to mutliply the RGB components, otherwise you will get a black edge to your shape (when you get the transparency right)
on the other hand, you could do what I suggested before and not have the second texture, and just write directly the the alpha channel of the first texture, which I still think is your best bet.
| - My project website - | - email me - |
because if it is completly white, then your output will always have alpha value of 1, so it won''t be transparent, and it will have a black background.
BTW. also, you don''t need to mutliply the RGB components, otherwise you will get a black edge to your shape (when you get the transparency right)
on the other hand, you could do what I suggested before and not have the second texture, and just write directly the the alpha channel of the first texture, which I still think is your best bet.
| - My project website - | - email me - |
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement