GL1 water warp effect

A basic "squeeze/stretch" effect to fov when diving underwater.
Intensity is controlled by gl1_waterwarp, 0 disables the effect.
Original from Fitzquake.
This commit is contained in:
Jaime Moreira 2024-12-11 21:05:27 -03:00
parent 6a3a081b4b
commit 5d201fce9a
2 changed files with 14 additions and 0 deletions

View file

@ -511,6 +511,10 @@ it's `+set busywait 0` (setting the `busywait` cvar) and `-portable`
look a bit better (no flickering) by using the stencil buffer. Does
not work when `gl1_stereo` is `3`, `4` or `5`.
* **gl1_waterwarp**: Intensity of the "squeeze/stretch" effect on the
FOV when diving underwater. Can be any floating point number, `0`
disables it (Vanilla Quake II look). Default `1.0`.
* **gl1_lightmapcopies**: When enabled (`1`), keep 3 copies of the same
lightmap rotating, shifting to another one when drawing a new frame.
Meant for mobile/embedded devices, where changing textures just shown

View file

@ -143,6 +143,7 @@ cvar_t *gl1_stereo_separation;
cvar_t *gl1_stereo_anaglyph_colors;
cvar_t *gl1_stereo_convergence;
static cvar_t *gl1_waterwarp;
refimport_t ri;
@ -740,6 +741,13 @@ R_SetPerspective(GLdouble fovy)
ymax = zNear * tan(fovy * M_PI / 360.0);
xmax = ymax * aspectratio;
if ((r_newrefdef.rdflags & RDF_UNDERWATER) && gl1_waterwarp->value)
{
const GLdouble warp = sin(r_newrefdef.time * 1.5) * 0.03 * gl1_waterwarp->value;
ymax *= 1.0 - warp;
xmax *= 1.0 + warp;
}
ymin = -ymax;
xmin = -xmax;
@ -1302,6 +1310,8 @@ R_Register(void)
gl1_stereo_anaglyph_colors = ri.Cvar_Get( "gl1_stereo_anaglyph_colors", "rc", CVAR_ARCHIVE );
gl1_stereo_convergence = ri.Cvar_Get( "gl1_stereo_convergence", "1", CVAR_ARCHIVE );
gl1_waterwarp = ri.Cvar_Get( "gl1_waterwarp", "1.0", CVAR_ARCHIVE );
ri.Cmd_AddCommand("imagelist", R_ImageList_f);
ri.Cmd_AddCommand("screenshot", R_ScreenShot);
ri.Cmd_AddCommand("modellist", Mod_Modellist_f);