core | glapi | vbo | math | shader | swrast | swrast_setup | tnl | tnl_dd

s_fog.c File Reference

#include "main/glheader.h"
#include "main/colormac.h"
#include "main/context.h"
#include "main/macros.h"
#include "s_context.h"
#include "s_fog.h"

Defines

#define LINEAR_FOG(f, coord)   f = (fogEnd - coord) * fogScale
#define EXP_FOG(f, coord)   f = EXPF(density * coord)
#define EXP2_FOG(f, coord)
#define BLEND_FOG(f, coord)   f = coord
#define FOG_LOOP(TYPE, FOG_FUNC)
 Template code for computing fog blend factor and applying it to colors.
#define FOG_LOOP_CI(FOG_FUNC)

Functions

GLfloat _swrast_z_to_fogfactor (GLcontext *ctx, GLfloat z)
 Used to convert current raster distance to a fog factor in [0,1].
void _swrast_fog_rgba_span (const GLcontext *ctx, SWspan *span)
 Apply fog to a span of RGBA pixels.
void _swrast_fog_ci_span (const GLcontext *ctx, SWspan *span)
 As above, but color index mode.


Define Documentation

#define BLEND_FOG ( f,
coord   )     f = coord

#define EXP2_FOG ( f,
coord   ) 

Value:

do {                                                    \
   GLfloat tmp = negDensitySquared * coord * coord;     \
   if (tmp < FLT_MIN_10_EXP)                            \
      tmp = FLT_MIN_10_EXP;                             \
   f = EXPF(tmp);                                       \
 } while(0)

#define EXP_FOG ( f,
coord   )     f = EXPF(density * coord)

#define FOG_LOOP ( TYPE,
FOG_FUNC   ) 

Template code for computing fog blend factor and applying it to colors.

Parameters:
TYPE either GLubyte, GLushort or GLfloat.
COMPUTE_F code to compute the fog blend factor, f.

#define FOG_LOOP_CI ( FOG_FUNC   ) 

Value:

if (span->arrayAttribs & FRAG_BIT_FOGC) {                                       \
   GLuint i;                                                                    \
   for (i = 0; i < span->end; i++) {                                            \
      const GLfloat fogCoord = span->array->attribs[FRAG_ATTRIB_FOGC][i][0];    \
      const GLfloat c = FABSF(fogCoord);                                        \
      GLfloat f;                                                                \
      FOG_FUNC(f, c);                                                           \
      f = CLAMP(f, 0.0F, 1.0F);                                                 \
      index[i] = (GLuint) ((GLfloat) index[i] + (1.0F - f) * fogIndex);         \
   }                                                                            \
}                                                                               \
else {                                                                          \
   const GLfloat fogStep = span->attrStepX[FRAG_ATTRIB_FOGC][0];                \
   GLfloat fogCoord = span->attrStart[FRAG_ATTRIB_FOGC][0];                     \
   const GLfloat wStep = span->attrStepX[FRAG_ATTRIB_WPOS][3];                  \
   GLfloat w = span->attrStart[FRAG_ATTRIB_WPOS][3];                            \
   GLuint i;                                                                    \
   for (i = 0; i < span->end; i++) {                                            \
      const GLfloat c = FABSF(fogCoord) / w;                                    \
      GLfloat f;                                                                \
      FOG_FUNC(f, c);                                                           \
      f = CLAMP(f, 0.0F, 1.0F);                                                 \
      index[i] = (GLuint) ((GLfloat) index[i] + (1.0F - f) * fogIndex);         \
      fogCoord += fogStep;                                                      \
      w += wStep;                                                               \
   }                                                                            \
}

#define LINEAR_FOG ( f,
coord   )     f = (fogEnd - coord) * fogScale


Function Documentation

void _swrast_fog_ci_span ( const GLcontext ctx,
SWspan span 
)

As above, but color index mode.

void _swrast_fog_rgba_span ( const GLcontext ctx,
SWspan span 
)

Apply fog to a span of RGBA pixels.

The fog value are either in the span->array->fog array or interpolated from the fog/fogStep values. They fog values are either fog coordinates (Z) or fog blend factors. _PreferPixelFog should be in sync with that state!

GLfloat _swrast_z_to_fogfactor ( GLcontext ctx,
GLfloat  z 
)

Used to convert current raster distance to a fog factor in [0,1].


Generated on Sun Sep 27 06:48:05 2009 for Mesa Software Rasterization (swrast) by  doxygen 1.5.4