diff --git a/source/build/src/engine.cpp b/source/build/src/engine.cpp index 4b9aba8e2..e5c033a55 100644 --- a/source/build/src/engine.cpp +++ b/source/build/src/engine.cpp @@ -3075,8 +3075,19 @@ void twod_rotatesprite(int32_t sx, int32_t sy, int32_t z, int16_t a, int16_t pic auto ptr = &twod->mVertices[dg.mVertIndex]; float drawpoly_alpha = daalpha * (1.0f / 255.0f); float alpha = GetAlphaFromBlend(method, dablend) * (1.f - drawpoly_alpha); // Hmmm... - int light = clamp(scale((numshades - dashade), 255, numshades), 0, 255); - auto p = PalEntry((uint8_t)(alpha * 255), light, light, light); + PalEntry p; + + if (!hw_useindexedcolortextures) + { + int light = clamp(scale((numshades - dashade), 255, numshades), 0, 255); + p = PalEntry((uint8_t)(alpha * 255), light, light, light); + } + else + { + p = PalEntry((uint8_t)(alpha * 255), 255, 255, 255); + dg.mLightLevel = clamp(dashade, 0, numshades); + } + vec2_t const siz = { (int)dg.mTexture->GetDisplayWidth(), (int)dg.mTexture->GetDisplayHeight() }; vec2_16_t ofs = { 0, 0 }; diff --git a/source/common/2d/v_2ddrawer.cpp b/source/common/2d/v_2ddrawer.cpp index b397cc88d..6553d3187 100644 --- a/source/common/2d/v_2ddrawer.cpp +++ b/source/common/2d/v_2ddrawer.cpp @@ -408,7 +408,7 @@ void F2DDrawer::AddTexture(FGameTexture* img, DrawParms& parms) double u1, v1, u2, v2; PalEntry vertexcolor; - RenderCommand dg; + RenderCommand dg = {}; dg.mType = DrawTypeTriangles; dg.mVertCount = 4; @@ -487,7 +487,7 @@ void F2DDrawer::AddShape(FGameTexture* img, DShape2D* shape, DrawParms& parms) PalEntry vertexcolor; - RenderCommand dg; + RenderCommand dg = {}; dg.mType = DrawTypeTriangles; dg.mVertCount = shape->mVertices.Size(); @@ -560,7 +560,7 @@ void F2DDrawer::AddPoly(FGameTexture *texture, FVector2 *points, int npoints, DAngle rotation, const FColormap &colormap, PalEntry flatcolor, double fadelevel, uint32_t *indices, size_t indexcount) { - RenderCommand poly; + RenderCommand poly = {}; poly.mType = DrawTypeTriangles; poly.mTexture = texture; @@ -698,7 +698,7 @@ void F2DDrawer::AddFlatFill(int left, int top, int right, int bottom, FGameTextu { float fU1, fU2, fV1, fV2; - RenderCommand dg; + RenderCommand dg = {}; dg.mType = DrawTypeTriangles; dg.mRenderStyle = DefaultRenderStyle(); @@ -817,7 +817,7 @@ void F2DDrawer::AddFlatFill(int left, int top, int right, int bottom, FGameTextu void F2DDrawer::AddColorOnlyQuad(int x1, int y1, int w, int h, PalEntry color, FRenderStyle *style, bool prepend) { - RenderCommand dg; + RenderCommand dg = {}; dg.mType = DrawTypeTriangles; dg.mVertCount = 4; @@ -856,7 +856,7 @@ void F2DDrawer::AddLine(double x1, double y1, double x2, double y2, int clipx1, PalEntry p = (PalEntry)color; p.a = alpha; - RenderCommand dg; + RenderCommand dg = {}; if (clipx1 > 0 || clipy1 > 0 || clipx2 < GetWidth()- 1 || clipy2 < GetHeight() - 1) { @@ -900,7 +900,7 @@ void F2DDrawer::AddThickLine(int x1, int y1, int x2, int y2, double thickness, u DVector2 corner2 = point1 + perp; DVector2 corner3 = point1 - perp; - RenderCommand dg; + RenderCommand dg = {}; dg.mType = DrawTypeTriangles; dg.mVertCount = 4; @@ -928,7 +928,7 @@ void F2DDrawer::AddPixel(int x1, int y1, uint32_t color) PalEntry p = (PalEntry)color; p.a = 255; - RenderCommand dg; + RenderCommand dg = {}; dg.mType = DrawTypePoints; dg.mRenderStyle = LegacyRenderStyles[STYLE_Translucent]; diff --git a/source/common/2d/v_2ddrawer.h b/source/common/2d/v_2ddrawer.h index bd8797d4c..f3e0577f2 100644 --- a/source/common/2d/v_2ddrawer.h +++ b/source/common/2d/v_2ddrawer.h @@ -129,9 +129,10 @@ public: PalEntry mSpecialColormap[2]; int mScissor[4]; int mDesaturate; - FRenderStyle mRenderStyle; + FRenderStyle mRenderStyle; PalEntry mColor1; // Overlay color ETexMode mDrawMode; + uint8_t mLightLevel; uint8_t mFlags; RenderCommand() @@ -152,6 +153,7 @@ public: mRenderStyle == other.mRenderStyle && mDrawMode == other.mDrawMode && mFlags == other.mFlags && + mLightLevel == other.mLightLevel && mColor1.d == other.mColor1.d; } diff --git a/source/common/rendering/hwrenderer/data/hw_viewpointbuffer.cpp b/source/common/rendering/hwrenderer/data/hw_viewpointbuffer.cpp index d11284228..a265e7d11 100644 --- a/source/common/rendering/hwrenderer/data/hw_viewpointbuffer.cpp +++ b/source/common/rendering/hwrenderer/data/hw_viewpointbuffer.cpp @@ -73,7 +73,7 @@ int HWViewpointBuffer::Bind(FRenderState &di, unsigned int index) return index; } -void HWViewpointBuffer::Set2D(FRenderState &di, int width, int height) +void HWViewpointBuffer::Set2D(FRenderState &di, int width, int height, int pll) { if (width != m2DWidth || height != m2DHeight) { @@ -83,7 +83,7 @@ void HWViewpointBuffer::Set2D(FRenderState &di, int width, int height) matrices.mNormalViewMatrix.loadIdentity(); matrices.mViewHeight = 0; matrices.mGlobVis = 1.f; - matrices.mPalLightLevels = 0; + matrices.mPalLightLevels = pll; matrices.mClipLine.X = -10000000.0f; matrices.mShadowmapFilter = gl_shadowmap_filter; diff --git a/source/common/rendering/hwrenderer/data/hw_viewpointbuffer.h b/source/common/rendering/hwrenderer/data/hw_viewpointbuffer.h index 01389e01a..42c096704 100644 --- a/source/common/rendering/hwrenderer/data/hw_viewpointbuffer.h +++ b/source/common/rendering/hwrenderer/data/hw_viewpointbuffer.h @@ -28,7 +28,7 @@ public: ~HWViewpointBuffer(); void Clear(); int Bind(FRenderState &di, unsigned int index); - void Set2D(FRenderState &di, int width, int height); + void Set2D(FRenderState &di, int width, int height, int pll = 0); int SetViewpoint(FRenderState &di, HWViewpointUniforms *vp); unsigned int GetBlockSize() const { return mBlockSize; } }; diff --git a/source/glbackend/hw_draw2d.cpp b/source/glbackend/hw_draw2d.cpp index 16e2faad7..6faf489e0 100644 --- a/source/glbackend/hw_draw2d.cpp +++ b/source/glbackend/hw_draw2d.cpp @@ -105,7 +105,7 @@ void polymost_dorotatesprite(int32_t sx, int32_t sy, int32_t z, int16_t a, int16 void GLInstance::Draw2D(F2DDrawer *drawer) { VSMatrix mat(0); - screen->mViewpoints->Set2D(OpenGLRenderer::gl_RenderState, xdim, ydim); + screen->mViewpoints->Set2D(OpenGLRenderer::gl_RenderState, xdim, ydim, numshades); SetViewport(0, 0, xdim, ydim); EnableDepthTest(false); EnableMultisampling(false); @@ -167,8 +167,8 @@ void GLInstance::Draw2D(F2DDrawer *drawer) { auto tex = cmd.mTexture; - SetFadeDisable(true); - SetShade(0, numshades); + SetFadeDisable(cmd.mLightLevel == 0); + SetShade(cmd.mLightLevel, numshades); SetTexture(TileFiles.GetTileIndex(tex), tex, cmd.mTranslationId, cmd.mFlags & F2DDrawer::DTF_Wrap ? CLAMP_NONE : CLAMP_XY); EnableBlend(!(cmd.mRenderStyle.Flags & STYLEF_Alpha1)); diff --git a/wadsrc/static/engine/shaders/glsl/polymost.fp b/wadsrc/static/engine/shaders/glsl/polymost.fp index 6407d91cd..ab126a1c4 100644 --- a/wadsrc/static/engine/shaders/glsl/polymost.fp +++ b/wadsrc/static/engine/shaders/glsl/polymost.fp @@ -197,7 +197,8 @@ void main() } palettedColor.a = color.r == 0.0? 0.0 : 1.0;// 1.0-floor(color.r); - color = palettedColor; + color.rgb = palettedColor.rgb * v_color.rgb; + color.a = palettedColor.a; } else {