Uncap water ripples

This commit is contained in:
Zwip-Zwap Zapony 2022-11-13 16:15:15 +01:00
parent 6709100997
commit 59399e9fcf
4 changed files with 21 additions and 11 deletions

View file

@ -6786,7 +6786,7 @@ void HWR_DoPostProcessor(player_t *player)
{
// 10 by 10 grid. 2 coordinates (xy)
float v[SCREENVERTS][SCREENVERTS][2];
static double disStart = 0;
float disStart = (leveltime-1) + FIXED_TO_FLOAT(rendertimefrac);
UINT8 x, y;
INT32 WAVELENGTH;
@ -6817,8 +6817,6 @@ void HWR_DoPostProcessor(player_t *player)
}
}
HWD.pfnPostImgRedraw(v);
if (!(paused || P_AutoPause()))
disStart += FIXED_TO_FLOAT(renderdeltatics);
// Capture the screen again for screen waving on the intermission
if(gamestate != GS_INTERMISSION)

View file

@ -21,6 +21,7 @@
#include <stdarg.h>
#include <math.h>
#include "../../r_local.h" // For rendertimefrac, used for the leveltime shader uniform
#include "r_opengl.h"
#include "r_vbo.h"
@ -616,7 +617,7 @@ typedef struct gl_shaderstate_s
static gl_shaderstate_t gl_shaderstate;
// Shader info
static INT32 shader_leveltime = 0;
static float shader_leveltime = 0;
// Lactozilla: Shader functions
static boolean Shader_CompileProgram(gl_shader_t *shader, GLint i, const GLchar *vert_shader, const GLchar *frag_shader);
@ -976,7 +977,7 @@ EXPORT void HWRAPI(SetShaderInfo) (hwdshaderinfo_t info, INT32 value)
switch (info)
{
case HWD_SHADERINFO_LEVELTIME:
shader_leveltime = value;
shader_leveltime = (((float)(value-1)) + FIXED_TO_FLOAT(rendertimefrac)) / TICRATE;
break;
default:
break;
@ -2046,7 +2047,7 @@ static void Shader_SetUniforms(FSurfaceInfo *Surface, GLRGBAFloat *poly, GLRGBAF
UNIFORM_1(shader->uniforms[gluniform_fade_end], Surface->LightInfo.fade_end, pglUniform1f);
}
UNIFORM_1(shader->uniforms[gluniform_leveltime], ((float)shader_leveltime) / TICRATE, pglUniform1f);
UNIFORM_1(shader->uniforms[gluniform_leveltime], shader_leveltime, pglUniform1f);
#undef UNIFORM_1
#undef UNIFORM_2

View file

@ -15,6 +15,7 @@
#include "doomdef.h"
#include "console.h"
#include "m_easing.h" // For Easing_InOutSine, used in R_UpdatePlaneRipple
#include "g_game.h"
#include "p_setup.h" // levelflats
#include "p_slopes.h"
@ -137,8 +138,14 @@ static void R_CalculatePlaneRipple(angle_t angle)
static void R_UpdatePlaneRipple(void)
{
ds_waterofs = (leveltime & 1)*16384;
planeripple.offset = (leveltime * 140);
// ds_waterofs oscillates between 0 and 16384 every other tic
// Now that frame interpolation is a thing, HOW does it oscillate?
// The difference between linear interpolation and a sine wave is miniscule here,
// but a sine wave is ever so slightly smoother and sleeker
ds_waterofs = Easing_InOutSine(((leveltime & 1)*FRACUNIT) + rendertimefrac,16384,0);
// Meanwhile, planeripple.offset just counts up, so it gets simple linear interpolation
planeripple.offset = ((leveltime-1)*140) + ((rendertimefrac*140) / FRACUNIT);
}
static void R_MapPlane(INT32 y, INT32 x1, INT32 x2)

View file

@ -3606,7 +3606,8 @@ void V_DoPostProcessor(INT32 view, postimg_t type, INT32 param)
UINT8 *tmpscr = screens[4];
UINT8 *srcscr = screens[0];
INT32 y;
angle_t disStart = (leveltime * 128) & FINEMASK; // in 0 to FINEANGLE
// Set disStart to a range from 0 to FINEANGLE, incrementing by 128 per tic
angle_t disStart = (((leveltime-1)*128) + (rendertimefrac / (FRACUNIT/128))) & FINEMASK;
INT32 newpix;
INT32 sine;
//UINT8 *transme = R_GetTranslucencyTable(tr_trans50);
@ -3729,8 +3730,11 @@ Unoptimized version
heatindex[view] %= height;
}
if (renderisnewtic) // This isn't interpolated... but how do you interpolate a one-pixel shift?
{
heatindex[view]++;
heatindex[view] %= vid.height;
}
VID_BlitLinearScreen(tmpscr+vid.width*vid.bpp*yoffset, screens[0]+vid.width*vid.bpp*yoffset,
vid.width*vid.bpp, height, vid.width*vid.bpp, vid.width);