From f21f81fa1c3b997ef5621380a7c98a6ecee7458e Mon Sep 17 00:00:00 2001 From: divverent Date: Tue, 6 Sep 2011 19:26:01 +0000 Subject: [PATCH] mod_q3shader_force_addalpha (default 0) treat GL_ONE GL_ONE (or add) blendfunc as GL_SRC_ALPHA GL_ONE for compatibility with older DarkPlaces releases git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@11329 d7cf8633-e32d-0410-b094-e92efae38249 --- model_brush.c | 7 +++++++ model_shared.c | 11 ++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/model_brush.c b/model_brush.c index cb830aaf..470b8586 100644 --- a/model_brush.c +++ b/model_brush.c @@ -53,6 +53,7 @@ cvar_t mod_q3shader_default_offsetmapping_scale = {CVAR_SAVE, "mod_q3shader_defa cvar_t mod_q3shader_default_offsetmapping_bias = {CVAR_SAVE, "mod_q3shader_default_offsetmapping_bias", "0", "default bias used for offsetmapping"}; cvar_t mod_q3shader_default_polygonfactor = {0, "mod_q3shader_default_polygonfactor", "0", "biases depth values of 'polygonoffset' shaders to prevent z-fighting artifacts"}; cvar_t mod_q3shader_default_polygonoffset = {0, "mod_q3shader_default_polygonoffset", "-2", "biases depth values of 'polygonoffset' shaders to prevent z-fighting artifacts"}; +cvar_t mod_q3shader_force_addalpha = {0, "mod_q3shader_force_addalpha", "0", "treat GL_ONE GL_ONE (or add) blendfunc as GL_SRC_ALPHA GL_ONE for compatibility with older DarkPlaces releases"}; cvar_t mod_q1bsp_polygoncollisions = {0, "mod_q1bsp_polygoncollisions", "0", "disables use of precomputed cliphulls and instead collides with polygons (uses Bounding Interval Hierarchy optimizations)"}; cvar_t mod_collision_bih = {0, "mod_collision_bih", "1", "enables use of generated Bounding Interval Hierarchy tree instead of compiled bsp tree in collision code"}; cvar_t mod_recalculatenodeboxes = {0, "mod_recalculatenodeboxes", "1", "enables use of generated node bounding boxes based on BSP tree portal reconstruction, rather than the node boxes supplied by the map compiler"}; @@ -92,10 +93,16 @@ void Mod_BrushInit(void) Cvar_RegisterVariable(&mod_q3shader_default_offsetmapping_bias); Cvar_RegisterVariable(&mod_q3shader_default_polygonfactor); Cvar_RegisterVariable(&mod_q3shader_default_polygonoffset); + Cvar_RegisterVariable(&mod_q3shader_force_addalpha); Cvar_RegisterVariable(&mod_q1bsp_polygoncollisions); Cvar_RegisterVariable(&mod_collision_bih); Cvar_RegisterVariable(&mod_recalculatenodeboxes); + // these games were made for older DP engines and are no longer + // maintained; use this hack to show their textures properly + if(gamemode == GAME_NEXUIZ) + Cvar_SetQuick(&mod_q3shader_force_addalpha, "1"); + memset(&mod_q1bsp_texture_solid, 0, sizeof(mod_q1bsp_texture_solid)); strlcpy(mod_q1bsp_texture_solid.name, "solid" , sizeof(mod_q1bsp_texture_solid.name)); mod_q1bsp_texture_solid.surfaceflags = 0; diff --git a/model_shared.c b/model_shared.c index a5241913..9c5ca203 100644 --- a/model_shared.c +++ b/model_shared.c @@ -1627,6 +1627,7 @@ extern cvar_t mod_q3shader_default_offsetmapping_scale; extern cvar_t mod_q3shader_default_offsetmapping_bias; extern cvar_t mod_q3shader_default_polygonoffset; extern cvar_t mod_q3shader_default_polygonfactor; +extern cvar_t mod_q3shader_force_addalpha; void Mod_LoadQ3Shaders(void) { int j; @@ -1970,6 +1971,15 @@ void Mod_LoadQ3Shaders(void) shader.textureblendalpha = true; } } + + if(mod_q3shader_force_addalpha.integer) + { + // for a long while, DP treated GL_ONE GL_ONE as GL_SRC_ALPHA GL_ONE + // this cvar brings back this behaviour + if(layer->blendfunc[0] == GL_ONE && layer->blendfunc[1] == GL_ONE) + layer->blendfunc[0] = GL_SRC_ALPHA; + } + layer->texflags = 0; if (layer->alphatest) layer->texflags |= TEXF_ALPHA; @@ -1987,7 +1997,6 @@ void Mod_LoadQ3Shaders(void) layer->texflags |= TEXF_ALPHA; break; } - if (!(shader.surfaceparms & Q3SURFACEPARM_NOMIPMAPS)) layer->texflags |= TEXF_MIPMAP; if (!(shader.textureflags & Q3TEXTUREFLAG_NOPICMIP)) -- 2.39.2