From 9eff693d002a8b852766151e47f6efa84cec441f Mon Sep 17 00:00:00 2001 From: Indev Date: Wed, 27 Dec 2023 15:18:06 +0300 Subject: [PATCH 1/6] Fix noencore effect not working for walls in opengl renderer --- src/hardware/hw_cache.c | 12 ++--- src/hardware/hw_glob.h | 6 +-- src/hardware/hw_main.c | 97 ++++++++++++++++++++++------------------- src/hardware/hw_main.h | 2 +- 4 files changed, 62 insertions(+), 55 deletions(-) diff --git a/src/hardware/hw_cache.c b/src/hardware/hw_cache.c index bfd5fa26d..7f7f031a6 100644 --- a/src/hardware/hw_cache.c +++ b/src/hardware/hw_cache.c @@ -320,7 +320,7 @@ static UINT8 *MakeBlock(GLMipmap_t *grMipmap) // Create a composite texture from patches, adapt the texture size to a power of 2 // height and width for the hardware texture cache. // -static void HWR_GenerateTexture(INT32 texnum, GLTexture_t *grtex) +static void HWR_GenerateTexture(INT32 texnum, GLTexture_t *grtex, boolean noencore) { UINT8 *block; texture_t *texture; @@ -354,7 +354,7 @@ static void HWR_GenerateTexture(INT32 texnum, GLTexture_t *grtex) grtex->mipmap.colormap = colormaps; #ifdef GLENCORE - if (encoremap) + if (encoremap && !noencore) grtex->mipmap.colormap += (256*32); #endif @@ -552,7 +552,7 @@ void HWR_PrepLevelCache(size_t pnumtextures) HWR_FreeTextureCache(); gr_numtextures = pnumtextures; - gr_textures = calloc(pnumtextures, sizeof (*gr_textures)); + gr_textures = calloc(pnumtextures, sizeof (*gr_textures)*2); // *2 - 1 for encore-remapped texture and another for noencore texture (unused when not in encore) if (gr_textures == NULL) I_Error("HWR_PrepLevelCache: can't alloc gr_textures"); } @@ -579,17 +579,17 @@ void HWR_SetPalette(RGBA_t *palette) // -------------------------------------------------------------------------- // Make sure texture is downloaded and set it as the source // -------------------------------------------------------------------------- -GLTexture_t *HWR_GetTexture(INT32 tex) +GLTexture_t *HWR_GetTexture(INT32 tex, boolean noencore) { GLTexture_t *grtex; #ifdef PARANOIA if ((unsigned)tex >= gr_numtextures) I_Error("HWR_GetTexture: tex >= numtextures\n"); #endif - grtex = &gr_textures[tex]; + grtex = &gr_textures[tex*2 + (encoremap && !noencore ? 0 : 1)]; if (!grtex->mipmap.grInfo.data && !grtex->mipmap.downloaded) - HWR_GenerateTexture(tex, grtex); + HWR_GenerateTexture(tex, grtex, noencore); HWD.pfnSetTexture(&grtex->mipmap); diff --git a/src/hardware/hw_glob.h b/src/hardware/hw_glob.h index 1950a10da..d2a532c4c 100644 --- a/src/hardware/hw_glob.h +++ b/src/hardware/hw_glob.h @@ -62,7 +62,7 @@ void HWR_FreeExtraSubsectors(void); void HWR_GetFlat(lumpnum_t flatlumpnum, boolean noencoremap); // ^ some flats must NOT be remapped to encore, since we remap them as we cache them for ease, adding a toggle here seems wise. -GLTexture_t *HWR_GetTexture(INT32 tex); +GLTexture_t *HWR_GetTexture(INT32 tex, boolean noencore); void HWR_GetPatch(GLPatch_t *gpatch); void HWR_GetMappedPatch(GLPatch_t *gpatch, const UINT8 *colormap); void HWR_MakePatch(patch_t *patch, GLPatch_t *grPatch, GLMipmap_t *grMipmap, boolean makebitmap); @@ -83,11 +83,11 @@ extern INT32 textureformat; // -------- // hw_main.c // originally hw_drawnodes.c from HWPortal branch // -------- -void HWR_AddTransparentWall(FOutVector *wallVerts, FSurfaceInfo *pSurf, INT32 texnum, FBITFIELD blend, boolean fogwall, INT32 lightlevel, extracolormap_t *wallcolormap); +void HWR_AddTransparentWall(FOutVector *wallVerts, FSurfaceInfo *pSurf, INT32 texnum, boolean noencore, FBITFIELD blend, boolean fogwall, INT32 lightlevel, extracolormap_t *wallcolormap); void HWR_AddTransparentFloor(lumpnum_t lumpnum, extrasubsector_t *xsub, boolean isceiling, fixed_t fixedheight, INT32 lightlevel, INT32 alpha, sector_t *FOFSector, FBITFIELD blend, boolean fogplane, extracolormap_t *planecolormap); void HWR_AddTransparentPolyobjectFloor(lumpnum_t lumpnum, polyobj_t *polysector, boolean isceiling, fixed_t fixedheight, INT32 lightlevel, INT32 alpha, sector_t *FOFSector, FBITFIELD blend, extracolormap_t *planecolormap); void HWR_RenderDrawNodes(void); -#endif //_HW_GLOB_ \ No newline at end of file +#endif //_HW_GLOB_ diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index bc5888b2e..c25f3541d 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -245,7 +245,7 @@ static line_t *gr_linedef; static sector_t *gr_frontsector; static sector_t *gr_backsector; -static void HWR_SplitWall(sector_t *sector, FOutVector *wallVerts, INT32 texnum, FSurfaceInfo* Surf, INT32 cutflag, ffloor_t *pfloor, FBITFIELD polyflags); +static void HWR_SplitWall(sector_t *sector, FOutVector *wallVerts, INT32 texnum, boolean noencore, FSurfaceInfo* Surf, INT32 cutflag, ffloor_t *pfloor, FBITFIELD polyflags); boolean gr_shadersavailable = true; @@ -1085,7 +1085,7 @@ void HWR_ProjectWall(FOutVector *wallVerts, FSurfaceInfo *pSurf, FBITFIELD blend // // SoM: split up and light walls according to the lightlist. // This may also include leaving out parts of the wall that can't be seen -static void HWR_SplitWall(sector_t *sector, FOutVector *wallVerts, INT32 texnum, FSurfaceInfo* Surf, INT32 cutflag, ffloor_t *pfloor, FBITFIELD polyflags) +static void HWR_SplitWall(sector_t *sector, FOutVector *wallVerts, INT32 texnum, boolean noencore, FSurfaceInfo* Surf, INT32 cutflag, ffloor_t *pfloor, FBITFIELD polyflags) { float realtop, realbot, top, bot; float pegt, pegb, pegmul; @@ -1316,16 +1316,16 @@ static void HWR_SplitWall(sector_t *sector, FOutVector *wallVerts, INT32 texnum, if (cv_fofzfightfix.value) { if (cutflag & FF_FOG) - HWR_AddTransparentWall(wallVerts, Surf, texnum, PF_Fog|PF_NoTexture|polyflags, true, lightnum, colormap); + HWR_AddTransparentWall(wallVerts, Surf, texnum, noencore, PF_Fog|PF_NoTexture|polyflags, true, lightnum, colormap); else if (cutflag & FF_TRANSLUCENT) - HWR_AddTransparentWall(wallVerts, Surf, texnum, PF_Translucent|polyflags, false, lightnum, colormap); + HWR_AddTransparentWall(wallVerts, Surf, texnum, noencore, PF_Translucent|polyflags, false, lightnum, colormap); else HWR_ProjectWall(wallVerts, Surf, PF_Masked|polyflags, lightnum, colormap); }else{ if (cutflag & FF_FOG) - HWR_AddTransparentWall(wallVerts, Surf, texnum, PF_Fog|PF_NoTexture, true, lightnum, colormap); + HWR_AddTransparentWall(wallVerts, Surf, texnum, noencore, PF_Fog|PF_NoTexture, true, lightnum, colormap); else if (cutflag & FF_TRANSLUCENT) - HWR_AddTransparentWall(wallVerts, Surf, texnum, PF_Translucent, false, lightnum, colormap); + HWR_AddTransparentWall(wallVerts, Surf, texnum, noencore, PF_Translucent, false, lightnum, colormap); else HWR_ProjectWall(wallVerts, Surf, PF_Masked, lightnum, colormap); } @@ -1370,16 +1370,16 @@ static void HWR_SplitWall(sector_t *sector, FOutVector *wallVerts, INT32 texnum, if (cv_fofzfightfix.value) { if (cutflag & FF_FOG) - HWR_AddTransparentWall(wallVerts, Surf, texnum, PF_Fog|PF_NoTexture|polyflags, true, lightnum, colormap); + HWR_AddTransparentWall(wallVerts, Surf, texnum, noencore, PF_Fog|PF_NoTexture|polyflags, true, lightnum, colormap); else if (cutflag & FF_TRANSLUCENT) - HWR_AddTransparentWall(wallVerts, Surf, texnum, PF_Translucent|polyflags, false, lightnum, colormap); + HWR_AddTransparentWall(wallVerts, Surf, texnum, noencore, PF_Translucent|polyflags, false, lightnum, colormap); else HWR_ProjectWall(wallVerts, Surf, PF_Masked|polyflags, lightnum, colormap); }else{ if (cutflag & FF_FOG) - HWR_AddTransparentWall(wallVerts, Surf, texnum, PF_Fog|PF_NoTexture, true, lightnum, colormap); + HWR_AddTransparentWall(wallVerts, Surf, texnum, noencore, PF_Fog|PF_NoTexture, true, lightnum, colormap); else if (cutflag & FF_TRANSLUCENT) - HWR_AddTransparentWall(wallVerts, Surf, texnum, PF_Translucent, false, lightnum, colormap); + HWR_AddTransparentWall(wallVerts, Surf, texnum, noencore, PF_Translucent, false, lightnum, colormap); else HWR_ProjectWall(wallVerts, Surf, PF_Masked, lightnum, colormap); } @@ -1712,7 +1712,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom { fixed_t texturevpegtop; // top - grTex = HWR_GetTexture(gr_toptexture); + grTex = HWR_GetTexture(gr_toptexture, gr_linedef->flags & ML_TFERLINE); // PEGGING if (gr_linedef->flags & ML_DONTPEGTOP) @@ -1775,9 +1775,9 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom #endif if (!gl_drawing_stencil && gr_frontsector->numlights) - HWR_SplitWall(gr_frontsector, wallVerts, gr_toptexture, &Surf, FF_CUTLEVEL, NULL, 0); + HWR_SplitWall(gr_frontsector, wallVerts, gr_toptexture, gr_linedef->flags & ML_TFERLINE, &Surf, FF_CUTLEVEL, NULL, 0); else if (!gl_drawing_stencil && grTex->mipmap.flags & TF_TRANSPARENT) - HWR_AddTransparentWall(wallVerts, &Surf, gr_toptexture, PF_Environment, false, lightnum, colormap); + HWR_AddTransparentWall(wallVerts, &Surf, gr_toptexture, gr_linedef->flags & ML_TFERLINE, PF_Environment, false, lightnum, colormap); else HWR_ProjectWall(wallVerts, &Surf, PF_Masked, lightnum, colormap); } @@ -1792,7 +1792,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom { fixed_t texturevpegbottom = 0; // bottom - grTex = HWR_GetTexture(gr_bottomtexture); + grTex = HWR_GetTexture(gr_bottomtexture, gr_linedef->flags & ML_TFERLINE); // PEGGING #ifdef ESLOPE @@ -1857,9 +1857,9 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom #endif if (!gl_drawing_stencil && gr_frontsector->numlights) - HWR_SplitWall(gr_frontsector, wallVerts, gr_bottomtexture, &Surf, FF_CUTLEVEL, NULL, 0); + HWR_SplitWall(gr_frontsector, wallVerts, gr_bottomtexture, gr_linedef->flags & ML_TFERLINE, &Surf, FF_CUTLEVEL, NULL, 0); else if (!gl_drawing_stencil && grTex->mipmap.flags & TF_TRANSPARENT) - HWR_AddTransparentWall(wallVerts, &Surf, gr_bottomtexture, PF_Environment, false, lightnum, colormap); + HWR_AddTransparentWall(wallVerts, &Surf, gr_bottomtexture, gr_linedef->flags & ML_TFERLINE, PF_Environment, false, lightnum, colormap); else HWR_ProjectWall(wallVerts, &Surf, PF_Masked, lightnum, colormap); } @@ -1999,15 +1999,15 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom l = max(polybottom, lowcut); hS = min(highcutslope, polytopslope); lS = max(polybottomslope, lowcutslope); - + // PEGGING fixed_t texturevpeg, texturevpegslope; - - grTex = HWR_GetTexture(gr_midtexture); - + + grTex = HWR_GetTexture(gr_midtexture, gr_linedef->flags & ML_TFERLINE); + if (cv_slopepegfix.value) - { - if (!!(gr_linedef->flags & ML_DONTPEGBOTTOM) ^ !!(gr_linedef->flags & ML_EFFECT3)) + { + if (!!(gr_linedef->flags & ML_DONTPEGBOTTOM) ^ !!(gr_linedef->flags & ML_EFFECT3)) { texturevpeg = midtexheight - h + polybottom; texturevpegslope = midtexheight - hS + polybottomslope; @@ -2017,7 +2017,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom texturevpeg = polytop - h; texturevpegslope = polytopslope - hS; } - + wallVerts[3].t = texturevpeg * grTex->scaleY; wallVerts[0].t = (h - l + texturevpeg) * grTex->scaleY; wallVerts[2].t = texturevpegslope * grTex->scaleY; @@ -2181,22 +2181,22 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom if (cv_fofzfightfix.value) { if (!(blendmode & PF_Masked)) - HWR_SplitWall(gr_frontsector, wallVerts, gr_midtexture, &Surf, FF_TRANSLUCENT, NULL, PF_Decal); + HWR_SplitWall(gr_frontsector, wallVerts, gr_midtexture, gr_linedef->flags & ML_TFERLINE, &Surf, FF_TRANSLUCENT, NULL, PF_Decal); else { - HWR_SplitWall(gr_frontsector, wallVerts, gr_midtexture, &Surf, FF_CUTLEVEL, NULL, PF_Decal); + HWR_SplitWall(gr_frontsector, wallVerts, gr_midtexture, gr_linedef->flags & ML_TFERLINE, &Surf, FF_CUTLEVEL, NULL, PF_Decal); } }else{ if (!(blendmode & PF_Masked)) - HWR_SplitWall(gr_frontsector, wallVerts, gr_midtexture, &Surf, FF_TRANSLUCENT, NULL, 0); + HWR_SplitWall(gr_frontsector, wallVerts, gr_midtexture, gr_linedef->flags & ML_TFERLINE, &Surf, FF_TRANSLUCENT, NULL, 0); else { - HWR_SplitWall(gr_frontsector, wallVerts, gr_midtexture, &Surf, FF_CUTLEVEL, NULL, 0); + HWR_SplitWall(gr_frontsector, wallVerts, gr_midtexture, gr_linedef->flags & ML_TFERLINE, &Surf, FF_CUTLEVEL, NULL, 0); } - } + } } else if (!gl_drawing_stencil && !(blendmode & PF_Masked)) - HWR_AddTransparentWall(wallVerts, &Surf, gr_midtexture, blendmode, false, lightnum, colormap); + HWR_AddTransparentWall(wallVerts, &Surf, gr_midtexture, gr_linedef->flags & ML_TFERLINE, blendmode, false, lightnum, colormap); else HWR_ProjectWall(wallVerts, &Surf, blendmode, lightnum, colormap); } @@ -2221,7 +2221,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom // top of texture at top texturevpeg = gr_sidedef->rowoffset; - grTex = HWR_GetTexture(gr_midtexture); + grTex = HWR_GetTexture(gr_midtexture, gr_linedef->flags & ML_TFERLINE); wallVerts[3].t = wallVerts[2].t = texturevpeg * grTex->scaleY; wallVerts[0].t = wallVerts[1].t = (texturevpeg + gr_frontsector->ceilingheight - gr_frontsector->floorheight) * grTex->scaleY; @@ -2257,12 +2257,12 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom #endif if (gr_frontsector->numlights) - HWR_SplitWall(gr_frontsector, wallVerts, gr_midtexture, &Surf, FF_CUTLEVEL, NULL, 0); + HWR_SplitWall(gr_frontsector, wallVerts, gr_midtexture, gr_linedef->flags & ML_TFERLINE, &Surf, FF_CUTLEVEL, NULL, 0); // I don't think that solid walls can use translucent linedef types... else { if (grTex->mipmap.flags & TF_TRANSPARENT) - HWR_AddTransparentWall(wallVerts, &Surf, gr_midtexture, PF_Environment, false, lightnum, colormap); + HWR_AddTransparentWall(wallVerts, &Surf, gr_midtexture, gr_linedef->flags & ML_TFERLINE, PF_Environment, false, lightnum, colormap); else HWR_ProjectWall(wallVerts, &Surf, PF_Masked, lightnum, colormap); } @@ -2328,6 +2328,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom fixed_t high1, highslope1, low1, lowslope1; INT32 texnum; + boolean noencore = false; line_t * newline = NULL; // Multi-Property FOF if (!cv_grfofcut.value) @@ -2369,12 +2370,14 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom texnum = R_GetTextureNum(sides[rover->master->sidenum[0]].midtexture); + noencore = false; if (rover->master->flags & ML_TFERLINE) { size_t linenum = min(gr_curline->linedef-gr_backsector->lines[0], rover->master->frontsector->linecount); newline = rover->master->frontsector->lines[0] + linenum; texnum = R_GetTextureNum(sides[newline->sidenum[0]].midtexture); + noencore = true; } #ifdef ESLOPE @@ -2463,7 +2466,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom #endif } - grTex = HWR_GetTexture(texnum); + grTex = HWR_GetTexture(texnum, noencore); #ifdef ESLOPE if (!slopeskew) // no skewing @@ -2519,9 +2522,9 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom Surf.PolyColor.s.alpha = HWR_FogBlockAlpha(rover->master->frontsector->lightlevel, rover->master->frontsector->extra_colormap); if (gr_frontsector->numlights) - HWR_SplitWall(gr_frontsector, wallVerts, 0, &Surf, rover->flags, rover, 0); + HWR_SplitWall(gr_frontsector, wallVerts, 0, false, &Surf, rover->flags, rover, 0); else - HWR_AddTransparentWall(wallVerts, &Surf, 0, blendmode, true, lightnum, colormap); + HWR_AddTransparentWall(wallVerts, &Surf, 0, false, blendmode, true, lightnum, colormap); } else { @@ -2534,11 +2537,11 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom } if (gr_frontsector->numlights) - HWR_SplitWall(gr_frontsector, wallVerts, texnum, &Surf, rover->flags, rover, 0); + HWR_SplitWall(gr_frontsector, wallVerts, texnum, noencore, &Surf, rover->flags, rover, 0); else { if (blendmode != PF_Masked) - HWR_AddTransparentWall(wallVerts, &Surf, texnum, blendmode, false, lightnum, colormap); + HWR_AddTransparentWall(wallVerts, &Surf, texnum, gr_linedef->flags & ML_TFERLINE, blendmode, false, lightnum, colormap); else HWR_ProjectWall(wallVerts, &Surf, PF_Masked, lightnum, colormap); } @@ -2569,12 +2572,14 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom texnum = R_GetTextureNum(sides[rover->master->sidenum[0]].midtexture); + noencore = false; if (rover->master->flags & ML_TFERLINE) { size_t linenum = min(gr_curline->linedef-gr_backsector->lines[0], rover->master->frontsector->linecount); newline = rover->master->frontsector->lines[0] + linenum; texnum = R_GetTextureNum(sides[newline->sidenum[0]].midtexture); + noencore = true; } #ifdef ESLOPE //backsides h = *rover->t_slope ? P_GetZAt(*rover->t_slope, v1x, v1y) : *rover->topheight; @@ -2634,7 +2639,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom } else { - grTex = HWR_GetTexture(texnum); + grTex = HWR_GetTexture(texnum, noencore); if (newline) { @@ -2670,9 +2675,9 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom Surf.PolyColor.s.alpha = HWR_FogBlockAlpha(rover->master->frontsector->lightlevel, rover->master->frontsector->extra_colormap); if (gr_backsector->numlights) - HWR_SplitWall(gr_backsector, wallVerts, 0, &Surf, rover->flags, rover, 0); + HWR_SplitWall(gr_backsector, wallVerts, 0, false, &Surf, rover->flags, rover, 0); else - HWR_AddTransparentWall(wallVerts, &Surf, 0, blendmode, true, lightnum, colormap); + HWR_AddTransparentWall(wallVerts, &Surf, 0, false, blendmode, true, lightnum, colormap); } else { @@ -2685,11 +2690,11 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom } if (gr_backsector->numlights) - HWR_SplitWall(gr_backsector, wallVerts, texnum, &Surf, rover->flags, rover, 0); + HWR_SplitWall(gr_backsector, wallVerts, texnum, noencore, &Surf, rover->flags, rover, 0); else { if (blendmode != PF_Masked) - HWR_AddTransparentWall(wallVerts, &Surf, texnum, blendmode, false, lightnum, colormap); + HWR_AddTransparentWall(wallVerts, &Surf, texnum, noencore, blendmode, false, lightnum, colormap); else HWR_ProjectWall(wallVerts, &Surf, PF_Masked, lightnum, colormap); } @@ -4833,6 +4838,7 @@ typedef struct FOutVector wallVerts[4]; FSurfaceInfo Surf; INT32 texnum; + boolean noencore; FBITFIELD blend; boolean fogwall; INT32 lightlevel; @@ -4921,13 +4927,14 @@ static void *HWR_CreateDrawNode(gr_drawnode_type_t type) return NULL; } -void HWR_AddTransparentWall(FOutVector *wallVerts, FSurfaceInfo *pSurf, INT32 texnum, FBITFIELD blend, boolean fogwall, INT32 lightlevel, extracolormap_t *wallcolormap) +void HWR_AddTransparentWall(FOutVector *wallVerts, FSurfaceInfo *pSurf, INT32 texnum, boolean noencore, FBITFIELD blend, boolean fogwall, INT32 lightlevel, extracolormap_t *wallcolormap) { wallinfo_t *wallinfo = HWR_CreateDrawNode(DRAWNODE_WALL); M_Memcpy(wallinfo->wallVerts, wallVerts, sizeof (wallinfo->wallVerts)); M_Memcpy(&wallinfo->Surf, pSurf, sizeof (FSurfaceInfo)); wallinfo->texnum = texnum; + wallinfo->noencore = noencore; wallinfo->blend = blend; wallinfo->fogwall = fogwall; wallinfo->lightlevel = lightlevel; @@ -5080,7 +5087,7 @@ void HWR_RenderDrawNodes(void) wallinfo_t *wall = &drawnode->u.wall; if (!(wall->blend & PF_NoTexture)) - HWR_GetTexture(wall->texnum); + HWR_GetTexture(wall->texnum, wall->noencore); HWR_RenderWall(wall->wallVerts, &wall->Surf, wall->blend, wall->fogwall, wall->lightlevel, wall->wallcolormap); } @@ -5797,7 +5804,7 @@ void HWR_DrawSkyBackground(float fpov) dometransform.roll = atransform.roll; dometransform.splitscreen = splitscreen; - HWR_GetTexture(texturetranslation[skytexture]); + HWR_GetTexture(texturetranslation[skytexture], false); HWD.pfnSetShader(7); // sky shader HWD.pfnRenderSkyDome(skytexture, textures[skytexture]->width, textures[skytexture]->height, dometransform); HWD.pfnSetShader(0); diff --git a/src/hardware/hw_main.h b/src/hardware/hw_main.h index 3dc18ccf8..195ff0e6f 100644 --- a/src/hardware/hw_main.h +++ b/src/hardware/hw_main.h @@ -132,7 +132,7 @@ void HWR_AddTransparentPolyobjectFloor(lumpnum_t lumpnum, polyobj_t *polysector, void HWR_ProcessSeg(void); // Sort of like GLWall::Process in GZDoom void HWR_RenderWall(FOutVector *wallVerts, FSurfaceInfo *pSurf, FBITFIELD blend, boolean fogwall, INT32 lightlevel, extracolormap_t *wallcolormap); void HWR_ProjectWall(FOutVector *wallVerts, FSurfaceInfo *pSurf, FBITFIELD blendmode, INT32 lightlevel, extracolormap_t *wallcolormap); -void HWR_AddTransparentWall(FOutVector *wallVerts, FSurfaceInfo * pSurf, INT32 texnum, FBITFIELD blend, boolean fogwall, INT32 lightlevel, extracolormap_t *wallcolormap); +void HWR_AddTransparentWall(FOutVector *wallVerts, FSurfaceInfo * pSurf, INT32 texnum, boolean noencore, FBITFIELD blend, boolean fogwall, INT32 lightlevel, extracolormap_t *wallcolormap); // moved HWR_SplitWall to hw_main.c void HWR_DrawSkyWall(FOutVector *wallVerts, FSurfaceInfo *Surf); void HWR_DrawSkyBackground(float fpov); -- 2.54.0 From 04ba08a8258d32862f1c15353a9c270b947e3ad9 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 27 Dec 2023 14:23:40 +0100 Subject: [PATCH 2/6] move noencore out of fof stuff idk if this is right lmao --- src/hardware/hw_main.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index c25f3541d..136def751 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -1492,6 +1492,8 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom FUINT lightnum = 0; // shut up compiler extracolormap_t *colormap; FSurfaceInfo Surf; + + boolean noencore = false; gr_sidedef = gr_curline->sidedef; gr_linedef = gr_curline->linedef; @@ -1575,6 +1577,8 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom { INT32 gr_toptexture, gr_bottomtexture; // two sided line + + noencore = false; #ifdef ESLOPE SLOPEPARAMS(gr_backsector->c_slope, worldhigh, worldhighslope, gr_backsector->ceilingheight) @@ -1584,6 +1588,9 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom worldlow = gr_backsector->floorheight; #endif + if (gr_linedef->flags & ML_TFERLINE) + noencore = true; + // Sky culling if (!gr_curline->polyseg) // Don't do it for polyobjects { @@ -2328,7 +2335,6 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom fixed_t high1, highslope1, low1, lowslope1; INT32 texnum; - boolean noencore = false; line_t * newline = NULL; // Multi-Property FOF if (!cv_grfofcut.value) @@ -2370,14 +2376,12 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom texnum = R_GetTextureNum(sides[rover->master->sidenum[0]].midtexture); - noencore = false; if (rover->master->flags & ML_TFERLINE) { size_t linenum = min(gr_curline->linedef-gr_backsector->lines[0], rover->master->frontsector->linecount); newline = rover->master->frontsector->lines[0] + linenum; texnum = R_GetTextureNum(sides[newline->sidenum[0]].midtexture); - noencore = true; } #ifdef ESLOPE @@ -2572,14 +2576,12 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom texnum = R_GetTextureNum(sides[rover->master->sidenum[0]].midtexture); - noencore = false; if (rover->master->flags & ML_TFERLINE) { size_t linenum = min(gr_curline->linedef-gr_backsector->lines[0], rover->master->frontsector->linecount); newline = rover->master->frontsector->lines[0] + linenum; texnum = R_GetTextureNum(sides[newline->sidenum[0]].midtexture); - noencore = true; } #ifdef ESLOPE //backsides h = *rover->t_slope ? P_GetZAt(*rover->t_slope, v1x, v1y) : *rover->topheight; -- 2.54.0 From 81a8fc3daa3afa35681a8f1d03aefd7b6cf68892 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 27 Dec 2023 15:02:57 +0100 Subject: [PATCH 3/6] move this out of gr_backsector --- src/hardware/hw_main.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 136def751..0d1b698d3 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -1569,7 +1569,10 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom lightnum = HWR_CalcWallLight(gr_frontsector->lightlevel, vs.x, vs.y, ve.x, ve.y); colormap = gr_frontsector->extra_colormap; } - + + if (gr_linedef->flags & ML_TFERLINE) + noencore = true; + if (gr_frontsector) Surf.PolyColor.s.alpha = 255; @@ -1577,8 +1580,6 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom { INT32 gr_toptexture, gr_bottomtexture; // two sided line - - noencore = false; #ifdef ESLOPE SLOPEPARAMS(gr_backsector->c_slope, worldhigh, worldhighslope, gr_backsector->ceilingheight) @@ -1588,9 +1589,6 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom worldlow = gr_backsector->floorheight; #endif - if (gr_linedef->flags & ML_TFERLINE) - noencore = true; - // Sky culling if (!gr_curline->polyseg) // Don't do it for polyobjects { -- 2.54.0 From 6748d5ad303782584bb4e65f53cf872baa8094b3 Mon Sep 17 00:00:00 2001 From: Indev Date: Wed, 27 Dec 2023 17:28:02 +0300 Subject: [PATCH 4/6] Remove unneeded condition for encore remap in opengl renderer (consistency with software renderer) --- src/hardware/hw_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 136def751..a2f59ab0c 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -5625,7 +5625,7 @@ void HWR_ProjectSprite(mobj_t *thing) { vis->colormap = colormaps; #ifdef GLENCORE - if (encoremap && (thing->flags & (MF_SCENERY|MF_NOTHINK)) && !(thing->flags & MF_DONTENCOREMAP)) + if (encoremap && !(thing->flags & MF_DONTENCOREMAP)) vis->colormap += (256*32); #endif } -- 2.54.0 From cd239b0f357a2d1003ac0d6186a28054ac870c61 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 22 Feb 2024 23:26:18 +0100 Subject: [PATCH 5/6] fix conflicts --- src/hardware/hw_cache.c | 22 +++++++--------------- src/hardware/hw_glob.h | 3 +-- src/hardware/hw_main.c | 1 - 3 files changed, 8 insertions(+), 18 deletions(-) diff --git a/src/hardware/hw_cache.c b/src/hardware/hw_cache.c index f4007b826..c32870fed 100644 --- a/src/hardware/hw_cache.c +++ b/src/hardware/hw_cache.c @@ -321,8 +321,7 @@ bpp = format2bpp(grMipmap->format); // Create a composite texture from patches, adapt the texture size to a power of 2 // height and width for the hardware texture cache. // -static void HWR_GenerateTexture(INT32 texnum, GLTexture_t *grtex, boolean noencore) -static void HWR_GenerateTexture(INT32 texnum, GLMapTexture_t *grtex) +static void HWR_GenerateTexture(INT32 texnum, GLMapTexture_t *grtex, boolean noencore) { UINT8 *block; texture_t *texture; @@ -560,11 +559,10 @@ void HWR_LoadTextures(size_t pnumtextures) // -------------------------------------------------------------------------- // Make sure texture is downloaded and set it as the source // -------------------------------------------------------------------------- -GLTexture_t *HWR_GetTexture(INT32 tex, boolean noencore) -GLMapTexture_t *HWR_GetTexture(INT32 tex) +GLMapTexture_t *HWR_GetTexture(INT32 tex, boolean noencore) { GLMapTexture_t *grtex; - + if (tex < 0 || tex >= (signed)gr_numtextures) { #ifdef PARANOIA @@ -572,20 +570,17 @@ GLMapTexture_t *HWR_GetTexture(INT32 tex) #else tex = 0; #endif - grtex = &gr_textures[tex*2 + (encoremap && !noencore ? 0 : 1)]; } + + grtex = &gr_textures[tex*2 + (encoremap && !noencore ? 0 : 1)]; - grtex = &gr_textures[tex]; - - if (!grtex->mipmap.grInfo.data && !grtex->mipmap.downloaded) - HWR_GenerateTexture(tex, grtex, noencore); if (!grtex->mipmap.data && !grtex->mipmap.downloaded) - HWR_GenerateTexture(tex, grtex); + HWR_GenerateTexture(tex, grtex, noencore); // If hardware does not have the texture, then call pfnSetTexture to upload it if (!grtex->mipmap.downloaded) HWD.pfnSetTexture(&grtex->mipmap); - + HWR_SetCurrentTexture(&grtex->mipmap); // The system-memory data can be purged now. @@ -594,7 +589,6 @@ GLMapTexture_t *HWR_GetTexture(INT32 tex) return grtex; } - static void HWR_CacheFlat(GLMipmap_t *grMipmap, lumpnum_t flatlumpnum) { #ifdef GLENCORE @@ -603,7 +597,6 @@ static void HWR_CacheFlat(GLMipmap_t *grMipmap, lumpnum_t flatlumpnum) #endif size_t size, pflatsize; - // setup the texture info grMipmap->format = GL_TEXFMT_P_8; grMipmap->flags = TF_WRAPXY|TF_CHROMAKEYED; @@ -649,7 +642,6 @@ static void HWR_CacheFlat(GLMipmap_t *grMipmap, lumpnum_t flatlumpnum) #endif } - // Download a Doom 'flat' to the hardware cache and make it ready for use void HWR_GetFlat(lumpnum_t flatlumpnum, boolean noencoremap) { diff --git a/src/hardware/hw_glob.h b/src/hardware/hw_glob.h index 60c3b1fae..742fd82ae 100644 --- a/src/hardware/hw_glob.h +++ b/src/hardware/hw_glob.h @@ -63,8 +63,7 @@ void HWR_FreeExtraSubsectors(void); void HWR_GetFlat(lumpnum_t flatlumpnum, boolean noencoremap); // ^ some flats must NOT be remapped to encore, since we remap them as we cache them for ease, adding a toggle here seems wise. -GLMapTexture_t *HWR_GetTexture(INT32 tex); -GLTexture_t *HWR_GetTexture(INT32 tex, boolean noencore); +GLMapTexture_t *HWR_GetTexture(INT32 tex, boolean noencore); void HWR_GetPatch(GLPatch_t *gpatch); void HWR_GetMappedPatch(GLPatch_t *gpatch, const UINT8 *colormap); void HWR_MakePatch(patch_t *patch, GLPatch_t *grPatch, GLMipmap_t *grMipmap, boolean makebitmap); diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index e83349fcf..8403c6565 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -5812,7 +5812,6 @@ void HWR_DrawSkyBackground(float fpov) dometransform.roll = atransform.roll; dometransform.splitscreen = splitscreen; - HWR_GetTexture(texturetranslation[skytexture]); if (HWR_UseShader()) HWD.pfnSetShader(HWR_GetShaderFromTarget(SHADER_SKY));// sky shader HWR_GetTexture(texturetranslation[skytexture], false); -- 2.54.0 From 0b1add2988dc7d1cb25ab508704063d98f0226eb Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 22 Feb 2024 23:27:26 +0100 Subject: [PATCH 6/6] one more --- src/hardware/hw_main.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 8403c6565..bb80441af 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -5812,10 +5812,9 @@ void HWR_DrawSkyBackground(float fpov) dometransform.roll = atransform.roll; dometransform.splitscreen = splitscreen; + HWR_GetTexture(texturetranslation[skytexture], false); if (HWR_UseShader()) HWD.pfnSetShader(HWR_GetShaderFromTarget(SHADER_SKY));// sky shader - HWR_GetTexture(texturetranslation[skytexture], false); - HWD.pfnSetShader(7); // sky shader HWD.pfnRenderSkyDome(skytexture, textures[skytexture]->width, textures[skytexture]->height, dometransform); } -- 2.54.0