diff options
author | Brian Paul <brian.paul@tungstengraphics.com> | 2005-04-26 17:22:21 +0000 |
---|---|---|
committer | Brian Paul <brian.paul@tungstengraphics.com> | 2005-04-26 17:22:21 +0000 |
commit | 78e63187d320aaff0c9cbbb87f82668e3925c374 (patch) | |
tree | 68053968d05e7b6d5f9a08bb966f8d7d71a29437 | |
parent | 81c8037e0f5d737bc8f2c4d31e8182bbc812d213 (diff) |
added interpolate_fog()
-rw-r--r-- | src/mesa/swrast/s_span.c | 32 |
1 files changed, 28 insertions, 4 deletions
diff --git a/src/mesa/swrast/s_span.c b/src/mesa/swrast/s_span.c index 8fb89f692f..f8ba0d03f4 100644 --- a/src/mesa/swrast/s_span.c +++ b/src/mesa/swrast/s_span.c @@ -276,6 +276,26 @@ interpolate_specular(GLcontext *ctx, struct sw_span *span) } +/* Fill in the span.array.fog values from the interpolation values */ +static void +interpolate_fog(const GLcontext *ctx, struct sw_span *span) +{ + GLfloat *fog = span->array->fog; + const GLfloat fogStep = span->fogStep; + GLfloat fogCoord = span->fog; + const GLuint haveW = (span->interpMask & SPAN_W); + const GLfloat wStep = haveW ? span->dwdx : 0.0F; + GLfloat w = haveW ? span->w : 1.0F; + GLuint i; + for (i = 0; i < span->end; i++) { + fog[i] = fogCoord / w; + fogCoord += fogStep; + w += wStep; + } + span->arrayMask |= SPAN_FOG; +} + + /* Fill in the span.zArray array from the interpolation values */ void _swrast_span_interpolate_z( const GLcontext *ctx, struct sw_span *span ) @@ -1388,9 +1408,11 @@ _swrast_write_texture_span( GLcontext *ctx, struct sw_span *span) if ((span->interpMask & SPAN_RGBA) && (span->arrayMask & SPAN_RGBA) == 0) interpolate_colors(ctx, span); - if (span->interpMask & SPAN_SPEC) { + if (span->interpMask & SPAN_SPEC) interpolate_specular(ctx, span); - } + + if (span->interpMask & SPAN_FOG) + interpolate_fog(ctx, span); /* Texturing without alpha is done after depth-testing which * gives a potential speed-up. @@ -1461,9 +1483,11 @@ _swrast_write_texture_span( GLcontext *ctx, struct sw_span *span) if ((span->interpMask & SPAN_RGBA) && (span->arrayMask & SPAN_RGBA) == 0) interpolate_colors(ctx, span); - if (span->interpMask & SPAN_SPEC) { + if (span->interpMask & SPAN_SPEC) interpolate_specular(ctx, span); - } + + if (span->interpMask & SPAN_FOG) + interpolate_fog(ctx, span); if (ctx->FragmentProgram._Enabled) _swrast_exec_fragment_program( ctx, span ); |