]> git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
extra required parameter for dp_water: alpha modifier
authordivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Mon, 28 Jan 2008 22:45:43 +0000 (22:45 +0000)
committerdivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Mon, 28 Jan 2008 22:45:43 +0000 (22:45 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@8034 d7cf8633-e32d-0410-b094-e92efae38249

darkplaces.txt
gl_rmain.c
model_brush.c
model_shared.c
model_shared.h

index 57e2dfdade362c757b32edcd853de43a2fd569d2..c20f3b28e0eb4aee7756c782351ce4f620903fea 100644 (file)
@@ -1329,11 +1329,14 @@ Shader parameters for DP's own features:
   Makes surfaces of this shader refractive with r_water. The refraction\r
   replaces the transparency of the texture. distort is used in conjunction with\r
   the normalmap to simulate a nonplanar water surface.\r
-- dp_water <reflectmin> <reflectmax> <refractdistort> <reflectdistort> <refractr> <refractg> <refractb> <reflectr> <reflectg> <reflectb>\r
+- dp_water <reflectmin> <reflectmax> <refractdistort> <reflectdistort> <refractr> <refractg> <refractb> <reflectr> <reflectg> <reflectb> <alpha>\r
   This combines the effects of dp_reflect and dp_refract to simulate a water\r
   surface. However, the refraction and the reflection are mixed using a Fresnel\r
   equation that makes the amount of reflection slide from reflectmin when\r
   looking parallel to the water to reflectmax when looking directly into the\r
   water. The result of this reflection/refraction mix is then layered BELOW the\r
   texture of the shader, so basically, it "fills up" the alpha values of the\r
-  water.\r
+  water. The alpha value is a multiplicator for the alpha value on the texture\r
+  - set this to a small value like 0.1 to emphasize the reflection and make\r
+  the water transparent; but if r_water is 0, alpha isn't used, so the water can\r
+  be very visible then too.\r
index 0ad6e6c73dc273638a480cb78e61c42dcb83c033..fc3ed27620245e9611747c24efdd2682d543002f 100644 (file)
@@ -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))
index 9402a6f7a50400ed93a683a955c799e527d7a30f..3278bcd467722a140210bedcbc1ccc06bee19084 100644 (file)
@@ -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)
index 5ad5cf40044587306c79a64679ac06675ee1132b..246a1873a213676deb5eb02f9133078656ed89c5 100644 (file)
@@ -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"))
        {
index 27869571d277c7ea9627217eb1b8c14947f6569e..5bd0585f3e91778cf850ba07b7d82e73e0fedaf8 100644 (file)
@@ -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;