blending problems..

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

Recommended Posts

I can get the required effect from blending a dark color with my building textures to make it look like nighttime. However I don't understand why it works... eg table 6.1 page 228 of the red book gives the blending fucntion parameters. GL_ONE rgb factor=(1,1,1) alpha =1 Therefore if I want to blend my dark color with my texture - I can assume that the dark color is the source, the texture is the destination. I have not specified an alpha color for each. The blend function is:
glEnable(GL_BLEND);
glBlendFunc(GL_ONE, GL_ONE); ///THIS IS THE BLEND
glEnable(GL_TEXTURE_2D);
glEnable(GL_COLOR_MATERIAL);
glColor3f(0.1f, 0.1f, 0.1f);
glBindTexture(GL_TEXTURE_2D, buildingTex);


So according to page 226 the resultant color of say the red channel and the alpha after blending would be (1*Rd + 1*Rs,...... 1*Ad+1*As) which you would think would give a totally non transparent building with color channel equal to the combined value of 0.1 + the color channel. Instead it's transparent.
I then tried
glBlendFunc(GL_SRC_COLOR, GL_DST_COLOR)

which you would think would take the color of the glColor and combine it with the color of the building tex - but that blend too is transparent !
I don't get it !


So although I can get this to work with other values - the values that I would use from reading the red book don't do as I expect. So can someone explain how to use the values and know what's going on so I can get it right and know why its right? cheers [Edited by - ade-the-heat on May 14, 2005 7:37:36 AM]

Share on other sites
I don't think you understand what GL_BLEND does. It's used to blend incoming fragments(pixels, if you want it, altough fragments are more correct term) with those that are already in the framebuffer. It doesn't "blend" textures or colors in the same pass. More precisely, it multiplies the source and destination fragments with the factors that you supply in glBlendFunc and then adds them together.

In your case, GL reads the texture color, it modulates it(if your TexEnv is GL_MODULATE) with the primary color. That's the current(source) fragment color. Then it adds that value to the already present(destination) fragment.

Share on other sites
Quote:
 Original post by mikemanIn your case, GL reads the texture color, it modulates it(if your TexEnv is GL_MODULATE) with the primary color. That's the current(source) fragment color. Then it adds that value to the already present(destination) fragment.

That was my understanding as well,

Share on other sites
perhaps of interest requires fltk
http://uk.geocities.com/sloppyturds/stuff/opengl_blending.zip

Share on other sites
Quote:
 Original post by zedzeekperhaps of interest requires fltkhttp://uk.geocities.com/sloppyturds/stuff/opengl_blending.zip

Handydandy. cheers zed.

Share on other sites
Quote:
 Original post by zedzeekperhaps of interest requires fltkhttp://uk.geocities.com/sloppyturds/stuff/opengl_blending.zip

fab thanks

1. 1
2. 2
3. 3
Rutin
19
4. 4
khawk
14
5. 5
frob
12

• 9
• 11
• 11
• 23
• 12
• Forum Statistics

• Total Topics
633659
• Total Posts
3013210
×