Advertisement

Blending question for clouds

Started by August 09, 2004 07:01 AM
0 comments, last by Lutz 20 years, 4 months ago
Hello, in an earlier version of my app, I rendered billboards with cloud textures that contain alpha directly to the screen after everything else has been rendered. That worked fine. I used glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); But now I'm rendering all those billboards into a pbuffer with alpha and in most cases, I'm rendering the generated pbuffer texture, not the billboards. However, I don't know how to set the right blending modes, because it always doesn't look how it should. Questions: - What should be the clear color for my pbuffer? glClearColor(0,0,0,0)? glClearColor(1,1,1,0)? - What blending mode should I use to render the billboards into the pbuffer? glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ) ? - What blending mode should I use to render the pbuffer? glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ) ? The above three examples don't work because all billboards tend to be a little bit black where it's alpha is not 1. Also the white isn't visible enough, because the alpha value of e.g. 0.5 is applied TWICE :( Any ideas? Regards, Lyve
_____________________________________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.
I plan to include clouds to my app and I'm going to render them to a billboard and then render the billboards to the screen. I guess I will face the same problems as you.

I can't answer the question but I know how you can find out the solution. However, it involves a little bit paper-work. Write up (on a piece of paper) what happens to a single color in the frame buffer when you render the billboards (the way you did it in the old days). You should get an equation like

new color = ( (frame buffer color) * alpha_1 + color_1*(1-alpha_1) ) * (alpha_2) + color_2 * (1-alpha_2) ...

where alpha_n and color_n are alpha and color of the n-th billboard (n=1 is the farmost billboard and so on). Then, try to write the new color into the form

new color = (frame buffer color) * (some value) + (some color) * (another value)

Then, "some value" and "another value" give you two alphas for blending (if you're lucky, "some value" will be 1 - "another value") and "some color" will be the pbuffer color. This will tell you how to compose the pbuffer.

I haven't done it myself but it shouldn't take longer than half an hour or so.

Lutz

This topic is closed to new replies.

Advertisement