From bb1b9dad23a934787d77ef95aec1aae39c57b789 Mon Sep 17 00:00:00 2001 From: Velaron Date: Sat, 20 May 2023 20:22:09 +0300 Subject: [PATCH] ref: gl: Goldsrc compatible fog implementation --- ref/gl/gl_triapi.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/ref/gl/gl_triapi.c b/ref/gl/gl_triapi.c index 63536898..85ce753b 100644 --- a/ref/gl/gl_triapi.c +++ b/ref/gl/gl_triapi.c @@ -281,13 +281,22 @@ void TriFog( float flFogColor[3], float flStart, float flEnd, int bOn ) RI.fogColor[0] = flFogColor[0] / 255.0f; RI.fogColor[1] = flFogColor[1] / 255.0f; RI.fogColor[2] = flFogColor[2] / 255.0f; - RI.fogStart = flStart; RI.fogColor[3] = 1.0f; - RI.fogDensity = 0.0f; - RI.fogSkybox = true; + + RI.fogStart = flStart; RI.fogEnd = flEnd; - pglFogi( GL_FOG_MODE, GL_LINEAR ); + if( RI.fogDensity > 0.0f ) + { + pglFogi( GL_FOG_MODE, GL_EXP2 ); + pglFogf( GL_FOG_DENSITY, RI.fogDensity ); + } + else + { + pglFogi( GL_FOG_MODE, GL_LINEAR ); + RI.fogSkybox = true; + } + pglFogfv( GL_FOG_COLOR, RI.fogColor ); pglFogf( GL_FOG_START, RI.fogStart ); pglFogf( GL_FOG_END, RI.fogEnd );