From dc03359f3a44481338715be809ebf9038bd47e6f Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 30 May 2024 19:59:01 +0200 Subject: [PATCH 01/12] theres no value 3 oops i shouldnt do stuff after waking up at 4 in the morning lol --- src/hardware/hw_main.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 750b245fc..3cf998d84 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -184,7 +184,7 @@ static void CV_anisotropic_ONChange(void) static void CV_screentextures_ONChange(void) { ONLY_IF_GL_LOADED - if (cv_grscreentextures.value != 3) + if (cv_grscreentextures.value != 2) { #ifdef USE_FBO_OGL CV_Set(&cv_grframebuffer, "Off"); @@ -6240,10 +6240,10 @@ void HWR_DrawIntermissionBG(void) { patch_t *bgpatch = W_CachePatchName("SRB2BACK", PU_CACHE); - if (cv_grscreentextures.value != 3) - V_DrawPatchFill(bgpatch); // use the neato kart bg for intermission on disabled screen textures - else + if (cv_grscreentextures.value == 2) HWD.pfnDrawScreenTexture(HWD_SCREENTEXTURE_GENERIC1, NULL, 0); + else + V_DrawPatchFill(bgpatch); // use the neato kart bg for intermission on disabled screen textures } void HWR_DoWipe(UINT8 wipenum, UINT8 scrnnum) From b01a2836ea51bfd8d52b8b1116df8ee93052db3d Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 1 Jun 2024 16:29:40 +0200 Subject: [PATCH 02/12] cleanup some super old stuff that did nothing lul --- src/hardware/hw_glob.h | 2 -- src/r_defs.h | 9 +-------- src/r_patch.c | 4 ++-- src/r_things.c | 42 +++++++++++++++--------------------------- src/r_things.h | 2 -- 5 files changed, 18 insertions(+), 41 deletions(-) diff --git a/src/hardware/hw_glob.h b/src/hardware/hw_glob.h index a5b66a429..542a99b33 100644 --- a/src/hardware/hw_glob.h +++ b/src/hardware/hw_glob.h @@ -30,11 +30,9 @@ typedef struct gr_vissprite_s float gz, gzt; float tz, ty; float scale; - //lumpnum_t patchlumpnum; float spritexscale, spriteyscale; float spritexoffset, spriteyoffset; UINT32 renderflags; - UINT8 rotateflags; GLPatch_t *gpatch; boolean flip; UINT8 translucency; //alpha level 0-255 diff --git a/src/r_defs.h b/src/r_defs.h index 81e3f0c3a..40a4db023 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -649,15 +649,8 @@ typedef struct INT16 leftoffset; // pixels to the left of origin INT16 topoffset; // pixels below the origin INT32 columnofs[8]; // only [width] used - UINT8 *columns; // Software column data // the [0] is &columnofs[width] - - void *hardware; // OpenGL patch, allocated whenever necessary - -#ifdef ROTSPRITE - rotsprite_t *rotated; // Rotated patches -#endif -} patch_t; +}ATTRPACK patch_t; #ifdef _MSC_VER #pragma warning(disable : 4200) diff --git a/src/r_patch.c b/src/r_patch.c index 597a1a0de..bf0f28aa9 100644 --- a/src/r_patch.c +++ b/src/r_patch.c @@ -48,8 +48,8 @@ boolean R_CheckIfPatch(lumpnum_t lump) patch = (patch_t *)W_CacheLumpNum(lump, PU_STATIC); - width = patch->width; - height = patch->height; + width = SHORT(patch->width); + height = SHORT(patch->height); result = (height > 0 && height <= 16384 && width > 0 && width <= 16384 && width < (INT16)(size / 4)); diff --git a/src/r_things.c b/src/r_things.c index 1ea932ac3..8def2ff83 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -152,7 +152,6 @@ static void R_InstallSpriteLump(UINT16 wad, // graphics patch } #endif/*ROTSPRITE*/ - if (rotation == 0) { // the lump should be used for all rotations @@ -578,10 +577,8 @@ static vissprite_t *R_GetVisSprite(UINT32 num) static vissprite_t *R_NewVisSprite(void) { - if (visspritecount == MAXVISSPRITES) { - //CONS_Alert(CONS_ERROR, M_GetText("R_NewVisSprite: too many vissprites requested (maximum is %i)\n"), MAXVISSPRITES); + if (visspritecount == MAXVISSPRITES) return &overflowsprite; - } return R_GetVisSprite(visspritecount++); } @@ -656,8 +653,6 @@ void R_DrawMaskedColumn(column_t *column) dc_texturemid = basetexturemid; } -INT32 lengthcol; // column->length : for flipped column function pointers and multi-patch on 2sided wall = texture->height - static void R_DrawFlippedMaskedColumn(column_t *column, INT32 texheight) { INT32 topscreen; @@ -860,9 +855,6 @@ static void R_DrawVisSprite(vissprite_t *vis) if (vis->x2 >= vid.width) vis->x2 = vid.width-1; - lengthcol = SHORT(patch->height); - -#if 1 // Something is occasionally setting 1px-wide sprites whose frac is exactly the width of the sprite, causing crashes due to // accessing invalid column info. Until the cause is found, let's try to correct those manually... { @@ -870,7 +862,6 @@ static void R_DrawVisSprite(vissprite_t *vis) if (temp > 0) vis->x2 -= temp; } -#endif #define CLAMP(x, min_val, max_val) ((x) < (min_val) ? (min_val) : ((x) > (max_val) ? (max_val) : (x))) @@ -1177,6 +1168,7 @@ static void R_ProjectSprite(mobj_t *thing) // rotsprite fixed_t spr_width, spr_height; fixed_t spr_offset, spr_topoffset; + #ifdef ROTSPRITE patch_t *rotsprite = NULL; INT32 rollangle = 0; @@ -1482,7 +1474,6 @@ static void R_ProjectSprite(mobj_t *thing) scalestep = (yscale2 - yscale)/(x2 - x1); scalestep = scalestep ? scalestep : 1; - // The following two are alternate sorting methods which might be more applicable in some circumstances. TODO - maybe enable via MF2? // sortscale = max(yscale, yscale2); @@ -1558,16 +1549,13 @@ static void R_ProjectSprite(mobj_t *thing) if (heightsec != -1 && phs != -1) // only clip things which are in special sectors { - fixed_t top = gzt; - fixed_t bottom = interp.z; - if (viewz < sectors[phs].floorheight ? - bottom >= sectors[heightsec].floorheight : - top < sectors[heightsec].floorheight) + interp.z >= sectors[heightsec].floorheight : + gzt < sectors[heightsec].floorheight) return; if (viewz > sectors[phs].ceilingheight ? - top < sectors[heightsec].ceilingheight && viewz >= sectors[heightsec].ceilingheight : - bottom >= sectors[heightsec].ceilingheight) + gzt < sectors[heightsec].ceilingheight && viewz >= sectors[heightsec].ceilingheight : + interp.z >= sectors[heightsec].ceilingheight) return; } @@ -1594,6 +1582,15 @@ static void R_ProjectSprite(mobj_t *thing) vis->x1 = x1 < 0 ? 0 : x1; vis->x2 = x2 >= viewwidth ? viewwidth-1 : x2; + // PORTAL SEMI-CLIPPING + if (portalrender) + { + if (vis->x1 < portalclipstart) + vis->x1 = portalclipstart; + if (vis->x2 > portalclipend) + vis->x2 = portalclipend; + } + vis->sector = thing->subsector->sector; vis->szt = (INT16)((centeryfrac - FixedMul(vis->gzt - viewz, sortscale))>>FRACBITS); vis->sz = (INT16)((centeryfrac - FixedMul(vis->gz - viewz, sortscale))>>FRACBITS); @@ -1604,15 +1601,6 @@ static void R_ProjectSprite(mobj_t *thing) else vis->extra_colormap = thing->subsector->sector->extra_colormap; - // PORTAL SEMI-CLIPPING - if (portalrender) - { - if (vis->x1 < portalclipstart) - vis->x1 = portalclipstart; - if (vis->x2 > portalclipend) - vis->x2 = portalclipend; - } - vis->xscale = FixedMul(spritexscale, xscale); //SoM: 4/17/2000 vis->scale = FixedMul(spriteyscale, yscale); //<thingscale = interp.scale; diff --git a/src/r_things.h b/src/r_things.h index 88e1abdab..da2e90168 100644 --- a/src/r_things.h +++ b/src/r_things.h @@ -172,12 +172,10 @@ typedef struct vissprite_s spritecut_e cut; UINT32 renderflags; - UINT8 rotateflags; fixed_t spritexscale, spriteyscale; fixed_t spritexoffset, spriteyoffset; - INT16 clipbot[MAXVIDWIDTH], cliptop[MAXVIDWIDTH]; boolean precip; From 37a394ebaa63db043ff11a3526100fcb4938239e Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 31 May 2024 23:04:26 +0200 Subject: [PATCH 03/12] flexible array stuff for columnofs hopefully this fixes some crashes or smth --- src/r_defs.h | 2 +- src/r_patch.c | 28 ++++++++++++---------------- src/r_things.c | 3 +-- 3 files changed, 14 insertions(+), 19 deletions(-) diff --git a/src/r_defs.h b/src/r_defs.h index 40a4db023..99a185c7a 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -648,7 +648,7 @@ typedef struct INT16 height; INT16 leftoffset; // pixels to the left of origin INT16 topoffset; // pixels below the origin - INT32 columnofs[8]; // only [width] used + INT32 columnofs[]; // only [width] used // the [0] is &columnofs[width] }ATTRPACK patch_t; diff --git a/src/r_patch.c b/src/r_patch.c index bf0f28aa9..eea97cfbb 100644 --- a/src/r_patch.c +++ b/src/r_patch.c @@ -772,6 +772,17 @@ static UINT16 GetPatchPixel(patch_t *patch, INT32 x, INT32 y, boolean flip) return 0xFF00; } +#ifdef HWRENDER +static patch_t *R_CreateHardwarePatch(patch_t *patch) +{ + GLPatch_t *grPatch = Z_Calloc(sizeof(GLPatch_t), PU_HWRPATCHINFO, NULL); + grPatch->mipmap = Z_Calloc(sizeof(GLMipmap_t), PU_HWRPATCHINFO, NULL); + grPatch->rawpatch = patch; + HWR_MakePatch(patch, grPatch, grPatch->mipmap, false); + return (patch_t *)grPatch; +} +#endif + #ifdef ROTSPRITE // // R_GetRollAngle @@ -792,11 +803,7 @@ INT32 R_GetRollAngle(angle_t rollangle) return ra; } -patch_t *Patch_GetRotatedSprite( - spriteframe_t *sprite, - size_t frame, size_t spriteangle, - boolean flip, boolean adjustfeet, - void *info, INT32 rotationangle) +patch_t *Patch_GetRotatedSprite(spriteframe_t *sprite, size_t frame, size_t spriteangle, boolean flip, boolean adjustfeet, void *info, INT32 rotationangle) { rotsprite_t *rotsprite; spriteinfo_t *sprinfo = (spriteinfo_t *)info; @@ -882,17 +889,6 @@ static void RotatedPatch_CalculateDimensions( *newheight = max(height, max(h1, h2)); } -#ifdef HWRENDER -static patch_t *R_CreateHardwarePatch(patch_t *patch) -{ - GLPatch_t *grPatch = Z_Calloc(sizeof(GLPatch_t), PU_HWRPATCHINFO, NULL); - grPatch->mipmap = Z_Calloc(sizeof(GLMipmap_t), PU_HWRPATCHINFO, NULL); - grPatch->rawpatch = patch; - HWR_MakePatch(patch, grPatch, grPatch->mipmap, false); - return (patch_t *)grPatch; -} -#endif - void RotatedPatch_DoRotation(rotsprite_t *rotsprite, patch_t *patch, INT32 angle, INT32 xpivot, INT32 ypivot, boolean flip) { UINT32 i; diff --git a/src/r_things.c b/src/r_things.c index 8def2ff83..c0efbf751 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -1370,8 +1370,7 @@ static void R_ProjectSprite(mobj_t *thing) rollsum += thing->rollangle; rollangle = R_GetRollAngle(rollsum); - rotsprite = Patch_GetRotatedSprite( - sprframe, (thing->frame & FF_FRAMEMASK), rot, flip, false, sprinfo, rollangle); + rotsprite = Patch_GetRotatedSprite(sprframe, (thing->frame & FF_FRAMEMASK), rot, flip, false, sprinfo, rollangle); if (rotsprite != NULL) { From 8052eb1c3a0bf58fe531485ba709b528d75ba0fe Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 1 Jun 2024 16:29:20 +0200 Subject: [PATCH 04/12] fix papersprites in software (hopefully) lul --- src/r_things.c | 178 ++++++++++++++++++++++++++++++++++++------------- src/r_things.h | 3 + 2 files changed, 133 insertions(+), 48 deletions(-) diff --git a/src/r_things.c b/src/r_things.c index c0efbf751..daf589980 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -863,25 +863,27 @@ static void R_DrawVisSprite(vissprite_t *vis) vis->x2 -= temp; } -#define CLAMP(x, min_val, max_val) ((x) < (min_val) ? (min_val) : ((x) > (max_val) ? (max_val) : (x))) - // Split drawing loops for paper and non-paper to reduce conditional checks per sprite if (vis->scalestep) { + fixed_t horzscale = FixedMul(vis->spritexscale, this_scale); fixed_t scalestep = FixedMul(vis->scalestep, vis->spriteyscale); // Papersprite drawing loop - for (dc_x = vis->x1; dc_x <= vis->x2; dc_x++, frac += vis->xiscale) + for (dc_x = vis->x1; dc_x <= vis->x2; dc_x++, spryscale += scalestep) { -#ifndef RANGECHECK - if ((frac>>FRACBITS) < 0 || (frac>>FRACBITS) >= SHORT(patch->width)) // if this doesn't work i'm removing papersprites - break; -#endif + angle_t angle = ((vis->centerangle + xtoviewangle[dc_x]) >> ANGLETOFINESHIFT) & 0xFFF; + texturecolumn = (vis->paperoffset - FixedMul(FINETANGENT(angle), vis->paperdistance)) / horzscale; + + if (texturecolumn < 0 || texturecolumn >= SHORT(patch->width)) + continue; + + if (vis->xiscale < 0) // Flipped sprite + texturecolumn = SHORT(patch->width) - 1 - texturecolumn; + sprtopscreen = (centeryfrac - FixedMul(dc_texturemid, spryscale)); dc_iscale = (0xffffffffu / (unsigned)spryscale); - spryscale += scalestep; - texturecolumn = CLAMP(frac >> FRACBITS, 0, SHORT(patch->width) - 1); column = (column_t *)((UINT8 *)patch + LONG(patch->columnofs[texturecolumn])); if (vis->vflip) @@ -892,9 +894,12 @@ static void R_DrawVisSprite(vissprite_t *vis) } else { + // Non-paper drawing loop for (dc_x = vis->x1; dc_x <= vis->x2; dc_x++, frac += vis->xiscale) { +#define CLAMP(x, min_val, max_val) ((x) < (min_val) ? (min_val) : ((x) > (max_val) ? (max_val) : (x))) texturecolumn = CLAMP(frac >> FRACBITS, 0, SHORT(patch->width) - 1); +#undef CLAMP column = (column_t *)((UINT8 *)patch + LONG(patch->columnofs[texturecolumn])); if (vis->vflip) @@ -903,7 +908,7 @@ static void R_DrawVisSprite(vissprite_t *vis) R_DrawMaskedColumn(column); } } -#undef CLAMP + colfunc = basecolfunc; dc_hires = 0; @@ -1126,12 +1131,14 @@ fixed_t R_GetShadowZ(mobj_t *thing, pslope_t **shadowslope) static void R_ProjectSprite(mobj_t *thing) { mobj_t *oldthing = thing; + fixed_t tr_x, tr_y; fixed_t gxt, gyt; fixed_t tx, tz; fixed_t xscale, yscale, sortscale; //added : 02-02-98 : aaargll..if I were a math-guy!!! INT32 x1, x2; + INT32 x1test = 0, x2test = 0; spritedef_t *sprdef; spriteframe_t *sprframe; @@ -1157,6 +1164,7 @@ static void R_ProjectSprite(mobj_t *thing) fixed_t scalestep; // toast '16 fixed_t offset, offset2; boolean papersprite = (thing->frame & FF_PAPERSPRITE); + fixed_t paperoffset = 0, paperdistance = 0; angle_t centerangle = 0; //SoM: 3/17/2000 fixed_t gz, gzt; @@ -1176,8 +1184,6 @@ static void R_ProjectSprite(mobj_t *thing) angle_t pitchnroll = 0; angle_t sliptiderollangle = 0; #endif - - fixed_t ang_scale = FRACUNIT; INT32 dist = -1; @@ -1209,7 +1215,7 @@ static void R_ProjectSprite(mobj_t *thing) tz = gxt-gyt; // thing is behind view plane? - if (!(papersprite) && (tz < FixedMul(MINZ, this_scale))) // papersprite clipping is handled later + if (!papersprite && (tz < FixedMul(MINZ, this_scale))) // papersprite clipping is handled later return; gxt = -FixedMul(tr_x, viewsin); @@ -1280,14 +1286,9 @@ static void R_ProjectSprite(mobj_t *thing) { ang = R_PointToAngle (interp.x, interp.y) - interp.angle; camang = R_PointToAngle (interp.x, interp.y); - } - - if (sprframe->rotate != SRF_SINGLE || papersprite) - { + if (mirrored) ang = InvAngle(ang); - if (papersprite) - ang_scale = abs(FINESINE(ang>>ANGLETOFINESHIFT)); } if (sprframe->rotate == SRF_SINGLE) @@ -1387,10 +1388,11 @@ static void R_ProjectSprite(mobj_t *thing) } #endif + flip = !flip != !hflip; + // calculate edges of the shape spritexscale = interp.spritexscale; spriteyscale = interp.spriteyscale; - if (spritexscale < 1 || spriteyscale < 1) return; @@ -1409,39 +1411,19 @@ static void R_ProjectSprite(mobj_t *thing) spr_offset += interp.spritexoffset * flipoffset; spr_topoffset += interp.spriteyoffset * flipoffset; } - - flip = !flip != !hflip; if (flip) offset = spr_offset - spr_width; else offset = -spr_offset; - //offset = FixedMul(offset, FixedMul(spritexscale, this_scale)); - //offset2 = FixedMul(spr_width, FixedMul(spritexscale, this_scale)); // OH GOD I'M REVOOOOORTINGGGG AHHHHHHH - offset = FixedMul(offset, FixedMul(spritexscale, this_scale)); - tx += FixedMul(offset, ang_scale); - x1 = (centerxfrac + FixedMul (tx,xscale)) >>FRACBITS; - - // off the right side? - if (x1 > viewwidth) - return; - offset2 = FixedMul(spr_width, FixedMul(spritexscale, this_scale)); - tx += FixedMul(offset2, ang_scale); - x2 = ((centerxfrac + FixedMul (tx,xscale)) >> FRACBITS) - 1; - - // off the left side - if (x2 < 0) - return; if (papersprite) { - fixed_t yscale2, cosmul, sinmul, tz2; - - if (x2 <= x1) - return; + fixed_t xscale2, yscale2, cosmul, sinmul, tx2, tz2; + INT32 range; if (ang >= ANGLE_180) { @@ -1458,7 +1440,22 @@ static void R_ProjectSprite(mobj_t *thing) gyt = -FixedMul(tr_y, viewsin); tz = gxt-gyt; yscale = FixedDiv(projectiony, tz); - if (yscale < 64) return; // Fix some funky visuals + + gxt = -FixedMul(tr_x, viewsin); + gyt = FixedMul(tr_y, viewcos); + tx = -(gyt + gxt); + xscale = FixedDiv(projection, tz); + x1 = (centerxfrac + FixedMul(tx,xscale))>>FRACBITS; + + // Get paperoffset (offset) and paperoffset (distance) + paperoffset = -FixedMul(tr_x, cosmul) - FixedMul(tr_y, sinmul); + paperdistance = -FixedMul(tr_x, sinmul) + FixedMul(tr_y, cosmul); + if (paperdistance < 0) + { + paperoffset = -paperoffset; + paperdistance = -paperdistance; + } + centerangle = viewangle - interp.angle; tr_x += FixedMul(offset2, cosmul); tr_y += FixedMul(offset2, sinmul); @@ -1466,13 +1463,72 @@ static void R_ProjectSprite(mobj_t *thing) gyt = -FixedMul(tr_y, viewsin); tz2 = gxt-gyt; yscale2 = FixedDiv(projectiony, tz2); - if (yscale2 < 64) return; // ditto + //if (yscale2 < 64) return; // ditto + + gxt = -FixedMul(tr_x, viewsin); + gyt = FixedMul(tr_y, viewcos); + tx2 = -(gyt + gxt); + xscale2 = FixedDiv(projection, tz2); + x2 = ((centerxfrac + FixedMul(tx2,xscale2))>>FRACBITS); if (max(tz, tz2) < FixedMul(MINZ, this_scale)) // non-papersprite clipping is handled earlier return; - scalestep = (yscale2 - yscale)/(x2 - x1); - scalestep = scalestep ? scalestep : 1; + // Needs partially clipped + if (tz < FixedMul(MINZ, this_scale)) + { + fixed_t div = FixedDiv(tz2-tz, FixedMul(MINZ, this_scale)-tz); + tx += FixedDiv(tx2-tx, div); + tz = FixedMul(MINZ, this_scale); + } + else if (tz2 < FixedMul(MINZ, this_scale)) + { + fixed_t div = FixedDiv(tz-tz2, FixedMul(MINZ, this_scale)-tz2); + tx2 += FixedDiv(tx-tx2, div); + tz2 = FixedMul(MINZ, this_scale); + } + + if ((tx2 / 4) < -(FixedMul(tz2, fovtan)) || (tx / 4) > FixedMul(tz, fovtan)) // too far off the side? + return; + + yscale = FixedDiv(projectiony, tz); + xscale = FixedDiv(projection, tz); + + x1 = (centerxfrac + FixedMul(tx,xscale))>>FRACBITS; + + // off the right side? + if (x1 > viewwidth) + return; + + yscale2 = FixedDiv(projectiony, tz2); + xscale2 = FixedDiv(projection, tz2); + + x2 = (centerxfrac + FixedMul(tx2,xscale2))>>FRACBITS; + + // off the left side + if (x2 < 0) + return; + + range = x2 - x1; + + if (range < 0) + return; + + range++; // fencepost problem + + if (range > 32767) + { + // If the range happens to be too large for fixed_t, + // abort the draw to avoid xscale becoming negative due to arithmetic overflow. + return; + } + + scalestep = ((yscale2 - yscale)/range) ?: 1; + + if (scalestep == 0) + scalestep = 1; + + xscale = FixedDiv(range<>FRACBITS; + x1 = centerx + (FixedMul(tx,xscale) / FRACUNIT); - xscale = FixedMul(xscale, ang_scale); + x1test = (centerxfrac + FixedMul(tx,xscale))>>FRACBITS; + + if (x1test > viewwidth) + x1test = 0; + + // off the right side? + if (x1 > viewwidth) + return; + + tx += offset2; + //x2 = ((centerxfrac + FixedMul(tx,xscale))>>FRACBITS); x2--; + x2 = (centerx + (FixedMul(tx,xscale) / FRACUNIT)) - 1; + + x2test = ((centerxfrac + FixedMul(tx,xscale))>>FRACBITS) - 1; + + if (x2test < 0) + x2test = 0; + + // off the left side + if (x2 < 0) + return; + } // PORTAL SPRITE CLIPPING if (portalrender) @@ -1575,6 +1654,9 @@ static void R_ProjectSprite(mobj_t *thing) vis->pzt = vis->pz + vis->thingheight; vis->texturemid = FixedDiv(gzt - viewz, spriteyscale); vis->scalestep = scalestep; + vis->paperoffset = paperoffset; + vis->paperdistance = paperdistance; + vis->centerangle = centerangle; vis->mobj = thing; // Easy access! Tails 06-07-2002 diff --git a/src/r_things.h b/src/r_things.h index da2e90168..5b74eea02 100644 --- a/src/r_things.h +++ b/src/r_things.h @@ -149,8 +149,11 @@ typedef struct vissprite_s fixed_t thingscale; // the object's scale fixed_t sortscale; // sortscale only differs from scale for flat sprites fixed_t scalestep; // only for flat sprites, 0 otherwise + fixed_t paperoffset, paperdistance; // for paper sprites, offset/dist relative to the angle fixed_t xiscale; // negative if flipped + angle_t centerangle; // for paper sprites + fixed_t texturemid; patch_t *patch; From 957159d4859b2c73221b55cd9d2444d925bf904f Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 1 Jun 2024 16:31:49 +0200 Subject: [PATCH 05/12] forgor to remove that --- src/r_things.c | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/src/r_things.c b/src/r_things.c index daf589980..23208c622 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -1138,7 +1138,6 @@ static void R_ProjectSprite(mobj_t *thing) fixed_t xscale, yscale, sortscale; //added : 02-02-98 : aaargll..if I were a math-guy!!! INT32 x1, x2; - INT32 x1test = 0, x2test = 0; spritedef_t *sprdef; spriteframe_t *sprframe; @@ -1149,7 +1148,6 @@ static void R_ProjectSprite(mobj_t *thing) size_t rot; UINT8 flip; - /*boolean vflip = (!(thing->eflags & MFE_VERTICALFLIP) != !R_ThingVerticallyFlipped(thing));*/ boolean mirrored = thing->mirrored; boolean hflip = (!(thing->frame & FF_HORIZONTALFLIP) != !mirrored); @@ -1542,11 +1540,6 @@ static void R_ProjectSprite(mobj_t *thing) //x1 = (centerxfrac + FixedMul(tx,xscale))>>FRACBITS; x1 = centerx + (FixedMul(tx,xscale) / FRACUNIT); - x1test = (centerxfrac + FixedMul(tx,xscale))>>FRACBITS; - - if (x1test > viewwidth) - x1test = 0; - // off the right side? if (x1 > viewwidth) return; @@ -1555,11 +1548,6 @@ static void R_ProjectSprite(mobj_t *thing) //x2 = ((centerxfrac + FixedMul(tx,xscale))>>FRACBITS); x2--; x2 = (centerx + (FixedMul(tx,xscale) / FRACUNIT)) - 1; - x2test = ((centerxfrac + FixedMul(tx,xscale))>>FRACBITS) - 1; - - if (x2test < 0) - x2test = 0; - // off the left side if (x2 < 0) return; From 38633a85168f8577bfedd9899327821980f4dcfc Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 1 Jun 2024 17:03:27 +0200 Subject: [PATCH 06/12] stuffs --- src/r_things.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/r_things.c b/src/r_things.c index 23208c622..884da6302 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -744,7 +744,7 @@ static void R_DrawVisSprite(vissprite_t *vis) // TODO This check should not be necessary. But Papersprites near to the camera will sometimes create invalid values // for the vissprite's startfrac. This happens because they are not depth culled like other sprites. // Someone who is more familiar with papersprites pls check and try to fix <3 - if (vis->startfrac < 0 || vis->startfrac > (patch->width << FRACBITS)) + if (vis->startfrac < 0 || vis->startfrac > (SHORT(patch->width) << FRACBITS)) { // never draw vissprites with startfrac out of patch range return; @@ -1554,7 +1554,7 @@ static void R_ProjectSprite(mobj_t *thing) } // PORTAL SPRITE CLIPPING - if (portalrender) + if (portalrender && portalclipline) { if (x2 < portalclipstart || x1 > portalclipend) return; @@ -1652,7 +1652,7 @@ static void R_ProjectSprite(mobj_t *thing) vis->x2 = x2 >= viewwidth ? viewwidth-1 : x2; // PORTAL SEMI-CLIPPING - if (portalrender) + if (portalrender && portalclipline) { if (vis->x1 < portalclipstart) vis->x1 = portalclipstart; @@ -1809,7 +1809,7 @@ static void R_ProjectPrecipitationSprite(precipmobj_t *thing) tx = -(gyt + gxt); // too far off the side? - if (abs(tx) > tz<<2) + if (abs(tx) > FixedMul(tz, fovtan)<<2) return; // aspect ratio stuff : @@ -1857,7 +1857,7 @@ static void R_ProjectPrecipitationSprite(precipmobj_t *thing) return; // PORTAL SPRITE CLIPPING - if (portalrender) + if (portalrender && portalclipline) { if (x2 < portalclipstart || x1 > portalclipend) return; @@ -1889,12 +1889,13 @@ static void R_ProjectPrecipitationSprite(precipmobj_t *thing) vis->pzt = vis->pz + vis->thingheight; vis->texturemid = vis->gzt - viewz; vis->scalestep = 0; + vis->paperdistance = 0; vis->x1 = x1 < 0 ? 0 : x1; vis->x2 = x2 >= viewwidth ? viewwidth-1 : x2; // PORTAL SEMI-CLIPPING - if (portalrender) + if (portalrender && portalclipline) { if (vis->x1 < portalclipstart) vis->x1 = portalclipstart; From bf75644144290de36bca71126294b60e3938cd99 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 28 May 2024 20:28:27 +0200 Subject: [PATCH 07/12] make r_fps if else hell a bit more bearable to look at lol lmao --- src/r_fps.c | 67 ++++++++++++++++++----------------------------------- 1 file changed, 22 insertions(+), 45 deletions(-) diff --git a/src/r_fps.c b/src/r_fps.c index 91044b42e..52a89098f 100644 --- a/src/r_fps.c +++ b/src/r_fps.c @@ -287,6 +287,11 @@ angle_t R_InterpolateAngle(angle_t from, angle_t to) return (R_LerpAngle(from, to, rendertimefrac)); }*/ +#define IFCHANGED(a, b)\ +if (mobj->a == mobj->b)\ +(out->a = mobj->b);\ +else + void R_InterpolateMobjState(mobj_t *mobj, fixed_t frac, interpmobjstate_t *out) { if (frac == FRACUNIT) @@ -308,44 +313,28 @@ void R_InterpolateMobjState(mobj_t *mobj, fixed_t frac, interpmobjstate_t *out) return; } - if (mobj->x == mobj->old_x) - out->x = mobj->x; - else + IFCHANGED(x, old_x) out->x = R_LerpFixed(mobj->old_x, mobj->x, frac); - if (mobj->y == mobj->old_y) - out->y = mobj->y; - else + IFCHANGED(y, old_y) out->y = R_LerpFixed(mobj->old_y, mobj->y, frac); - if (mobj->z == mobj->old_z) - out->z = mobj->z; - else + IFCHANGED(z, old_z) out->z = R_LerpFixed(mobj->old_z, mobj->z, frac); - if (mobj->spritexscale == mobj->old_spritexscale) - out->spritexscale = mobj->spritexscale; - else + IFCHANGED(spritexscale, old_spritexscale) out->spritexscale = mobj->resetinterp ? mobj->spritexscale : R_LerpFixed(mobj->old_spritexscale, mobj->spritexscale, frac); - if (mobj->spriteyscale == mobj->old_spriteyscale) - out->spriteyscale = mobj->spriteyscale; - else + IFCHANGED(spriteyscale, old_spriteyscale) out->spriteyscale = mobj->resetinterp ? mobj->spriteyscale : R_LerpFixed(mobj->old_spriteyscale, mobj->spriteyscale, frac); - if (mobj->spritexoffset == mobj->old_spritexoffset) - out->spritexoffset = mobj->spritexoffset; - else + IFCHANGED(spritexoffset, old_spritexoffset) out->spritexoffset = mobj->resetinterp ? mobj->spritexoffset : R_LerpFixed(mobj->old_spritexoffset, mobj->spritexoffset, frac); - if (mobj->spriteyoffset == mobj->old_spriteyoffset) - out->spriteyoffset = mobj->spriteyoffset; - else + IFCHANGED(spriteyoffset, old_spriteyoffset) out->spriteyoffset = mobj->resetinterp ? mobj->spriteyoffset : R_LerpFixed(mobj->old_spriteyoffset, mobj->spriteyoffset, frac); - if (mobj->scale == mobj->old_scale) // Tiny optimisation - scale is usually unchanging, so let's skip a lerp, two FixedMuls, and two FixedDivs - out->scale = mobj->scale; - else + IFCHANGED(scale, old_scale) out->scale = mobj->resetinterp ? mobj->scale : R_LerpFixed(mobj->old_scale, mobj->scale, frac); if (cv_mobjssector.value) @@ -355,39 +344,27 @@ void R_InterpolateMobjState(mobj_t *mobj, fixed_t frac, interpmobjstate_t *out) if (mobj->player) { - if (mobj->angle == mobj->player->old_frameangle) - out->angle = mobj->player->frameangle; - else + IFCHANGED(angle, player->old_frameangle) out->angle = mobj->resetinterp ? mobj->player->frameangle : R_LerpAngle(mobj->player->old_frameangle, mobj->player->frameangle, frac); } else { - if (mobj->angle == mobj->old_angle) - out->angle = mobj->angle; - else + IFCHANGED(angle, old_angle) out->angle = mobj->resetinterp ? mobj->angle : R_LerpAngle(mobj->old_angle, mobj->angle, frac); } // pitch roll stuff - if (mobj->pitch == mobj->old_pitch) - out->pitch = mobj->pitch; - else + IFCHANGED(pitch, old_pitch) out->pitch = mobj->resetinterp ? mobj->pitch : R_LerpAngle(mobj->old_pitch, mobj->pitch, frac); - if (mobj->roll == mobj->old_roll) - out->roll = mobj->roll; - else + IFCHANGED(roll, old_roll) out->roll = mobj->resetinterp ? mobj->roll : R_LerpAngle(mobj->old_roll, mobj->roll, frac); // and the slope stuff - if (mobj->slopepitch == mobj->old_slopepitch) - out->slopepitch = mobj->slopepitch; - else + IFCHANGED(slopepitch, old_slopepitch) out->slopepitch = mobj->resetinterp ? mobj->slopepitch : R_LerpAngle(mobj->old_slopepitch, mobj->slopepitch, frac); - if (mobj->sloperoll == mobj->old_sloperoll) - out->sloperoll = mobj->sloperoll; - else + IFCHANGED(sloperoll, old_sloperoll) out->sloperoll = mobj->resetinterp ? mobj->sloperoll : R_LerpAngle(mobj->old_sloperoll, mobj->sloperoll, frac); } @@ -422,12 +399,12 @@ void R_InterpolatePrecipMobjState(precipmobj_t *mobj, fixed_t frac, interpmobjst else out->subsector = mobj->subsector; - if (mobj->angle == mobj->old_angle) - out->angle = mobj->angle; - else + IFCHANGED(angle, old_angle) out->angle = R_LerpAngle(mobj->old_angle, mobj->angle, frac); } +#undef IFCHANGED + static void AddInterpolator(levelinterpolator_t* interpolator) { if (levelinterpolators_len >= levelinterpolators_size) From ee2ec01eb9796c41f435cbfa41a7046bff4039c9 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 2 Jun 2024 00:44:48 +0200 Subject: [PATCH 08/12] use shader to prevent sprite floor clipping from durr lul --- src/hardware/hw_main.c | 25 ------------------------- src/hardware/hw_shaders.c | 2 +- src/hardware/hw_shaders.h | 11 +++++++++++ 3 files changed, 12 insertions(+), 26 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 3cf998d84..c5be8d185 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -3970,18 +3970,6 @@ static void HWR_SplitSprite(gr_vissprite_t *spr) // Let dispoffset work first since this adjust each vertex HWR_RotateSpritePolyToAim(spr, baseWallVerts, false); - // push it toward the camera to mitigate floor-clipping sprites - { - float sprdist = sqrtf((spr->x1 - gr_viewx)*(spr->x1 - gr_viewx) + (spr->z1 - gr_viewy)*(spr->z1 - gr_viewy) + (spr->ty - gr_viewz)*(spr->ty - gr_viewz)); - float distfact = ((2.0f*spr->dispoffset) + 20.0f) / sprdist; - for (i = 0; i < 4; i++) - { - baseWallVerts[i].x += (gr_viewx - baseWallVerts[i].x)*distfact; - baseWallVerts[i].z += (gr_viewy - baseWallVerts[i].z)*distfact; - baseWallVerts[i].y += (gr_viewz - baseWallVerts[i].y)*distfact; - } - } - realtop = top = baseWallVerts[3].y; realbot = bot = baseWallVerts[0].y; towtop = baseWallVerts[3].t; @@ -4252,19 +4240,6 @@ static void HWR_DrawSprite(gr_vissprite_t *spr) // ...nah HWR_RotateSpritePolyToAim(spr, wallVerts, false); - // push it toward the camera to mitigate floor-clipping sprites - { - float sprdist = sqrtf((spr->x1 - gr_viewx)*(spr->x1 - gr_viewx) + (spr->z1 - gr_viewy)*(spr->z1 - gr_viewy) + (spr->ty - gr_viewz)*(spr->ty - gr_viewz)); - float distfact = ((2.0f*spr->dispoffset) + 20.0f) / sprdist; - size_t i; - for (i = 0; i < 4; i++) - { - wallVerts[i].x += (gr_viewx - wallVerts[i].x)*distfact; - wallVerts[i].z += (gr_viewy - wallVerts[i].z)*distfact; - wallVerts[i].y += (gr_viewz - wallVerts[i].y)*distfact; - } - } - // This needs to be AFTER the shadows so that the regular sprites aren't drawn completely black. // sprite lighting by modulating the RGB components /// \todo coloured diff --git a/src/hardware/hw_shaders.c b/src/hardware/hw_shaders.c index 427bd1540..a20375981 100644 --- a/src/hardware/hw_shaders.c +++ b/src/hardware/hw_shaders.c @@ -33,7 +33,7 @@ static struct { {GLSL_DEFAULT_VERTEX_SHADER, GLSL_WALL_FRAGMENT_SHADER}, // Sprite shader - {GLSL_DEFAULT_VERTEX_SHADER, GLSL_WALL_FRAGMENT_SHADER}, + {GLSL_SPRITECLIP_HACK_VERTEX_SHADER, GLSL_WALL_FRAGMENT_SHADER}, // Model shader {GLSL_DEFAULT_VERTEX_SHADER, GLSL_WALL_FRAGMENT_SHADER}, diff --git a/src/hardware/hw_shaders.h b/src/hardware/hw_shaders.h index eb705c34c..e817419a1 100644 --- a/src/hardware/hw_shaders.h +++ b/src/hardware/hw_shaders.h @@ -31,6 +31,17 @@ "gl_ClipVertex = gl_ModelViewMatrix * gl_Vertex;\n" \ "}\0" +// Sprite clipping makes me want to McFucking Die + +#define GLSL_SPRITECLIP_HACK_VERTEX_SHADER \ + "void main(void) {\n" \ + "gl_Position = gl_ProjectionMatrix * gl_ModelViewMatrix * gl_Vertex;\n" \ + "gl_FrontColor = gl_Color;\n" \ + "gl_TexCoord[0].xy = gl_MultiTexCoord0.xy;\n" \ + "gl_ClipVertex = gl_ModelViewMatrix * gl_Vertex;\n" \ + "gl_Position.z -= 80 / gl_Position.z;\n" \ + "}\0" + // ================== // Fragment shaders // ================== From cae40928ad16d088168bc4ba890de890d9337ee6 Mon Sep 17 00:00:00 2001 From: Indev Date: Mon, 3 Jun 2024 00:17:11 +0300 Subject: [PATCH 09/12] Use Z_Calloc to allocate wadfile_t to avoid having uninitialized fields --- src/w_wad.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/w_wad.c b/src/w_wad.c index cd2968494..15c7db38c 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -789,7 +789,7 @@ UINT16 W_InitFile(const char *filename, boolean local) // // link wad file to search files // - wadfile = Z_Malloc(sizeof (*wadfile), PU_STATIC, NULL); + wadfile = Z_Calloc(sizeof (*wadfile), PU_STATIC, NULL); wadfile->filename = Z_StrDup(filename); wadfile->handle = handle; wadfile->numlumps = (UINT16)numlumps; @@ -798,7 +798,6 @@ UINT16 W_InitFile(const char *filename, boolean local) fseek(handle, 0, SEEK_END); wadfile->filesize = (unsigned)ftell(handle); wadfile->type = type; - wadfile->majormod = false; // already generated, just copy it over M_Memcpy(&wadfile->md5sum, &md5sum, 16); From f977af6a802ffb4330a21d9c790a0e37c72c8e5b Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 3 Jun 2024 15:13:39 +0200 Subject: [PATCH 10/12] fix le dispoffset --- src/hardware/hw_defs.h | 1 + src/hardware/hw_main.c | 23 ++++++++++++++++++++++- src/hardware/hw_shaders.c | 4 ++++ src/hardware/hw_shaders.h | 2 +- src/r_things.c | 3 +-- 5 files changed, 29 insertions(+), 4 deletions(-) diff --git a/src/hardware/hw_defs.h b/src/hardware/hw_defs.h index 419549d73..d16b490b7 100644 --- a/src/hardware/hw_defs.h +++ b/src/hardware/hw_defs.h @@ -174,6 +174,7 @@ enum SHADER_NONE = -1, SHADER_FLOOR = 0, SHADER_WALL, + SHADER_SPRITECLIPHACK, SHADER_MODEL, SHADER_SPRITE, SHADER_WATER, diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index c5be8d185..61d4e85e0 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -3967,6 +3967,17 @@ static void HWR_SplitSprite(gr_vissprite_t *spr) baseWallVerts[0].t = baseWallVerts[1].t = gpatch->max_t; } + // if it has a dispoffset, push it a little towards the camera + if (spr->dispoffset) + { + float co = -gr_viewcos*(0.05f*spr->dispoffset); + float si = -gr_viewsin*(0.05f*spr->dispoffset); + baseWallVerts[0].z = baseWallVerts[3].z = baseWallVerts[0].z+si; + baseWallVerts[1].z = baseWallVerts[2].z = baseWallVerts[1].z+si; + baseWallVerts[0].x = baseWallVerts[3].x = baseWallVerts[0].x+co; + baseWallVerts[1].x = baseWallVerts[2].x = baseWallVerts[1].x+co; + } + // Let dispoffset work first since this adjust each vertex HWR_RotateSpritePolyToAim(spr, baseWallVerts, false); @@ -4236,8 +4247,18 @@ static void HWR_DrawSprite(gr_vissprite_t *spr) HWR_DrawSpriteShadow(spr, gpatch, this_scale); } + // if it has a dispoffset, push it a little towards the camera + if (spr->dispoffset) + { + float co = -gr_viewcos*(0.05f*spr->dispoffset); + float si = -gr_viewsin*(0.05f*spr->dispoffset); + wallVerts[0].z = wallVerts[3].z = wallVerts[0].z+si; + wallVerts[1].z = wallVerts[2].z = wallVerts[1].z+si; + wallVerts[0].x = wallVerts[3].x = wallVerts[0].x+co; + wallVerts[1].x = wallVerts[2].x = wallVerts[1].x+co; + } + // Let dispoffset work first since this adjust each vertex - // ...nah HWR_RotateSpritePolyToAim(spr, wallVerts, false); // This needs to be AFTER the shadows so that the regular sprites aren't drawn completely black. diff --git a/src/hardware/hw_shaders.c b/src/hardware/hw_shaders.c index a20375981..fb6b9661c 100644 --- a/src/hardware/hw_shaders.c +++ b/src/hardware/hw_shaders.c @@ -33,6 +33,9 @@ static struct { {GLSL_DEFAULT_VERTEX_SHADER, GLSL_WALL_FRAGMENT_SHADER}, // Sprite shader + {GLSL_DEFAULT_VERTEX_SHADER, GLSL_WALL_FRAGMENT_SHADER}, + + // Sprite clipping hack shader (for pulling things out of the floor) {GLSL_SPRITECLIP_HACK_VERTEX_SHADER, GLSL_WALL_FRAGMENT_SHADER}, // Model shader @@ -424,6 +427,7 @@ customshaderxlat_t shaderxlat[] = {"Flat", SHADER_FLOOR}, {"WallTexture", SHADER_WALL}, {"Sprite", SHADER_SPRITE}, + {"SpriteClipHack", SHADER_SPRITECLIPHACK}, {"Model", SHADER_MODEL}, {"WaterRipple", SHADER_WATER}, {"Fog", SHADER_FOG}, diff --git a/src/hardware/hw_shaders.h b/src/hardware/hw_shaders.h index e817419a1..3840eaef1 100644 --- a/src/hardware/hw_shaders.h +++ b/src/hardware/hw_shaders.h @@ -39,7 +39,7 @@ "gl_FrontColor = gl_Color;\n" \ "gl_TexCoord[0].xy = gl_MultiTexCoord0.xy;\n" \ "gl_ClipVertex = gl_ModelViewMatrix * gl_Vertex;\n" \ - "gl_Position.z -= 80 / gl_Position.z;\n" \ + "gl_Position.z -= 80.0 / gl_Position.z;\n" \ "}\0" // ================== diff --git a/src/r_things.c b/src/r_things.c index 884da6302..0fa96a4ce 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -299,8 +299,7 @@ static boolean R_AddSingleSpriteDef(const char *sprname, spritedef_t *spritedef, spritecachedinfo[numspritelumps].height = SHORT(patch.height)< Date: Mon, 3 Jun 2024 13:53:59 +0200 Subject: [PATCH 11/12] add toggle for beta intermission screen + smol cleanup --- src/d_netcmd.c | 4 ++++ src/d_netcmd.h | 2 ++ src/hardware/hw_main.c | 7 +------ src/y_inter.c | 29 ++++++++++++++++++----------- 4 files changed, 25 insertions(+), 17 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 1e46da57f..8701448b4 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -577,6 +577,8 @@ static CV_PossibleValue_t skinselectgridsort_t[] ={ }; consvar_t cv_skinselectgridsort ={ "skinselectgridsort", "Real name", CV_SAVE|CV_CALL|CV_NOINIT, skinselectgridsort_t, sortSkinGrid, 0, NULL, NULL, 0, 0, NULL }; +consvar_t cv_betainterscreen = {"betaintermissionscreen", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; + INT16 gametype = GT_RACE; // SRB2kart boolean forceresetplayers = false; boolean deferencoremode = false; @@ -822,6 +824,8 @@ void D_RegisterServerCommands(void) CV_RegisterVar(&cv_netdemosyncquality); CV_RegisterVar(&cv_maxdemosize); CV_RegisterVar(&cv_keyboardlayout); + + CV_RegisterVar(&cv_betainterscreen); } // ========================================================================= diff --git a/src/d_netcmd.h b/src/d_netcmd.h index e9934e237..b02b68f00 100644 --- a/src/d_netcmd.h +++ b/src/d_netcmd.h @@ -205,6 +205,8 @@ extern consvar_t cv_showtrackaddon; extern consvar_t cv_showspecstuff; +extern consvar_t cv_betainterscreen; + typedef enum { SKINMENUTYPE_SCROLL = 0, diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 61d4e85e0..af7fc8f37 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -6234,12 +6234,7 @@ void HWR_EndScreenWipe(void) void HWR_DrawIntermissionBG(void) { - patch_t *bgpatch = W_CachePatchName("SRB2BACK", PU_CACHE); - - if (cv_grscreentextures.value == 2) - HWD.pfnDrawScreenTexture(HWD_SCREENTEXTURE_GENERIC1, NULL, 0); - else - V_DrawPatchFill(bgpatch); // use the neato kart bg for intermission on disabled screen textures + HWD.pfnDrawScreenTexture(HWD_SCREENTEXTURE_GENERIC1, NULL, 0); } void HWR_DoWipe(UINT8 wipenum, UINT8 scrnnum) diff --git a/src/y_inter.c b/src/y_inter.c index cc1d7dd9c..58cfdc4e0 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -100,10 +100,10 @@ static y_data data; static patch_t *bgpatch = NULL; // INTERSCR static patch_t *widebgpatch = NULL; // INTERSCW static patch_t *bgtile = NULL; // SPECTILE/SRB2BACK -static patch_t *interpic = NULL; // custom picture defined in map header -static boolean usetile; +//static patch_t *interpic = NULL; // custom picture defined in map header +//static boolean usetile; boolean usebuffer = false; -static boolean useinterpic; +//static boolean useinterpic; static INT32 timer; static INT32 intertic; @@ -392,9 +392,16 @@ void Y_IntermissionDrawer(void) if (!usebuffer) V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, 31); - if (useinterpic) - V_DrawScaledPatch(0, 0, 0, interpic); - else if (!usetile) + if (cv_betainterscreen.value +#ifdef HWRENDER + || (rendermode == render_opengl && cv_grscreentextures.value != 2) // use the neato kart bg for intermission on disabled screen textures +#endif + ) + V_DrawPatchFill(bgtile); // use the neato kart bg for intermission on disabled screen textures + //else if (useinterpic) + //V_DrawScaledPatch(0, 0, 0, interpic); + //else if (!usetile) + else { if (rendermode == render_soft && usebuffer) VID_BlitLinearScreen(screens[1], screens[0], vid.width*vid.bpp, vid.height, vid.width*vid.bpp, vid.rowbytes); @@ -412,8 +419,8 @@ void Y_IntermissionDrawer(void) V_DrawScaledPatch(0, 0, 0, bgpatch); } } - else if (bgtile) - V_DrawPatchFill(bgtile); + //else if (bgtile) + //V_DrawPatchFill(bgtile); if (usebuffer) // Fade everything out V_DrawFadeScreen(0xFF00, 22); @@ -937,8 +944,8 @@ void Y_StartIntermission(void) //if (intertype == int_race || intertype == int_match) { - //bgtile = W_CachePatchName("SRB2BACK", PU_STATIC); - usetile = useinterpic = false; + bgtile = W_CachePatchName("SRB2BACK", PU_STATIC); + //usetile = useinterpic = false; usebuffer = true; } @@ -988,7 +995,7 @@ static void Y_UnloadData(void) UNLOAD(bgpatch); UNLOAD(widebgpatch); UNLOAD(bgtile); - UNLOAD(interpic); + //UNLOAD(interpic); } // SRB2Kart: Voting! From 9de3db7c97492486264c7faf378598f5b8d77868 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 3 Jun 2024 16:52:25 +0200 Subject: [PATCH 12/12] add shader for shadows to also fix sprite shadows in pal render --- src/hardware/hw_defs.h | 1 + src/hardware/hw_main.c | 8 +++++--- src/hardware/hw_shaders.c | 4 ++++ src/hardware/hw_shaders.h | 24 ++++++++++++++++++++++++ 4 files changed, 34 insertions(+), 3 deletions(-) diff --git a/src/hardware/hw_defs.h b/src/hardware/hw_defs.h index d16b490b7..9f95f8fcd 100644 --- a/src/hardware/hw_defs.h +++ b/src/hardware/hw_defs.h @@ -173,6 +173,7 @@ enum { SHADER_NONE = -1, SHADER_FLOOR = 0, + SHADER_SHADOW, SHADER_WALL, SHADER_SPRITECLIPHACK, SHADER_MODEL, diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index af7fc8f37..6fae23c77 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -3647,6 +3647,7 @@ static void HWR_DrawSpriteShadow(gr_vissprite_t *spr, GLPatch_t *gpatch, float t { FOutVector swallVerts[4]; FSurfaceInfo sSurf; + FBITFIELD blendmode = 0; fixed_t floorheight, mobjfloor; pslope_t *floorslope; fixed_t slopez; @@ -3802,13 +3803,14 @@ static void HWR_DrawSpriteShadow(gr_vissprite_t *spr, GLPatch_t *gpatch, float t if (sSurf.PolyColor.s.alpha > floorheight/4) { sSurf.PolyColor.s.alpha = (UINT8)(sSurf.PolyColor.s.alpha - floorheight/4); - + if (HWR_UseShader()) { - shader = SHADER_FLOOR; // floor shader + shader = SHADER_SHADOW; + blendmode |= PF_ColorMapped; } - HWR_ProcessPolygon(&sSurf, swallVerts, 4, PF_Translucent|PF_Modulated, shader, false); + HWR_ProcessPolygon(&sSurf, swallVerts, 4, blendmode|PF_Translucent|PF_Modulated, shader, false); } } diff --git a/src/hardware/hw_shaders.c b/src/hardware/hw_shaders.c index fb6b9661c..c4109837c 100644 --- a/src/hardware/hw_shaders.c +++ b/src/hardware/hw_shaders.c @@ -29,6 +29,9 @@ static struct { // Floor shader {GLSL_DEFAULT_VERTEX_SHADER, GLSL_FLOOR_FRAGMENT_SHADER}, + // Shadow shader + {GLSL_SPRITECLIP_HACK_VERTEX_SHADER, GLSL_SHADOW_FRAGMENT_SHADER}, + // Wall shader {GLSL_DEFAULT_VERTEX_SHADER, GLSL_WALL_FRAGMENT_SHADER}, @@ -425,6 +428,7 @@ static inline UINT16 HWR_FindShaderDefs(UINT16 wadnum) customshaderxlat_t shaderxlat[] = { {"Flat", SHADER_FLOOR}, + {"Shadow", SHADER_SHADOW}, {"WallTexture", SHADER_WALL}, {"Sprite", SHADER_SPRITE}, {"SpriteClipHack", SHADER_SPRITECLIPHACK}, diff --git a/src/hardware/hw_shaders.h b/src/hardware/hw_shaders.h index 3840eaef1..6c225b1a8 100644 --- a/src/hardware/hw_shaders.h +++ b/src/hardware/hw_shaders.h @@ -144,6 +144,26 @@ "gl_FragColor = final_color;\n" \ "}\n" \ "#endif\0" + +#define GLSL_SOFTWARE_FRAGMENT_SHADER_NOPAL \ + "uniform sampler2D tex;\n" \ + "uniform vec4 poly_color;\n" \ + "uniform vec4 tint_color;\n" \ + "uniform vec4 fade_color;\n" \ + "uniform float lighting;\n" \ + "uniform float fade_start;\n" \ + "uniform float fade_end;\n" \ + GLSL_DOOM_COLORMAP \ + GLSL_DOOM_LIGHT_EQUATION \ + "void main(void) {\n" \ + "vec4 texel = texture2D(tex, gl_TexCoord[0].st);\n" \ + "vec4 base_color = texel * poly_color;\n" \ + "vec4 final_color = base_color;\n" \ + GLSL_SOFTWARE_TINT_EQUATION \ + GLSL_SOFTWARE_FADE_EQUATION \ + "final_color.a = texel.a * poly_color.a;\n" \ + "gl_FragColor = final_color;\n" \ + "}\n" \ // hand tuned adjustments for light level calculation #define GLSL_FLOOR_FUDGES \ @@ -161,6 +181,10 @@ #define GLSL_WALL_FRAGMENT_SHADER \ GLSL_WALL_FUDGES \ GLSL_SOFTWARE_FRAGMENT_SHADER + +#define GLSL_SHADOW_FRAGMENT_SHADER \ + GLSL_FLOOR_FUDGES \ + GLSL_SOFTWARE_FRAGMENT_SHADER_NOPAL // // Water surface shader