matrix4x4_t tempmatrix;
float args[4] = {0.05f,0,0,0.04f};
- if (r_waterscroll.value)
+ if (gl_textureshader && r_watershader.value && !fogenabled)
+ {
+ Matrix4x4_CreateTranslate(&tempmatrix, sin(cl.time) * 0.025 * r_waterscroll.value, sin(cl.time * 0.8f) * 0.025 * r_waterscroll.value, 0);
+ R_Mesh_TextureMatrix(1, &tempmatrix);
+ Matrix4x4_CreateFromQuakeEntity(&tempmatrix, 0, 0, 0, 0, 0, 0, r_watershader.value);
+ R_Mesh_TextureMatrix(0, &tempmatrix);
+ }
+ else if (r_waterscroll.value)
{
// scrolling in texture matrix
Matrix4x4_CreateTranslate(&tempmatrix, sin(cl.time) * 0.025 * r_waterscroll.value, sin(cl.time * 0.8f) * 0.025 * r_waterscroll.value, 0);
- if (gl_textureshader && r_watershader.integer && !fogenabled)
- {
- R_Mesh_TextureMatrix(1, &tempmatrix);
- Matrix4x4_CreateTranslate(&tempmatrix, -sin(cl.time) * 0.025 * r_waterscroll.value, -sin(cl.time * 0.8f) * 0.025 * r_waterscroll.value, 0);
- }
R_Mesh_TextureMatrix(0, &tempmatrix);
}
GL_BlendFunc(GL_ONE, GL_ZERO);
GL_DepthMask(true);
}
- if (gl_textureshader && r_watershader.integer && !fogenabled)
+ if (gl_textureshader && r_watershader.value && !fogenabled)
{
- m.tex[0] = R_GetTexture(mod_shared_distorttexture);
+ m.tex[0] = R_GetTexture(mod_shared_distorttexture[(int)(cl.time * 16)&63]);
m.tex[1] = R_GetTexture(texture->skin.base);
}
else
GL_ColorPointer(varray_color4f);
else
GL_Color(1, 1, 1, alpha);
- if (gl_textureshader && r_watershader.integer && !fogenabled)
+ if (gl_textureshader && r_watershader.value && !fogenabled)
{
GL_ActiveTexture (0);
qglTexEnvi (GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, GL_TEXTURE_2D);
}
R_Mesh_Draw(surf->mesh.num_vertices, surf->mesh.num_triangles, surf->mesh.data_element3i);
- if (gl_textureshader && r_watershader.integer && !fogenabled)
+ if (gl_textureshader && r_watershader.value && !fogenabled)
{
qglDisable (GL_TEXTURE_SHADER_NV);
GL_ActiveTexture (0);
R_Mesh_Draw(surf->mesh.num_vertices, surf->mesh.num_triangles, surf->mesh.data_element3i);
}
- if (r_waterscroll.value)
+ if ((gl_textureshader && r_watershader.value && !fogenabled) || r_waterscroll.value)
{
Matrix4x4_CreateIdentity(&tempmatrix);
R_Mesh_TextureMatrix(0, &tempmatrix);
else if (options_effects_cursor == optnum++)
Cvar_SetValueQuick (&r_waterscroll, bound(0, r_waterscroll.value + dir * 0.5, 10));
else if (options_effects_cursor == optnum++)
- Cvar_SetValueQuick (&r_watershader, !r_watershader.integer);
+ Cvar_SetValueQuick (&r_watershader, bound(0, r_watershader.value + dir * 0.25, 10));
}
void M_Options_Effects_Draw (void)
M_Options_PrintCheckbox(" Model Interpolation", true, r_lerpmodels.integer);
M_Options_PrintCheckbox(" Sprite Interpolation", true, r_lerpsprites.integer);
M_Options_PrintSlider( " Water Movement", true, r_waterscroll.value, 0, 10);
- M_Options_PrintCheckbox(" GeForce3 Water Shader", true, r_watershader.integer);
+ M_Options_PrintSlider( " GeForce3 Water Shader", true, r_watershader.value, 0, 10);
}
rtexturepool_t *mod_shared_texturepool;
rtexture_t *r_notexture;
rtexture_t *mod_shared_detailtextures[NUM_DETAILTEXTURES];
-rtexture_t *mod_shared_distorttexture;
+rtexture_t *mod_shared_distorttexture[64];
void Mod_BuildDetailTextures (void)
{
}
}
+qbyte Mod_MorphDistortTexture (double y0, double y1, double y2, double y3, double morph)
+{
+ int value = (int)(((y1 + y3 - (y0 + y2)) * morph * morph * morph) +
+ ((2 * (y0 - y1) + y2 - y3) * morph * morph) +
+ ((y2 - y0) * morph) +
+ (y1));
+
+ if (value > 255)
+ value = 255;
+ if (value < 0)
+ value = 0;
+
+ return (qbyte)value;
+}
+
void Mod_BuildDistortTexture (void)
{
- int x, y;
+ int x, y, i, j;
#define DISTORTRESOLUTION 32
- qbyte data[DISTORTRESOLUTION][DISTORTRESOLUTION][2];
- for (y=0; y<DISTORTRESOLUTION; y++)
+ qbyte data[5][DISTORTRESOLUTION][DISTORTRESOLUTION][2];
+
+ for (i=0; i<4; i++)
+ {
+ for (y=0; y<DISTORTRESOLUTION; y++)
+ {
+ for (x=0; x<DISTORTRESOLUTION; x++)
+ {
+ data[i][y][x][0] = rand () & 255;
+ data[i][y][x][1] = rand () & 255;
+ }
+ }
+ }
+
+ for (i=0; i<4; i++)
{
- for (x=0; x<DISTORTRESOLUTION; x++)
+ for (j=0; j<16; j++)
{
- data[y][x][0] = rand () & 255;
- data[y][x][1] = rand () & 255;
+ for (y=0; y<DISTORTRESOLUTION; y++)
+ {
+ for (x=0; x<DISTORTRESOLUTION; x++)
+ {
+ data[4][y][x][0] = Mod_MorphDistortTexture (data[(i-1)&3][y][x][0], data[i][y][x][0], data[(i+1)&3][y][x][0], data[(i+2)&3][y][x][0], 0.0625*j);
+ data[4][y][x][1] = Mod_MorphDistortTexture (data[(i-1)&3][y][x][1], data[i][y][x][1], data[(i+1)&3][y][x][1], data[(i+2)&3][y][x][1], 0.0625*j);
+ }
+ }
+ mod_shared_distorttexture[i*16+j] = R_LoadTexture2D(mod_shared_texturepool, va("distorttexture%i", i*16+j), DISTORTRESOLUTION, DISTORTRESOLUTION, &data[4][0][0][0], TEXTYPE_DSDT, TEXF_PRECACHE, NULL);
}
}
- mod_shared_distorttexture = R_LoadTexture2D(mod_shared_texturepool, "distorttexture", DISTORTRESOLUTION, DISTORTRESOLUTION, &data[0][0][0], TEXTYPE_DSDT, TEXF_PRECACHE, NULL);
return;
}
// every texture must be in a pool...
extern rtexturepool_t *mod_shared_texturepool;
-extern rtexture_t *mod_shared_distorttexture;
+extern rtexture_t *mod_shared_distorttexture[64];
// model loading
extern model_t *loadmodel;