Table of Contents Glide Programming Guide


Chapter 8. Special Effects 1In This Chapter



Download 6.22 Mb.
Page46/106
Date03.02.2023
Size6.22 Mb.
#60547
1   ...   42   43   44   45   46   47   48   49   ...   106
GLIDEPGM

Chapter 8. Special Effects

1In This Chapter


Glide supports several different types of special effects, including fog, chroma-keying, and alpha testing. Fog simulates atmospheric conditions like fog, mist, smog, or smoke that partially obscure distant objects. Chroma-keying can be used to create a blue screen effect, removing all pixels that are a specific color. Alpha masking uses the low order bit of the incoming alpha value to invalidate pixels.
You will learn how to:

  • produce fog using the alpha iterator

  • create a fog table and use it to create atmospheric effects

  • configure the fog and alpha blending units for multi-pass fogging

  • use chroma-keying to simulate a blue screen

  • use alpha testing to simulate a blue screen

2Fog


Fog is a rendering technique that adds realism to computer-generated scenes by making distant objects appear to fade away. Fog is a general term representing all atmospheric effects: haze, mist, smoke, smog. It is essential in visual simulations like flight simulators to produce the effect of limited visibility. When fogging is enabled, distant objects fade into the fog color. Both the fog color and the fog density (the rate at which objects fade as a function of their distance from the viewer) are programmable.
Glide and the Voodoo Graphics hardware support per-pixel fog blending operations. The fog unit is separate from the alpha blending unit, so both fog and transparency may be applied simultaneously. Fog is applied after texturing and lighting, and may improve performance in large simulations: some objects may be lost in the fog and can be culled before rendering.
Fog is applied after color combining and before alpha blending, as shown in the pixel pipeline flow diagram in Figure An Introduction to Glide.2.
The fog operation blends the fog color (cfog) with each rasterized pixel’s post-texturing color (cin) using a blending factor f. Factor f is retrieved from the high order bits of the iterated alpha value or from a user downloaded fog table indexed with the pixel’s 1/w component. The fog operation blends a global (cfog) with each rasterized pixel’s color (cin) using a blending factor f. A value of f=0 indicates minimum fog density and a value of f=255 indicates maximum fog density.
The general fog equation is shown below.
cout = f cfog + (1-f )cin
The fog mode, set with grFogMode(), shapes the fog equation to the situation, as shown in Table Special Effects.1.
void grFogMode( GrFogMode_t mode )

The mode argument can be one of five values: GR_FOG_DISABLE, GR_FOG_WITH_ITERATED_ALPHA, GR_FOG_WITH_TABLE, GR_FOG_ADD2, or GR_FOG_MULT2. The last two modes have been created to facilitate multi-pass fogging applications and are used in conjunction with GR_FOG_WITH_ITERATED_ALPHA or GR_FOG_WITH_TABLE.



  1. Table Special Effects.1 The fog mode shapes the fog equation.

The general form of the fog equation is cout = f cfog + (1-f )cin. The mode argument to grFogMode() tailors the general equation for a specific situation, as shown below. The first three modes are mutually exclusive: choose one. Modes GR_FOG_ADD2 and GR_FOG_MULT2 are used in tandem with either GR_FOG_WITH_ITERATED_ALPHA or GR_FOG_WITH_TABLE.



if mode sets



the fog equation is

where cin is the color entering the fog unit, cout is the result of fogging, cfog is the fog color and

GR_FOG_DISABLE

cout = cin




GR_FOG_WITH_ITERATED_ALPHA

cout = ai cfog + (1-ai)cin

ai is the high order byte of the iterated alpha value

GR_FOG_WITH_TABLE

cout = ffog[w] · cfog + (1- ffog[w]) · cin


Download 6.22 Mb.

Share with your friends:
1   ...   42   43   44   45   46   47   48   49   ...   106




The database is protected by copyright ©ininet.org 2024
send message

    Main page