Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

ByteMe95

OpenGl Blending Problem/Question

This topic is 6370 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey everyone. I''m working on my first 3d Demo in OpenGl. I just started learning OpenGl a few months ago, pretty much all from this great site. Anyway, I'';ve run into a problem in my demo. I''m trying to make a demo of a rocket ship blasting off. So I got the rocket''s flame to look pretty good using a particle engine, and they all blend together, whatever and it looked good on a black background. But now I want to put in a blue sky background, and when I do the problem I have is that the rocket flame is not only blending with itself to get the right effect, it blends itself in with the blue sky background and doesn''t look right. So, my main question is, how can I have it set up that the rocket flame particle engine only blends with itself, and not with the sky background? Thanks in advance ByteMe95::~ByteMe95() Cerebrum Software

Share this post


Link to post
Share on other sites
Advertisement
Hi,

1. Draw the sky.

2. Enable the blending ==> glEnable(GL_BLEND)

3. Draw your rocket

4. Disable the blending ==> glDisable(GL_BLEND)





Leyder Dylan

dylan.leyder@ibelgique.com

Share this post


Link to post
Share on other sites
Hmm, I just tried both of those suggestings but they didnt work. I think it''s that even though I dont draw the sky with blending, when i draw the particles in blending they blend with the sky in the background, i guess it blends with whatever is in the frame buffer, I think.

I tried the GL_ONE , GL_ONE_MINUS_SRC_ALPHA, but that didnt work, the particles weren''t transparent anymore for some reason.

???

ByteMe95::~ByteMe95()
Cerebrum Software

Share this post


Link to post
Share on other sites
I dont think I really know what an alhpa channel is.

I do use alpha blending for the particles, they all have an alpha intensity from 0.0 - 1.0, and then I use glColor4f() with the alpha value and render it.

That''s it, what exactly is an alhpa channel?

ByteMe95::~ByteMe95()
Cerebrum Software

Share this post


Link to post
Share on other sites
So can anyone help me with this problem or not?
I''ve been stuck on this one problem for well over a month and my demo hasn''t progressed at ALL because of it

any help would be appreciated
PPPPLLLLEEEEEAAAAASSSSEEEE!!!
(Damn, I promised myself i wouldnt beg! oh well)

;o)

ByteMe95::~ByteMe95()
Cerebrum Software

Share this post


Link to post
Share on other sites
An alpha channel is an additional channel found in several image formats. Targe .tga and personal network graphics .png files come to my mind first. More or less, you have the RGB channels, then the additionals contain all kinds of extras. when I use tga files, I make a mask using the selection tool in paint shop and add that to the alpha channel.

For example:
A common particle bitmap is usually a sphere that is lightest in the center, and darkens towards the edges. The black portion of the image can be copied, and a solid white circle placed in the center of the image that lines up with the last visible portion of your particle. This allows you to use true transparency versus blending which can lead to image distortion. Common particle engines will show the square edge of the quad or triangle if you lighten the background. With alpha channel transparencies there aren''t any egdes, the alpha channel is used to mask the black in the texture.

If I''m not making this very clear, take a close look at Lesson 20, which covers this topic by using a second bitmap as a mask. Using alpha channels is just an advanced way of doing the same thing with only one image.

Jason

Share this post


Link to post
Share on other sites
Hmm, ok, I think I get alpha channels now, I did read lesson 20 so I know what you mean.

Now, my next question is how can I use alpha channels to help my problem? The problem isn''t that the square edges are showing, it''s just that the particles, which should range from red to red-orange in color, are getting blended with the blue background and instead of being red/red-orange are pretty much bright white.

...
Ok, I just took the time to make some screen shots of the rocket with the sky and without it. I should''ve done this a long time ago to demonstrate the real problem instead of trying to exlpain it I guess. I''m not sure if i could put html tags in here, if it doesnt work, just go to the specified URL to check it out:

Without Sky:


With Sky:


Hope I did that right.

ByteMe95::~ByteMe95()
Cerebrum Software

Share this post


Link to post
Share on other sites
Just taking a stab in the dark here, but maybe your sky texture is still bound when you draw your particles.

Try disabling texturing just before you draw your particles (of course, this is assuming that your particles do not use a texture... if they do, make sure you are binding that texture before drawing) like so:

...
Bind sky texture.
Draw sky.
Bind Rocket texture (or disable texturing with glDisable(GL_TEXTURE_2D) )
Draw Rocket.
(Bind particle texture if you''re using one...)
Enable blending.
Draw Particles.
Disable blending.
...

Like I said, I''m just taking a wild swing, but that''s what your pictures look like (ie, they seem to be just using the pixel colour from the last texture coordinate set while drawing with your sky texture).

Hope that was somewhat useful (or at least amusing in its stupidity )

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!