From d18567e0c4e86cfada23eb5cc727c1392a51d0e9 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 5 Jul 2025 22:45:10 +0200 Subject: [PATCH] =?UTF-8?q?funneh=20w=C3=B6ter=20w=C3=A4ve=20shader?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit this should be a fof flag so it can be applied if desired instead of doing all this crap, but its too late for such things at this point --- src/hardware/hw_defs.h | 2 ++ src/hardware/hw_main.cpp | 12 +++++++----- src/hardware/hw_shaders.c | 3 +++ src/hardware/hw_shaders.h | 21 +++++++++++++++++++++ 4 files changed, 33 insertions(+), 5 deletions(-) diff --git a/src/hardware/hw_defs.h b/src/hardware/hw_defs.h index 36f5326a5..4ac6af5f1 100644 --- a/src/hardware/hw_defs.h +++ b/src/hardware/hw_defs.h @@ -201,6 +201,7 @@ enum SHADER_SPRITE, SHADER_MODEL, SHADER_WATER, + SHADER_WAVE, SHADER_FOG, SHADER_SKY, SHADER_PALETTE_POSTPROCESS, @@ -263,6 +264,7 @@ enum EPolyFlags PF_ForceWrapX = 0x00020000, // Force repeat texture on X PF_ForceWrapY = 0x00040000, // Forces repeat texture on Y PF_Ripple = 0x00100000, // Water ripple effect. The current backend doesn't use it for anything. + PF_Wave = 0x00200000, // Water wave effect. PF_Skydecal = 0x20000000 // Enables smaller polygon offset, to be used for skywalls only // 0x20000000 // 0x40000000 diff --git a/src/hardware/hw_main.cpp b/src/hardware/hw_main.cpp index 8589fdb8e..86643e1fb 100644 --- a/src/hardware/hw_main.cpp +++ b/src/hardware/hw_main.cpp @@ -754,6 +754,8 @@ static void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, bool shader = SHADER_FOG; else if (cv_ripplewater.value && (PolyFlags & PF_Ripple)) shader = SHADER_WATER; + else if (cv_ripplewater.value && (PolyFlags & PF_Wave)) + shader = SHADER_WAVE; else shader = SHADER_FLOOR; @@ -2896,8 +2898,8 @@ static boolean HWR_DoCulling(line_t *cullheight, line_t *viewcullheight, float v static FBITFIELD HWR_RippleBlend(sector_t *sector, ffloor_t *rover, boolean ceiling) { (void)sector; - (void)ceiling; - return /*R_IsRipplePlane(sector, rover, ceiling)*/ (rover->flags & FF_RIPPLE) ? PF_Ripple : 0; + //(void)ceiling; + return /*R_IsRipplePlane(sector, rover, ceiling)*/ ((rover->flags & FF_RIPPLE) ? (ceiling ? PF_Wave : PF_Ripple) : 0); } // -----------------+ @@ -3057,7 +3059,7 @@ static void HWR_Subsector(size_t num) // rendering heights for bottom and top planes // yes there were functions for this stuff, no idea why it wasnt used but bleh bottomCullHeight = P_GetFFloorBottomZAt(rover, viewx, viewy); - topCullHeight = P_GetFFloorTopZAt(rover, viewx, viewy); + topCullHeight = P_GetFFloorTopZAt(rover, viewx, viewy); if (gl_frontsector->cullheight) { @@ -3143,7 +3145,7 @@ static void HWR_Subsector(size_t num) true, *rover->topheight, *gl_frontsector->lightlist[light].lightlevel, - CLAMP(rover->alpha, 0 ,255), rover->master->frontsector, HWR_RippleBlend(gl_frontsector, rover, false) | (rover->blend ? HWR_GetBlendModeFlag(rover->blend) : static_cast(PF_Translucent)), + CLAMP(rover->alpha, 0 ,255), rover->master->frontsector, HWR_RippleBlend(gl_frontsector, rover, *rover->topheight < rover->target->ceilingheight-(20*FRACUNIT) /*random offset that seems fitting ig*/) | (rover->blend ? HWR_GetBlendModeFlag(rover->blend) : static_cast(PF_Translucent)), false, gl_frontsector->lightlist[light].extra_colormap); } else @@ -3151,7 +3153,7 @@ static void HWR_Subsector(size_t num) HWR_GetFlat(levelflats[*rover->toppic].lumpnum, R_NoEncore(gl_frontsector, true)); light = R_GetPlaneLight(gl_frontsector, centerHeight, (viewz < topCullHeight)); - HWR_RenderPlane(sub, &extrasubsectors[num], true, *rover->topheight, HWR_RippleBlend(gl_frontsector, rover, false)|PF_Occlude, *gl_frontsector->lightlist[light].lightlevel, levelflats[*rover->toppic].lumpnum, + HWR_RenderPlane(sub, &extrasubsectors[num], true, *rover->topheight, HWR_RippleBlend(gl_frontsector, rover, *rover->topheight < rover->target->ceilingheight-(20*FRACUNIT))|PF_Occlude, *gl_frontsector->lightlist[light].lightlevel, levelflats[*rover->toppic].lumpnum, rover->master->frontsector, 255, gl_frontsector->lightlist[light].extra_colormap); } } diff --git a/src/hardware/hw_shaders.c b/src/hardware/hw_shaders.c index bba4d1e3e..bb1731f40 100644 --- a/src/hardware/hw_shaders.c +++ b/src/hardware/hw_shaders.c @@ -41,6 +41,9 @@ static struct { // Water shader {GLSL_DEFAULT_VERTEX_SHADER, GLSL_WATER_FRAGMENT_SHADER}, + // Water Wave shader + {GLSL_WAVE_VERTEX_SHADER, GLSL_WATER_FRAGMENT_SHADER}, + // Fog shader {GLSL_DEFAULT_VERTEX_SHADER, GLSL_FOG_FRAGMENT_SHADER}, diff --git a/src/hardware/hw_shaders.h b/src/hardware/hw_shaders.h index fc3642b21..8142e7056 100644 --- a/src/hardware/hw_shaders.h +++ b/src/hardware/hw_shaders.h @@ -31,6 +31,27 @@ "gl_ClipVertex = gl_ModelViewMatrix * gl_Vertex;\n" \ "}\0" +// adjust the amplitude for beeegger wäves on ze wöter +// this is pretty meh but idk what im doing lmao +#define GLSL_WAVE_VERTEX_SHADER \ + "uniform float leveltime;\n" \ + "const float waveSpeed = 2.5;\n" \ + "const float waveFrequency = 0.7;\n" \ + "const float waveAmplitude = 1.8;\n" \ + "void main()\n" \ + "{\n" \ + "vec4 modelPos = gl_Vertex;\n" \ + "float timeF = leveltime * waveSpeed;\n" \ + "float wave1 = sin(timeF) * waveAmplitude;\n" \ + "float wave2 = cos(timeF * 1.3) * waveAmplitude;\n" \ + "modelPos.y += wave1 + wave2;\n" \ + "vec4 worldPos = gl_ModelViewMatrix * modelPos;\n" \ + "gl_Position = gl_ProjectionMatrix * worldPos;\n" \ + "gl_FrontColor = gl_Color;\n" \ + "gl_TexCoord[0].xy = gl_MultiTexCoord0.xy;\n" \ + "gl_ClipVertex = worldPos;\n" \ + "}\0" + // reinterpretation of sprite lighting for models // it's a combination of how it works for normal sprites & papersprites #define GLSL_MODEL_LIGHTING_VERTEX_SHADER \