Archived

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

okonomiyaki

Trying to get glBlendFunc to do what I want..

Recommended Posts

okonomiyaki    548
I will admit that I don't understand exactly how glBlendFunc works, so it's hard to piece together what I should set to make it act like I want. I get the basics of it, but for some reason it's hard to visualize destination scaling with source scaling and it all blending together according to the set parameters. I played around with it a little, but could not get it to do what I wanted. This is (again) about putting clouds in my sky. I have it basically working except for how it blends. I am rendering a skydome with colors first and then a skyplane that is textured with clouds. After rendering the skydome, I want to render the sky plane with a texture that has varying degrees of alpha. I want the texture to blend with the skydome so that the clouds will show and shine with it's color when the texture is fully opaque, but the texture is see through when it's totally transparent. Of course there are varying degrees of translucency. The setting that seemed to work the best was GL_SRC_ALPHA and GL_ONE_MINUS_SRC_ALPHA. However, this affects the color of my clouds. It draws the clouds right (where I can see the skydome color through the blank areas) but it's shading my clouds for some reason with a color from the skydome. I know parts of the clouds are partially translucent, but look at this: And the day goes on and changes color... See how it's actually coloring my clouds? I don't want it to do that, I just want it to blend with what's in the frame buffer, and those parts are opaque anyway so they should be showing their cloud color. Is there a setting with glBlendFunc that will achieve this correctly? [edited by - okonomiyaki on January 23, 2004 5:47:24 PM]

Share this post


Link to post
Share on other sites
Buzzy    312
GL_SRC_ALPHA and GL_ONE_MINUS_SRC_ALPHA should work the way you want it. Check to make sure that you are setting the color to white before drawing the clouds. If you''re not changing the color then it may still be on the last color used to draw the skydome, which will blend with the texture color of the clouds.

--Buzzy

Share this post


Link to post
Share on other sites
FReY    424
I have a sneaking suspicion that when you render your skydome you use glColorX(...) somewhere but forget to reset it to pure white for your sky plane.

Try a glColor3f(1.0f, 1.0f, 1.0f) just before you render your clouds. This will affect your vertex colours if you''re not already manually setting them.

Share this post


Link to post
Share on other sites
okonomiyaki    548
oh goodness, that's exactly it. I'm still really used to DirectX, this extremely state-based machine is kind of weird
Thanks a lot guys! It looks much better now.

[edited by - okonomiyaki on January 24, 2004 1:37:54 PM]

Share this post


Link to post
Share on other sites