mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-03-22 02:11:19 +00:00
Implement water alpha.
This commit is contained in:
parent
57f920b9e9
commit
4734c5b64a
4 changed files with 23 additions and 2 deletions
|
@ -132,6 +132,7 @@ static struct {
|
|||
shaderparam_t colormap;
|
||||
shaderparam_t texture;
|
||||
shaderparam_t lightmap;
|
||||
shaderparam_t color;
|
||||
} quake_bsp = {
|
||||
0,
|
||||
{"mvp_mat", 1},
|
||||
|
@ -140,6 +141,7 @@ static struct {
|
|||
{"colormap", 1},
|
||||
{"texture", 1},
|
||||
{"lightmap", 1},
|
||||
{"vcolor", 0},
|
||||
};
|
||||
|
||||
static struct {
|
||||
|
@ -150,6 +152,7 @@ static struct {
|
|||
shaderparam_t palette;
|
||||
shaderparam_t texture;
|
||||
shaderparam_t realtime;
|
||||
shaderparam_t color;
|
||||
} quake_turb = {
|
||||
0,
|
||||
{"mvp_mat", 1},
|
||||
|
@ -158,6 +161,7 @@ static struct {
|
|||
{"palette", 1},
|
||||
{"texture", 1},
|
||||
{"realtime", 1},
|
||||
{"vcolor", 0},
|
||||
};
|
||||
|
||||
static struct {
|
||||
|
@ -800,11 +804,15 @@ draw_elechain (elechain_t *ec, int matloc, int vertloc, int tlstloc)
|
|||
static void
|
||||
bsp_begin (void)
|
||||
{
|
||||
static quat_t color = { 1, 1, 1, 1 };
|
||||
Mat4Mult (glsl_projection, glsl_view, bsp_vp);
|
||||
|
||||
qfglUseProgram (quake_bsp.program);
|
||||
qfglEnableVertexAttribArray (quake_bsp.vertex.location);
|
||||
qfglEnableVertexAttribArray (quake_bsp.tlst.location);
|
||||
qfglDisableVertexAttribArray (quake_bsp.color.location);
|
||||
|
||||
qfglVertexAttrib4fv (quake_bsp.color.location, color);
|
||||
|
||||
qfglUniform1i (quake_bsp.colormap.location, 2);
|
||||
qfglActiveTexture (GL_TEXTURE0 + 2);
|
||||
|
@ -842,11 +850,17 @@ bsp_end (void)
|
|||
static void
|
||||
turb_begin (void)
|
||||
{
|
||||
static quat_t color = { 1, 1, 1, 1 };
|
||||
|
||||
Mat4Mult (glsl_projection, glsl_view, bsp_vp);
|
||||
|
||||
qfglUseProgram (quake_turb.program);
|
||||
qfglEnableVertexAttribArray (quake_turb.vertex.location);
|
||||
qfglEnableVertexAttribArray (quake_turb.tlst.location);
|
||||
qfglDisableVertexAttribArray (quake_bsp.color.location);
|
||||
|
||||
color[3] = bound (0, r_wateralpha->value, 1);
|
||||
qfglVertexAttrib4fv (quake_turb.color.location, color);
|
||||
|
||||
qfglUniform1i (quake_turb.palette.location, 1);
|
||||
qfglActiveTexture (GL_TEXTURE0 + 1);
|
||||
|
@ -1168,6 +1182,7 @@ R_InitBsp (void)
|
|||
GL_ResolveShaderParam (quake_bsp.program, &quake_bsp.colormap);
|
||||
GL_ResolveShaderParam (quake_bsp.program, &quake_bsp.texture);
|
||||
GL_ResolveShaderParam (quake_bsp.program, &quake_bsp.lightmap);
|
||||
GL_ResolveShaderParam (quake_bsp.program, &quake_bsp.color);
|
||||
|
||||
frag = GL_CompileShader ("quaketrb.frag", quaketurb_frag,
|
||||
GL_FRAGMENT_SHADER);
|
||||
|
@ -1178,6 +1193,7 @@ R_InitBsp (void)
|
|||
GL_ResolveShaderParam (quake_turb.program, &quake_turb.palette);
|
||||
GL_ResolveShaderParam (quake_turb.program, &quake_turb.texture);
|
||||
GL_ResolveShaderParam (quake_turb.program, &quake_turb.realtime);
|
||||
GL_ResolveShaderParam (quake_turb.program, &quake_turb.color);
|
||||
|
||||
vert = GL_CompileShader ("quakesky.vert", quakesky_vert, GL_VERTEX_SHADER);
|
||||
frag = GL_CompileShader ("quakeski.frag", quakeskyid_frag,
|
||||
|
|
|
@ -4,6 +4,7 @@ uniform sampler2D lightmap;
|
|||
|
||||
varying vec2 tst;
|
||||
varying vec2 lst;
|
||||
varying vec4 color;
|
||||
|
||||
void
|
||||
main (void)
|
||||
|
@ -12,5 +13,5 @@ main (void)
|
|||
float light = texture2D (lightmap, lst).r;
|
||||
float col;
|
||||
|
||||
gl_FragColor = texture2D (colormap, vec2 (pix, light * 4.0));
|
||||
gl_FragColor = texture2D (colormap, vec2 (pix, light * 4.0)) * color;
|
||||
}
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
uniform mat4 mvp_mat;
|
||||
|
||||
attribute vec4 vcolor;
|
||||
attribute vec4 tlst;
|
||||
attribute vec4 vertex;
|
||||
|
||||
varying vec2 tst;
|
||||
varying vec2 lst;
|
||||
varying vec4 color;
|
||||
|
||||
void
|
||||
main (void)
|
||||
|
@ -12,4 +14,5 @@ main (void)
|
|||
gl_Position = mvp_mat * vertex;
|
||||
tst = tlst.st;
|
||||
lst = tlst.pq;
|
||||
color = vcolor;
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ uniform sampler2D texture;
|
|||
uniform float realtime;
|
||||
|
||||
varying vec2 tst;
|
||||
varying vec4 color;
|
||||
|
||||
const float SPEED = 20.0;
|
||||
const float CYCLE = 128.0;
|
||||
|
@ -27,5 +28,5 @@ main (void)
|
|||
|
||||
st = turb_st (tst, realtime);
|
||||
pix = texture2D (texture, st).r;
|
||||
gl_FragColor = texture2D (palette, vec2 (pix, 0.0));
|
||||
gl_FragColor = texture2D (palette, vec2 (pix, 0.0)) * color;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue