From: divverent Date: Mon, 28 Jan 2008 22:45:43 +0000 (+0000) Subject: extra required parameter for dp_water: alpha modifier X-Git-Tag: xonotic-v0.1.0preview~2480 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=17deb1f88b4616715b630de176649d17ddb54bbe;p=xonotic%2Fdarkplaces.git extra required parameter for dp_water: alpha modifier git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@8034 d7cf8633-e32d-0410-b094-e92efae38249 --- diff --git a/darkplaces.txt b/darkplaces.txt index 57e2dfda..c20f3b28 100644 --- a/darkplaces.txt +++ b/darkplaces.txt @@ -1329,11 +1329,14 @@ Shader parameters for DP's own features: Makes surfaces of this shader refractive with r_water. The refraction replaces the transparency of the texture. distort is used in conjunction with the normalmap to simulate a nonplanar water surface. -- dp_water +- dp_water This combines the effects of dp_reflect and dp_refract to simulate a water surface. However, the refraction and the reflection are mixed using a Fresnel equation that makes the amount of reflection slide from reflectmin when looking parallel to the water to reflectmax when looking directly into the water. The result of this reflection/refraction mix is then layered BELOW the texture of the shader, so basically, it "fills up" the alpha values of the - water. + water. The alpha value is a multiplicator for the alpha value on the texture + - set this to a small value like 0.1 to emphasize the reflection and make + the water transparent; but if r_water is 0, alpha isn't used, so the water can + be very visible then too. diff --git a/gl_rmain.c b/gl_rmain.c index 0ad6e6c7..fc3ed276 100644 --- a/gl_rmain.c +++ b/gl_rmain.c @@ -4341,6 +4341,8 @@ void R_UpdateTextureInfo(const entity_render_t *ent, texture_t *t) t->currentmaterialflags |= MATERIALFLAG_WATERSHADER; */ } + if(t->basematerialflags & MATERIALFLAG_WATERSHADER && r_waterstate.enabled) + t->currentalpha *= t->r_water_wateralpha; if(!r_waterstate.enabled) t->currentmaterialflags &= ~(MATERIALFLAG_WATERSHADER | MATERIALFLAG_REFRACTION | MATERIALFLAG_REFLECTION); if (!(ent->flags & RENDER_LIGHT)) diff --git a/model_brush.c b/model_brush.c index 9402a6f7..3278bcd4 100644 --- a/model_brush.c +++ b/model_brush.c @@ -1376,6 +1376,7 @@ static void Mod_Q1BSP_LoadTextures(lump_t *l) Vector4Set(tx->refractcolor4f, 1, 1, 1, 1); tx->reflectfactor = 1; Vector4Set(tx->reflectcolor4f, 1, 1, 1, 1); + tx->r_water_wateralpha = 1; } if (!m) diff --git a/model_shared.c b/model_shared.c index 5ad5cf40..246a1873 100644 --- a/model_shared.c +++ b/model_shared.c @@ -1207,6 +1207,7 @@ void Mod_LoadQ3Shaders(void) Vector4Set(shader.refractcolor4f, 1, 1, 1, 1); shader.reflectfactor = 1; Vector4Set(shader.reflectcolor4f, 1, 1, 1, 1); + shader.r_water_wateralpha = 1; strlcpy(shader.name, com_token, sizeof(shader.name)); if (!COM_ParseToken_QuakeC(&text, false) || strcasecmp(com_token, "{")) @@ -1582,7 +1583,7 @@ void Mod_LoadQ3Shaders(void) shader.reflectfactor = atof(parameter[1]); Vector4Set(shader.reflectcolor4f, atof(parameter[2]), atof(parameter[3]), atof(parameter[4]), atof(parameter[5])); } - else if (!strcasecmp(parameter[0], "dp_water") && numparameters >= 11) + else if (!strcasecmp(parameter[0], "dp_water") && numparameters >= 12) { shader.textureflags |= Q3TEXTUREFLAG_WATERSHADER; shader.reflectmin = atof(parameter[1]); @@ -1591,6 +1592,7 @@ void Mod_LoadQ3Shaders(void) shader.reflectfactor = atof(parameter[4]); Vector4Set(shader.refractcolor4f, atof(parameter[5]), atof(parameter[6]), atof(parameter[7]), 1); Vector4Set(shader.reflectcolor4f, atof(parameter[8]), atof(parameter[9]), atof(parameter[10]), 1); + shader.r_water_wateralpha = atof(parameter[11]); } else if (!strcasecmp(parameter[0], "deformvertexes") && numparameters >= 2) { @@ -1812,6 +1814,7 @@ nothing GL_ZERO GL_ONE Vector4Copy(shader->refractcolor4f, texture->refractcolor4f); texture->reflectfactor = shader->reflectfactor; Vector4Copy(shader->reflectcolor4f, texture->reflectcolor4f); + texture->r_water_wateralpha = shader->r_water_wateralpha; } else if (!strcmp(texture->name, "noshader")) { diff --git a/model_shared.h b/model_shared.h index 27869571..5bd0585f 100644 --- a/model_shared.h +++ b/model_shared.h @@ -373,12 +373,14 @@ typedef struct q3shaderinfo_s char skyboxname[Q3PATHLENGTH]; q3shaderinfo_deform_t deforms[Q3MAXDEFORMS]; + // reflection float reflectmin; // when refraction is used, minimum amount of reflection (when looking straight down) float reflectmax; // when refraction is used, maximum amount of reflection (when looking parallel to water) float refractfactor; // amount of refraction distort (1.0 = like the cvar specifies) vec4_t refractcolor4f; // color tint of refraction (including alpha factor) float reflectfactor; // amount of reflection distort (1.0 = like the cvar specifies) vec4_t reflectcolor4f; // color tint of reflection (including alpha factor) + float r_water_wateralpha; // additional wateralpha to apply when r_water is active } q3shaderinfo_t; @@ -502,6 +504,7 @@ typedef struct texture_s vec4_t refractcolor4f; // color tint of refraction (including alpha factor) float reflectfactor; // amount of reflection distort (1.0 = like the cvar specifies) vec4_t reflectcolor4f; // color tint of reflection (including alpha factor) + float r_water_wateralpha; // additional wateralpha to apply when r_water is active } texture_t;