summaryrefslogtreecommitdiffstats
path: root/src/mesa/tnl/t_vb_fog.c
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2004-02-25 16:14:16 +0000
committerBrian Paul <[email protected]>2004-02-25 16:14:16 +0000
commit54056db8db4cba5163ef40a30511bbdd35f8a47a (patch)
tree51d3ca1af1b878b3be5373555ef011ec781bad4e /src/mesa/tnl/t_vb_fog.c
parent20e25ca50a6335fda3769f746165b5bbc2dfa95b (diff)
use ABS(Z) when computing blend factors
Diffstat (limited to 'src/mesa/tnl/t_vb_fog.c')
-rw-r--r--src/mesa/tnl/t_vb_fog.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/mesa/tnl/t_vb_fog.c b/src/mesa/tnl/t_vb_fog.c
index f9646b24f34..cb71e67d2fd 100644
--- a/src/mesa/tnl/t_vb_fog.c
+++ b/src/mesa/tnl/t_vb_fog.c
@@ -91,6 +91,7 @@ init_static_data( void )
* evaluating the GL_LINEAR, GL_EXP or GL_EXP2 fog function.
* Fog coordinates are distances from the eye (typically between the
* near and far clip plane distances).
+ * Note the fog (eye Z) coords may be negative so we use ABS(z) below.
* Fog blend factors are in the range [0,1].
*/
static void
@@ -113,7 +114,7 @@ compute_fog_blend_factors(GLcontext *ctx, GLvector4f *out, const GLvector4f *in)
else
d = 1.0F / (ctx->Fog.End - ctx->Fog.Start);
for ( i = 0 ; i < n ; i++, STRIDE_F(v, stride)) {
- const GLfloat z = *v;
+ const GLfloat z = FABSF(*v);
GLfloat f = (end - z) * d;
data[i][0] = CLAMP(f, 0.0F, 1.0F);
}
@@ -121,14 +122,14 @@ compute_fog_blend_factors(GLcontext *ctx, GLvector4f *out, const GLvector4f *in)
case GL_EXP:
d = ctx->Fog.Density;
for ( i = 0 ; i < n ; i++, STRIDE_F(v,stride)) {
- const GLfloat z = *v;
+ const GLfloat z = FABSF(*v);
NEG_EXP( data[i][0], d * z );
}
break;
case GL_EXP2:
d = ctx->Fog.Density*ctx->Fog.Density;
for ( i = 0 ; i < n ; i++, STRIDE_F(v, stride)) {
- const GLfloat z = *v;
+ const GLfloat z = FABSF(*v);
NEG_EXP( data[i][0], d * z * z );
}
break;
@@ -170,7 +171,6 @@ run_fog_stage(GLcontext *ctx, struct tnl_pipeline_stage *stage)
plane[1] = -m[6];
plane[2] = -m[10];
plane[3] = -m[14];
-
/* Full eye coords weren't required, just calculate the
* eye Z values.
*/