From 5bbf173b4ec1563b7a93ea75ad1564d64907a130 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 4 May 2017 11:37:36 +0200 Subject: [PATCH 1/4] - fixed: SBARINFO based status bars got the wrong color for automap HUD highlights when playing Doom. --- wadsrc/static/zscript/statusbar/doom_sbar.txt | 6 ------ wadsrc/static/zscript/statusbar/statusbar.txt | 3 ++- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/wadsrc/static/zscript/statusbar/doom_sbar.txt b/wadsrc/static/zscript/statusbar/doom_sbar.txt index 00471540b..7eddf319e 100644 --- a/wadsrc/static/zscript/statusbar/doom_sbar.txt +++ b/wadsrc/static/zscript/statusbar/doom_sbar.txt @@ -20,12 +20,6 @@ class DoomStatusBar : BaseStatusBar diparms = InventoryBarState.Create(); } - override void DrawAutomapHUD(double ticFrac) - { - // This uses the normal automap HUD but just changes the highlight color. - DoDrawAutomapHUD(Font.CR_GREY, Font.CR_UNTRANSLATED); - } - override void Draw (int state, double TicFrac) { Super.Draw (state, TicFrac); diff --git a/wadsrc/static/zscript/statusbar/statusbar.txt b/wadsrc/static/zscript/statusbar/statusbar.txt index b1aa96f31..cc773e1a2 100644 --- a/wadsrc/static/zscript/statusbar/statusbar.txt +++ b/wadsrc/static/zscript/statusbar/statusbar.txt @@ -798,7 +798,8 @@ class BaseStatusBar native ui virtual void DrawAutomapHUD(double ticFrac) { - DoDrawAutomapHUD(Font.CR_GREY, Font.CR_YELLOW); + // game needs to be checked here, so that SBARINFO also gets the correct colors. + DoDrawAutomapHUD(Font.CR_GREY, gameinfo.gametype & GAME_DoomChex? Font.CR_UNTRANSLATED : Font.CR_YELLOW); } //--------------------------------------------------------------------------- From 7308979c4419dc8ec27368f8fa4f2fd03d1bfb7f Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 4 May 2017 22:53:14 +0200 Subject: [PATCH 2/4] - fixed bad state label in A_SerpentHeadCheck. --- wadsrc/static/zscript/hexen/serpent.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wadsrc/static/zscript/hexen/serpent.txt b/wadsrc/static/zscript/hexen/serpent.txt index eb26c8c7b..98ca6643f 100644 --- a/wadsrc/static/zscript/hexen/serpent.txt +++ b/wadsrc/static/zscript/hexen/serpent.txt @@ -373,7 +373,7 @@ class SerpentHead : Actor } else { - SetStateLabel ("NAME_Death"); + SetStateLabel ("Death"); } } } From 2dff0e7309904b5b4eebf38e370a22b8380797d2 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 4 May 2017 23:52:16 +0200 Subject: [PATCH 3/4] - fixed: P_TranslateLinedef should not do any byte swapping but require passing of properly ordered values. This gets called from several places, and the only one passing in potentially byte swapped values is P_LoadLineDefs. All other uses of this function were essentially broken on PowerPC. --- src/doomdata.h | 2 +- src/p_setup.cpp | 3 +++ src/p_xlat.cpp | 6 +++--- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/doomdata.h b/src/doomdata.h index e6cb728ec..5f681fa76 100644 --- a/src/doomdata.h +++ b/src/doomdata.h @@ -106,7 +106,7 @@ struct maplinedef_t uint16_t v1; uint16_t v2; uint16_t flags; - int16_t special; + uint16_t special; int16_t tag; uint16_t sidenum[2]; // sidenum[1] will be -1 if one sided diff --git a/src/p_setup.cpp b/src/p_setup.cpp index d19e65295..f89ad6704 100644 --- a/src/p_setup.cpp +++ b/src/p_setup.cpp @@ -2173,6 +2173,9 @@ void P_LoadLineDefs (MapData * map) // [RH] Translate old linedef special and flags to be // compatible with the new format. + mld->special = LittleShort(mld->special); + mld->tag = LittleShort(mld->tag); + mld->flags = LittleShort(mld->flags); P_TranslateLineDef (ld, mld, -1); // do not assign the tag for Extradata lines. if (ld->special != Static_Init || (ld->args[1] != Init_EDLine && ld->args[1] != Init_EDSector)) diff --git a/src/p_xlat.cpp b/src/p_xlat.cpp index 9ec582a92..4f3b45611 100644 --- a/src/p_xlat.cpp +++ b/src/p_xlat.cpp @@ -64,9 +64,9 @@ typedef enum void P_TranslateLineDef (line_t *ld, maplinedef_t *mld, int lineindexforid) { - unsigned short special = (unsigned short) LittleShort(mld->special); - short tag = LittleShort(mld->tag); - uint32_t flags = LittleShort(mld->flags); + uint32_t special = mld->special; + short tag = mld->tag; + uint32_t flags =mld->flags; INTBOOL passthrough = 0; uint32_t flags1 = flags; From 4fcea96a1ce75f5c9c2adc56ca031084b3d34ce6 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Fri, 5 May 2017 03:27:22 +0200 Subject: [PATCH 4/4] - Improve softpoly sky rendering a little bit --- src/polyrenderer/drawers/poly_triangle.cpp | 3 +- src/polyrenderer/scene/poly_sky.cpp | 158 ++++++++++++++++++--- src/polyrenderer/scene/poly_sky.h | 22 +++ 3 files changed, 166 insertions(+), 17 deletions(-) diff --git a/src/polyrenderer/drawers/poly_triangle.cpp b/src/polyrenderer/drawers/poly_triangle.cpp index 84dd13897..19628cf47 100644 --- a/src/polyrenderer/drawers/poly_triangle.cpp +++ b/src/polyrenderer/drawers/poly_triangle.cpp @@ -209,7 +209,8 @@ void PolyTriangleDrawer::draw_shaded_triangle(const ShadedTriVertex *vert, bool #endif // Keep varyings in -128 to 128 range if possible - if (numclipvert > 0) + // But don't do this for the skycap mode since the V texture coordinate is used for blending + if (numclipvert > 0 && args->uniforms->BlendMode() != TriBlendMode::Skycap) { float newOriginU = floorf(clippedvert[0].u * 0.1f) * 10.0f; float newOriginV = floorf(clippedvert[0].v * 0.1f) * 10.0f; diff --git a/src/polyrenderer/scene/poly_sky.cpp b/src/polyrenderer/scene/poly_sky.cpp index 7cb322032..2f4bc5f8c 100644 --- a/src/polyrenderer/scene/poly_sky.cpp +++ b/src/polyrenderer/scene/poly_sky.cpp @@ -37,17 +37,41 @@ PolySkyDome::PolySkyDome() void PolySkyDome::Render(const TriMatrix &worldToClip) { - FTextureID sky1tex, sky2tex; - if ((level.flags & LEVEL_SWAPSKIES) && !(level.flags & LEVEL_DOUBLESKY)) - sky1tex = sky2texture; - else - sky1tex = sky1texture; - sky2tex = sky2texture; + PolySkySetup frameSetup; + frameSetup.Update(); - FTexture *frontskytex = TexMan(sky1tex, true); - FTexture *backskytex = nullptr; - if (level.flags & LEVEL_DOUBLESKY) - backskytex = TexMan(sky2tex, true); + if (frameSetup != mCurrentSetup) + { + double frontTexWidth = (double)frameSetup.frontskytex->GetWidth(); + float scaleFrontU = (float)(frameSetup.frontcyl / frontTexWidth); + if (frameSetup.skyflip) + scaleFrontU = -scaleFrontU; + + float baseOffset = (float)(frameSetup.skyangle / 65536.0 / frontTexWidth); + float offsetFrontU = baseOffset * scaleFrontU + (float)(frameSetup.frontpos / 65536.0 / frontTexWidth); + + float scaleFrontV = (float)(frameSetup.frontskytex->Scale.Y * 1.6); + float offsetFrontV; + + // BTSX + /*{ + offsetFrontU += 0.5f; + offsetFrontV = (float)((28.0f - frameSetup.skymid) / frameSetup.frontskytex->GetHeight()); + }*/ + // E1M1 + { + offsetFrontV = (float)((28.0f + frameSetup.skymid) / frameSetup.frontskytex->GetHeight()); + } + + unsigned int count = mVertices.Size(); + for (unsigned int i = 0; i < count; i++) + { + mVertices[i].u = offsetFrontU + mInitialUV[i].X * scaleFrontU; + mVertices[i].v = offsetFrontV + mInitialUV[i].Y * scaleFrontV; + } + + mCurrentSetup = frameSetup; + } const auto &viewpoint = PolyRenderer::Instance()->Viewpoint; TriMatrix objectToWorld = TriMatrix::translate((float)viewpoint.Pos.X, (float)viewpoint.Pos.Y, (float)viewpoint.Pos.Z); @@ -63,13 +87,13 @@ void PolySkyDome::Render(const TriMatrix &worldToClip) args.SetWriteStencil(true, 1); args.SetClipPlane(PolyClipPlane(0.0f, 0.0f, 0.0f, 1.0f)); - RenderCapColorRow(args, frontskytex, 0, false); - RenderCapColorRow(args, frontskytex, rc, true); + RenderCapColorRow(args, mCurrentSetup.frontskytex, 0, false); + RenderCapColorRow(args, mCurrentSetup.frontskytex, rc, true); - args.SetTexture(frontskytex); + args.SetTexture(mCurrentSetup.frontskytex); - uint32_t topcapcolor = frontskytex->GetSkyCapColor(false); - uint32_t bottomcapcolor = frontskytex->GetSkyCapColor(true); + uint32_t topcapcolor = mCurrentSetup.frontskytex->GetSkyCapColor(false); + uint32_t bottomcapcolor = mCurrentSetup.frontskytex->GetSkyCapColor(true); uint8_t topcapindex = RGB256k.All[((RPART(topcapcolor) >> 2) << 12) | ((GPART(topcapcolor) >> 2) << 6) | (BPART(topcapcolor) >> 2)]; uint8_t bottomcapindex = RGB256k.All[((RPART(bottomcapcolor) >> 2) << 12) | ((GPART(bottomcapcolor) >> 2) << 6) | (BPART(bottomcapcolor) >> 2)]; @@ -174,6 +198,108 @@ void PolySkyDome::SkyVertex(int r, int c, bool zflip) // And finally the vertex. TriVertex vert; - vert = SetVertexXYZ(-pos.X, z - 1.f, pos.Y, u * 4.0f, v * 1.2f - 0.5f); + vert = SetVertexXYZ(-pos.X, z - 1.f, pos.Y, u, v - 0.5f); mVertices.Push(vert); + mInitialUV.Push({ vert.u, vert.v }); +} + +///////////////////////////////////////////////////////////////////////////// + +void PolySkySetup::Update() +{ + FTextureID sky1tex, sky2tex; + double frontdpos = 0, backdpos = 0; + + if ((level.flags & LEVEL_SWAPSKIES) && !(level.flags & LEVEL_DOUBLESKY)) + { + sky1tex = sky2texture; + } + else + { + sky1tex = sky1texture; + } + sky2tex = sky2texture; + skymid = skytexturemid; + skyangle = 0; + + int sectorSky = 0;// sector->sky; + + if (!(sectorSky & PL_SKYFLAT)) + { // use sky1 + sky1: + frontskytex = TexMan(sky1tex, true); + if (level.flags & LEVEL_DOUBLESKY) + backskytex = TexMan(sky2tex, true); + else + backskytex = nullptr; + skyflip = false; + frontdpos = sky1pos; + backdpos = sky2pos; + frontcyl = sky1cyl; + backcyl = sky2cyl; + } + else if (sectorSky == PL_SKYFLAT) + { // use sky2 + frontskytex = TexMan(sky2tex, true); + backskytex = nullptr; + frontcyl = sky2cyl; + skyflip = false; + frontdpos = sky2pos; + } + else + { // MBF's linedef-controlled skies + // Sky Linedef + const line_t *l = &level.lines[(sectorSky & ~PL_SKYFLAT) - 1]; + + // Sky transferred from first sidedef + const side_t *s = l->sidedef[0]; + int pos; + + // Texture comes from upper texture of reference sidedef + // [RH] If swapping skies, then use the lower sidedef + if (level.flags & LEVEL_SWAPSKIES && s->GetTexture(side_t::bottom).isValid()) + { + pos = side_t::bottom; + } + else + { + pos = side_t::top; + } + + frontskytex = TexMan(s->GetTexture(pos), true); + if (frontskytex == nullptr || frontskytex->UseType == FTexture::TEX_Null) + { // [RH] The blank texture: Use normal sky instead. + goto sky1; + } + backskytex = nullptr; + + // Horizontal offset is turned into an angle offset, + // to allow sky rotation as well as careful positioning. + // However, the offset is scaled very small, so that it + // allows a long-period of sky rotation. + skyangle += FLOAT2FIXED(s->GetTextureXOffset(pos)); + + // Vertical offset allows careful sky positioning. + skymid = s->GetTextureYOffset(pos); + + // We sometimes flip the picture horizontally. + // + // Doom always flipped the picture, so we make it optional, + // to make it easier to use the new feature, while to still + // allow old sky textures to be used. + skyflip = l->args[2] ? false : true; + + int frontxscale = int(frontskytex->Scale.X * 1024); + frontcyl = MAX(frontskytex->GetWidth(), frontxscale); + if (skystretch) + { + skymid = skymid * frontskytex->GetScaledHeightDouble() / SKYSTRETCH_HEIGHT; + } + } + + frontpos = int(fmod(frontdpos, sky1cyl * 65536.0)); + if (backskytex != nullptr) + { + backpos = int(fmod(backdpos, sky2cyl * 65536.0)); + } } diff --git a/src/polyrenderer/scene/poly_sky.h b/src/polyrenderer/scene/poly_sky.h index 87d6cabce..bf8f7e202 100644 --- a/src/polyrenderer/scene/poly_sky.h +++ b/src/polyrenderer/scene/poly_sky.h @@ -23,6 +23,25 @@ #include "polyrenderer/drawers/poly_triangle.h" +class PolySkySetup +{ +public: + void Update(); + + bool operator==(const PolySkySetup &that) const { return memcmp(this, &that, sizeof(PolySkySetup)) == 0; } + bool operator!=(const PolySkySetup &that) const { return memcmp(this, &that, sizeof(PolySkySetup)) != 0; } + + FTexture *frontskytex = nullptr; + FTexture *backskytex = nullptr; + bool skyflip = 0; + int frontpos = 0; + int backpos = 0; + fixed_t frontcyl = 0; + fixed_t backcyl = 0; + double skymid = 0.0; + angle_t skyangle = 0; +}; + class PolySkyDome { public: @@ -30,6 +49,7 @@ public: void Render(const TriMatrix &worldToClip); private: + TArray mInitialUV; TArray mVertices; TArray mPrimStart; int mRows, mColumns; @@ -42,4 +62,6 @@ private: void RenderCapColorRow(PolyDrawArgs &args, FTexture *skytex, int row, bool bottomCap); TriVertex SetVertexXYZ(float xx, float yy, float zz, float uu = 0, float vv = 0); + + PolySkySetup mCurrentSetup; };