Nadradený pojem:

Alpha
blending combines the colour of the current primitive with the colour already
in the frame buffer.

Terminology:

In the blending equation,** s**
and **d** are
blending factors, that describe how much of the source and destination colours
to use when producing the blended result.

In OpenGL, the blending factors are enumerants, not direct values. The blending factors are set with

*glBlendFunc (GLenum s, GLenum d);*

There
are many possible values s
and d can
take. Some of the common ones include

Perhaps the most common blending function is

*glBlendFunc (**GL_SRC_ALPHA,
GL_ONE_MINUS_SRC_ALPHA);*

This tells OpenGL to take the source colour and multiply it by the source alpha value. The destination colour is multiplied by one minus the source alpha. The result is the sum of these two terms.

This blending function is often used to render a transparent object in front of an opaque object. To get the desired effect,

Terminology:

- The
colour value already stored in the frame buffer is the
*destination colour***(Cd)** - The
colour value that is coming into the frame buffer is the
*source colour***(Cs)** - By default, the blending equation is

In the blending equation,

In OpenGL, the blending factors are enumerants, not direct values. The blending factors are set with

*GL_ONE**GL_ZERO**GL_SRC_ALPHA**GL_ONE_MINUS_SRC_ALPHA*

Perhaps the most common blending function is

This tells OpenGL to take the source colour and multiply it by the source alpha value. The destination colour is multiplied by one minus the source alpha. The result is the sum of these two terms.

This blending function is often used to render a transparent object in front of an opaque object. To get the desired effect,

- Draw the opaque objects first before drawing the transparent ones
- If you’re rendering back-facing polygons, it may be necessary to draw the transparent polygons far to near after depth sorting the polygons (based on distance to the camera). This is called the painter’s algorithm.
- Otherwise,
use
*glEnable(GL_CULL_FACE)*to eliminate back-facing triangles.

High

Nadradený pojem: