From: havoc Date: Fri, 7 Dec 2007 21:59:40 +0000 (+0000) Subject: fix fog, it now matches GL_EXP2 fog as it was meant to (this makes X-Git-Tag: xonotic-v0.1.0preview~2713 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=08b17d6e1f0ba20ac2ec1414a1369b1a098bd06f;p=xonotic%2Fdarkplaces.git fix fog, it now matches GL_EXP2 fog as it was meant to (this makes Nehahra look correct, which it hasn't for years) git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@7777 d7cf8633-e32d-0410-b094-e92efae38249 --- diff --git a/gl_rmain.c b/gl_rmain.c index 55484014..b453e259 100644 --- a/gl_rmain.c +++ b/gl_rmain.c @@ -384,7 +384,7 @@ static void R_BuildNormalizationCube(void) static void R_BuildFogTexture(void) { int x, b; -#define FOGWIDTH 64 +#define FOGWIDTH 256 unsigned char data1[FOGWIDTH][4]; //unsigned char data2[FOGWIDTH][4]; for (x = 0;x < FOGWIDTH;x++) @@ -1825,10 +1825,10 @@ void gl_main_start(void) int x; double r, alpha; - r = (-1.0/256.0) * (FOGMASKTABLEWIDTH * FOGMASKTABLEWIDTH); + r = -16.0 / (1.0 * FOGMASKTABLEWIDTH * FOGMASKTABLEWIDTH); for (x = 0;x < FOGMASKTABLEWIDTH;x++) { - alpha = 1 - exp(r / ((double)x*(double)x)); + alpha = exp(r * ((double)x*(double)x)); if (x == FOGMASKTABLEWIDTH - 1) alpha = 0; r_refdef.fogmasktable[x] = bound(0, alpha, 1); @@ -3277,7 +3277,7 @@ void R_UpdateVariables(void) // this is the point where the fog reaches 0.9986 alpha, which we // consider a good enough cutoff point for the texture // (0.9986 * 256 == 255.6) - r_refdef.fogrange = 400 / r_refdef.fog_density; + r_refdef.fogrange = 16 / (r_refdef.fog_density * r_refdef.fog_density); r_refdef.fograngerecip = 1.0f / r_refdef.fogrange; r_refdef.fogmasktabledistmultiplier = FOGMASKTABLEWIDTH * r_refdef.fograngerecip; // fog color was already set