Bläddra i källkod

A few more tweaks to fog code.

Remove unneeded FABSF() macros.
Added blend factor clamping in a few spots.
tags/R300_DRIVER_0
Brian Paul 22 år sedan
förälder
incheckning
0733dbb011
2 ändrade filer med 15 tillägg och 10 borttagningar
  1. 8
    4
      src/mesa/swrast/s_fog.c
  2. 7
    6
      src/mesa/tnl/t_vb_fog.c

+ 8
- 4
src/mesa/swrast/s_fog.c Visa fil

@@ -55,10 +55,12 @@ _swrast_z_to_fogfactor(GLcontext *ctx, GLfloat z)
case GL_EXP:
d = ctx->Fog.Density;
f = (GLfloat) exp(-d * z);
f = CLAMP(f, 0.0F, 1.0F);
return f;
case GL_EXP2:
d = ctx->Fog.Density;
f = (GLfloat) exp(-(d * d * z * z));
f = CLAMP(f, 0.0F, 1.0F);
return f;
default:
_mesa_problem(ctx, "Bad fog mode in _swrast_z_to_fogfactor");
@@ -110,7 +112,7 @@ _swrast_fog_rgba_span( const GLcontext *ctx, struct sw_span *span )
GLuint i;
for (i = 0; i < span->end; i++) {
GLfloat f, oneMinusF;
f = (fogEnd - FABSF(fogCoord/w)) * fogScale;
f = (fogEnd - fogCoord / w) * fogScale;
f = CLAMP(f, 0.0F, 1.0F);
oneMinusF = 1.0F - f;
rgba[i][RCOMP] = (GLchan) (f * rgba[i][RCOMP] + oneMinusF * rFog);
@@ -131,7 +133,8 @@ _swrast_fog_rgba_span( const GLcontext *ctx, struct sw_span *span )
GLuint i;
for (i = 0; i < span->end; i++) {
GLfloat f, oneMinusF;
f = (GLfloat) exp(density * FABSF(fogCoord/w));
f = (GLfloat) exp(density * fogCoord / w);
f = CLAMP(f, 0.0F, 1.0F);
oneMinusF = 1.0F - f;
rgba[i][RCOMP] = (GLchan) (f * rgba[i][RCOMP] + oneMinusF * rFog);
rgba[i][GCOMP] = (GLchan) (f * rgba[i][GCOMP] + oneMinusF * gFog);
@@ -242,7 +245,7 @@ _swrast_fog_ci_span( const GLcontext *ctx, struct sw_span *span )
GLfloat w = haveW ? span->w : 1.0F;
GLuint i;
for (i = 0; i < span->end; i++) {
GLfloat f = (fogEnd - FABSF(fogCoord/w)) * fogScale;
GLfloat f = (fogEnd - fogCoord / w) * fogScale;
f = CLAMP(f, 0.0F, 1.0F);
index[i] = (GLuint) ((GLfloat) index[i] + (1.0F - f) * fogIndex);
fogCoord += fogStep;
@@ -259,7 +262,8 @@ _swrast_fog_ci_span( const GLcontext *ctx, struct sw_span *span )
GLfloat w = haveW ? span->w : 1.0F;
GLuint i;
for (i = 0; i < span->end; i++) {
GLfloat f = (GLfloat) exp(density * FABSF(fogCoord/w));
GLfloat f = (GLfloat) exp(density * fogCoord / w);
f = CLAMP(f, 0.0F, 1.0F);
index[i] = (GLuint) ((GLfloat) index[i] + (1.0F - f) * fogIndex);
fogCoord += fogStep;
w += wStep;

+ 7
- 6
src/mesa/tnl/t_vb_fog.c Visa fil

@@ -113,7 +113,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 = FABSF(*v);
const GLfloat z = *v;
GLfloat f = (end - z) * d;
data[i][0] = CLAMP(f, 0.0F, 1.0F);
}
@@ -121,7 +121,7 @@ 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 = FABSF(*v);
const GLfloat z = *v;
NEG_EXP( data[i][0], d * z );
}
break;
@@ -165,10 +165,11 @@ run_fog_stage(GLcontext *ctx, struct tnl_pipeline_stage *stage)
*/
input = &store->fogcoord;

plane[0] = m[2];
plane[1] = m[6];
plane[2] = m[10];
plane[3] = m[14];
/* NOTE: negate plane here so we get positive fog coords! */
plane[0] = -m[2];
plane[1] = -m[6];
plane[2] = -m[10];
plane[3] = -m[14];

/* Full eye coords weren't required, just calculate the
* eye Z values.

Laddar…
Avbryt
Spara