From 9406e6d2adc4a8a70e28fd4167ca6f0bac33a7ce Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 18 Mar 2021 23:22:51 +0100 Subject: [PATCH] - fixed the biggest issues with flat rendering --- source/core/rendering/scene/hw_flats.cpp | 10 ++++------ source/core/rendering/scene/hw_walls.cpp | 11 ----------- 2 files changed, 4 insertions(+), 17 deletions(-) diff --git a/source/core/rendering/scene/hw_flats.cpp b/source/core/rendering/scene/hw_flats.cpp index 833207eaf..dbff3368e 100644 --- a/source/core/rendering/scene/hw_flats.cpp +++ b/source/core/rendering/scene/hw_flats.cpp @@ -194,7 +194,7 @@ void HWFlat::MakeVertices() auto vp = ret.first; for (auto i : indices) { - auto& pt = points[indices[i]]; + auto& pt = points[i]; vp->SetVertex(pt.X, pt.Z, pt.Y); vp->SetTexCoord(pt.X / 64.f, pt.Y / 64.f); // todo: align vp++; @@ -253,15 +253,13 @@ void HWFlat::DrawFlat(HWDrawInfo *di, FRenderState &state, bool translucent) if (!texture->GetTranslucency()) state.AlphaFunc(Alpha_GEqual, gl_mask_threshold); else state.AlphaFunc(Alpha_GEqual, 0.f); } - state.SetMaterial(texture, UF_Texture, 0, CLAMP_NONE, 0, -1); + state.SetMaterial(texture, UF_Texture, 0, 0/*flags & 3*/, TRANSLATION(Translation_Remap + curbasepal, palette), -1); state.SetLightIndex(dynlightindex); state.Draw(DT_Triangles, vertindex, vertcount); vertexcount += vertcount; - state.EnableTextureMatrix(false); - - state.SetRenderStyle(DefaultRenderStyle()); + if (translucent) state.SetRenderStyle(DefaultRenderStyle()); //state.SetObjectColor(0xffffffff); //state.SetAddColor(0); //state.ApplyTextureManipulation(nullptr); @@ -314,7 +312,7 @@ void HWFlat::ProcessSector(HWDrawInfo *di, sectortype * frontsector, int which) const auto &vp = di->Viewpoint; float florz, ceilz; - PlanesAtPoint(frontsector, vp.Pos.X, vp.Pos.Y, &ceilz, &florz); + PlanesAtPoint(frontsector, vp.Pos.X * 16.f, vp.Pos.Y * -16.f, &ceilz, &florz); fade = lookups.getFade(frontsector->floorpal); // fog is per sector. visibility = sectorVisibility(frontsector); diff --git a/source/core/rendering/scene/hw_walls.cpp b/source/core/rendering/scene/hw_walls.cpp index eb5837a33..43acaf884 100644 --- a/source/core/rendering/scene/hw_walls.cpp +++ b/source/core/rendering/scene/hw_walls.cpp @@ -176,17 +176,6 @@ void HWWall::RenderTexturedWall(HWDrawInfo *di, FRenderState &state, int rflags) state.SetMaterial(texture, UF_Texture, 0, 0/*flags & 3*/, TRANSLATION(Translation_Remap + curbasepal, palette), -1); - int32_t size = xs_CRoundToInt(texture->GetDisplayHeight()); - int32_t size2; - for (size2 = 1; size2 < size; size2 += size2) {} - if (size == size2) - state.SetNpotEmulation(0.f, 0.f); - else - { - float xOffset = 1.f / texture->GetDisplayWidth(); - state.SetNpotEmulation((1.f * size2) / size, xOffset); - } - float absalpha = fabsf(alpha); // Fog must be done before the texture so that the texture selector can override it.