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
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))
Vector4Set(tx->refractcolor4f, 1, 1, 1, 1);
tx->reflectfactor = 1;
Vector4Set(tx->reflectcolor4f, 1, 1, 1, 1);
+ tx->r_water_wateralpha = 1;
}
if (!m)
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, "{"))
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]);
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)
{
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"))
{
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;
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;