summaryrefslogtreecommitdiff
path: root/src/mesa/swrast/s_tritemp.h
diff options
context:
space:
mode:
authorBrian Paul <brian.paul@tungstengraphics.com>2004-02-17 21:03:03 +0000
committerBrian Paul <brian.paul@tungstengraphics.com>2004-02-17 21:03:03 +0000
commit09da0b8e6621a831e3eeb9381430f2bed18a22ad (patch)
treee7e307c3a5ddd773b469cf17d0331822388b466e /src/mesa/swrast/s_tritemp.h
parent9a389d4bdb8026063034767e1599be975cb4e2f2 (diff)
A bit of an overhaul of the fog code.
glFogCoord didn't always work reliably. ARB fragment program fog options work now. Per-fragment fog computations are now perspective corrected.
Diffstat (limited to 'src/mesa/swrast/s_tritemp.h')
-rw-r--r--src/mesa/swrast/s_tritemp.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/mesa/swrast/s_tritemp.h b/src/mesa/swrast/s_tritemp.h
index 28a80dee66..2e25e531cc 100644
--- a/src/mesa/swrast/s_tritemp.h
+++ b/src/mesa/swrast/s_tritemp.h
@@ -411,8 +411,14 @@ static void NAME(GLcontext *ctx, const SWvertex *v0,
#ifdef INTERP_FOG
span.interpMask |= SPAN_FOG;
{
+# ifdef INTERP_W
+ const GLfloat wMax = vMax->win[3], wMin = vMin->win[3], wMid = vMid->win[3];
+ const GLfloat eMaj_dfog = vMax->fog * wMax - vMin->fog * wMin;
+ const GLfloat eBot_dfog = vMid->fog * wMid - vMin->fog * wMin;
+# else
const GLfloat eMaj_dfog = vMax->fog - vMin->fog;
const GLfloat eBot_dfog = vMid->fog - vMin->fog;
+# endif
span.dfogdx = oneOverArea * (eMaj_dfog * eBot.dy - eMaj.dy * eBot_dfog);
span.dfogdy = oneOverArea * (eMaj.dx * eBot_dfog - eMaj_dfog * eBot.dx);
span.fogStep = span.dfogdx;
@@ -802,7 +808,11 @@ static void NAME(GLcontext *ctx, const SWvertex *v0,
dwOuter = span.dwdy + dxOuter * span.dwdx;
#endif
#ifdef INTERP_FOG
+# ifdef INTERP_W
+ fogLeft = vLower->fog * vLower->win[3] + (span.dfogdx * adjx + span.dfogdy * adjy) * (1.0F/FIXED_SCALE);
+# else
fogLeft = vLower->fog + (span.dfogdx * adjx + span.dfogdy * adjy) * (1.0F/FIXED_SCALE);
+# endif
dfogOuter = span.dfogdy + dxOuter * span.dfogdx;
#endif
#ifdef INTERP_RGB