Blending
How can I remove the blend color from the ClearColor() ?
Actually what I`m meaning is that I want to blend only the colors from my particles and where the particles get a... fire color(with black background), in the blue background I get almost all the fire very white...
Well it`s more like this : Where my particles are not existing fill the empty space with the background color, but where 2 or more particles blend I don`t want the background color added to that . I don`t know how to post pics because I`d put 2 ...
Relative Games - My apps
So, if the particles don''t have to blend with the background, what should they blend with ? with a black color ? act as if blending was disabled ?
If you can tell me how to post pics in the forum I`ll show you
Relative Games - My apps
Well I did the old way... put it on geocities.
Here`s the sample->
http://www.geocities.com/cippyboy_7/fire_black.jpg
http://www.geocities.com/cippyboy_7/fire_blue.jpg
Notice the difference in the fire colors when changing the background . With black it seems perfect but wiht blue it`s too white . And yes I really want to have blue background and the particles act as if it was black .
Here`s the sample->
http://www.geocities.com/cippyboy_7/fire_black.jpg
http://www.geocities.com/cippyboy_7/fire_blue.jpg
Notice the difference in the fire colors when changing the background . With black it seems perfect but wiht blue it`s too white . And yes I really want to have blue background and the particles act as if it was black .
Relative Games - My apps
Ever wondered why games do prefer showing fire effects in dark scenes ? Now you know 
First, I think that the bright render is not that bad. Sure it doesn't look quite a nice as the render over a black background, but in fact really bright backgrounds are not likely to happen very often in real scenes since the detail in the background (textures, etc) will not let the problem appear as clearly as it is now (the screenshot shown can be considered as one of the worst case scenario, isn't it ?)
Anyway, if you really want to correct it, there is a solution which works if :
1- your texture has an alpha channel
2- if your framebuffer has an alpha channel (check GL_ALPHA_BITS with glGet)
The method is rather simple in fact, just write a black background where you know that fire will be rendered, you can do this with the following algorithm :
1- set the alpha clear component to be 0, eg : glClearColor(red_clear, green_clear, blue_clear, 0)
2- disable alpha writes for all your objects except fire : glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_FALSE)
3- render your objects now (not fire yet)
4- enable alpha writes but disable color writes : glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_TRUE)
5- enable blending and set the function to glBlendFunc(GL_ONE, GL_ONE)
6- render you fire (disable depth writes now if you don't do it in the fire rendering code)
7- enable color writes and disable alpha writes, just like in step 2
8- render a black quad over the screen, with the blending function set to : glBlendFunc(GL_DST_ALPHA, GL_ONE_MINUS_DST_ALPHA)
9- now you just have to render your fire as you did before.
If you don't have an alpha buffer, you can do subtractive blending or emulate it with modulation, but still it works (it just looks a bit different).
[edited by - vincoof on October 31, 2003 7:37:26 AM]

First, I think that the bright render is not that bad. Sure it doesn't look quite a nice as the render over a black background, but in fact really bright backgrounds are not likely to happen very often in real scenes since the detail in the background (textures, etc) will not let the problem appear as clearly as it is now (the screenshot shown can be considered as one of the worst case scenario, isn't it ?)
Anyway, if you really want to correct it, there is a solution which works if :
1- your texture has an alpha channel
2- if your framebuffer has an alpha channel (check GL_ALPHA_BITS with glGet)
The method is rather simple in fact, just write a black background where you know that fire will be rendered, you can do this with the following algorithm :
1- set the alpha clear component to be 0, eg : glClearColor(red_clear, green_clear, blue_clear, 0)
2- disable alpha writes for all your objects except fire : glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_FALSE)
3- render your objects now (not fire yet)
4- enable alpha writes but disable color writes : glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_TRUE)
5- enable blending and set the function to glBlendFunc(GL_ONE, GL_ONE)
6- render you fire (disable depth writes now if you don't do it in the fire rendering code)
7- enable color writes and disable alpha writes, just like in step 2
8- render a black quad over the screen, with the blending function set to : glBlendFunc(GL_DST_ALPHA, GL_ONE_MINUS_DST_ALPHA)
9- now you just have to render your fire as you did before.
If you don't have an alpha buffer, you can do subtractive blending or emulate it with modulation, but still it works (it just looks a bit different).
[edited by - vincoof on October 31, 2003 7:37:26 AM]
Thanks but I think I`m gonna pass although I really need that for my enviroment, I think I`ll give it a try and see how it comes out, by the way is there any other blendfunc that could just.. ignore the background ?
Relative Games - My apps
It sounds to me like you just should disable blending, and use alpha testing, and everywhere where your fire is at an alpha level > 0, it will be "blended" with a black color
_____________________________________http://www.winmaze.de, a 3D shoot em up in OpenGL, nice graphics, multiplayer, chat rooms, a nice community, worth visiting! ;)http://www.spheretris.tk, an upcoming Tetrisphere clone for windows, a 3D tetris game on a sphere with powerful graphics for Geforce FX and similar graphics cards.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement