next up previous contents
Next: 15.3.3.2 No Alpha Buffer Up: 15.3.3 Rendering a Surface Previous: 15.3.3 Rendering a Surface   Contents

15.3.3.1 Alpha Buffer Approach

You render the internal object as before, then adjust the transparency of the resulting image by rendering the alpha-textured shell with the blend mode set to glBlendFuncGL_ ZERO, GL_ ONE_MINUS_SRC_ALPHA(GL_ ZERO, GL_ ONE_MINUS_SRC_ALPHA). The alpha values from the shell are used to scale the image of the object internals that have been rendered into the framebuffer. The alpha values themselves are also saved into the alpha buffer.

Now depth buffer update is disabled, and the surface textured shell is rendered, with the blend mode set to glBlendFuncGL_ ONE_MINUS_DST_ALPHA, GL_ ONE(GL_ ONE_MINUS_DST_ALPHA, GL_ ONE). In this way the internal part of the object, which has already been scaled by $1 - srcalpha$ is summed with the surface textured shell, which is blended by $1 - (1 - srcalpha) = srcalpha$, giving the desired result.

  1. Configure a window that can store alpha color values.
  2. Draw the object internals with depth buffering.
  3. Mask off depth buffer updates.
  4. Enable blend mode.
  5. glBlendFuncGL_ ZERO, GL_ ONE_MINUS_SRC_ALPHA(GL_ ZERO, GL_ ONE_MINUS_SRC_ALPHA)
  6. Draw alpha textured shell to adjust internal objects' transparency.
  7. glBlendFuncGL_ ONE_MINUS_DST_ALPHA, GL_ ONE(GL_ ONE_MINUS_DST_ALPHA, GL_ ONE)
  8. Disable 1D Texturing Enable 2D texturing.
  9. Render surface textured shell.


next up previous contents
Next: 15.3.3.2 No Alpha Buffer Up: 15.3.3 Rendering a Surface Previous: 15.3.3 Rendering a Surface   Contents
2001-01-10