From 09da0b8e6621a831e3eeb9381430f2bed18a22ad Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 17 Feb 2004 21:03:03 +0000 Subject: 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. --- src/mesa/swrast/s_tritemp.h | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/mesa/swrast/s_tritemp.h') 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 -- cgit v1.2.3