general blending versus texture blending questions

Member
Posts: 321
Joined: 2004.10
Post: #1
I'm still fighting this in my head some of OpenGL. Could someone please clarify.

Chapter 7: Blending, Antialiasing, and Fog

Alpha values are specified with glColor*(), when using glClearColor(), to specify a clearing color, and when specifying certain lighting parameters such as a material property or light-source intensity. As you learned in Chapter 5 , the pixels on a monitor screen emit red, green, and blue light, which is controlled by the red, green, and blue color values. So how does an alpha value affect what gets drawn in a window on the screen? When blending is enabled, the alpha value is used to combine the color value of the fragment being processed with that of the pixel already stored in the framebuffer.

Chapter 9: Texture Mapping

the examples so far in this chapter, the values in the texture map have been used directly as colors to be painted on the surface being rendered. You can also use the values in the texture map to modulate the color that the surface would be painted without texturing, or to blend the color in the texture map with the non-textured color of the surface.



Just some clarifications; I’ll call the blending in Chapter 7, “General Blending” and the Chapter 9 blending, “Texture Blending”.


Is texture blending always done before general blending?


Once texture blending is done, does this surface+texture then become the “color value of the fragment being processed with that of the pixel already stored in the frambuffer”, as described in Chapter 5?


In texture blending, the 2d texture array is blended with the “color of the surface”. Is the color of the surface specified in glColor*() function mentioned in Chapter 7 or through some other mechanism that i've missed?
Quote this message in a reply
Moderator
Posts: 1,560
Joined: 2003.10
Post: #2
In simple cases, you can think of the behavior as multiplying each component in each pixel in the texture by the each component of the current glColor. So, for example, if the current color is {1, 0, 0, 0.5} (50% red), and the texture color is {1, 1, 1, 0.5} (50% white), you'll get {1, 0, 0, 0.25} (25% red).
Quote this message in a reply
Sage
Posts: 1,232
Joined: 2002.10
Post: #3
Refer to the OpenGL block diagram.

What you're calling "texture blending" is really TexEnv, in the "Texture Application" block.
What you're calling "general blending" is blending, in the "Per-fragment operations" block.

To look at the whole pipeline:
* your app sets up state (texture data, bindings, environment etc)
* your app passes in vertices with some attributes (color, normal, texcoords, etc)
* vertex processing transforms the attributes and passes some values on to fragment processing. For example:
** transform vertex position by the modelview-projection matrix
** calculate vertex color using normal and lights (or pass through glColor...)
** pass through texcoords (or do envmap transform, etc)
* fragment processing takes the attributes from vertex processing and outputs a final fragment color. For example:
** use texcoord to look up a texel in the bound texture
** modulate it with vertex color (etc etc)
* finally, a number of per-fragment operations are performed before writing the color into the framebuffer. These include tests that can discard the fragment (depth test etc) and blending.
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  GL Blending Question SethWillits 2 4,518 Jun 28, 2012 03:25 PM
Last Post: Charybdis
  2d shadow blending problems tesil 1 5,628 Mar 17, 2011 10:12 AM
Last Post: Skorche
  Using blending for a text fading effect. cjcaufield 2 4,273 Jun 30, 2010 08:21 PM
Last Post: cjcaufield
  pbuffer blending problem on macmin g4 madjerry 4 3,702 Nov 27, 2009 03:14 AM
Last Post: madjerry
  Alpha blending weirdness on GMA 950 akb825 15 8,820 Sep 1, 2009 06:22 PM
Last Post: arekkusu