From 7e901055ea30b5e2d9fa33c2bc8142be89503f38 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Wed, 12 Jun 2019 09:49:40 +0300 Subject: [PATCH] - fixed: light mode from mapinfo had no effect https://forum.zdoom.org/viewtopic.php?t=64997 --- src/rendering/hwrenderer/data/hw_viewpointbuffer.cpp | 2 +- src/rendering/hwrenderer/scene/hw_drawinfo.cpp | 7 ++++--- src/rendering/hwrenderer/scene/hw_viewpointuniforms.h | 4 +++- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/rendering/hwrenderer/data/hw_viewpointbuffer.cpp b/src/rendering/hwrenderer/data/hw_viewpointbuffer.cpp index 576b4c576..268bd4902 100644 --- a/src/rendering/hwrenderer/data/hw_viewpointbuffer.cpp +++ b/src/rendering/hwrenderer/data/hw_viewpointbuffer.cpp @@ -78,7 +78,7 @@ void HWViewpointBuffer::Set2D(FRenderState &di, int width, int height) if (width != m2DWidth || height != m2DHeight) { HWViewpointUniforms matrices; - matrices.SetDefaults(); + matrices.SetDefaults(nullptr); matrices.mProjectionMatrix.ortho(0, (float)width, (float)height, 0, -1.0f, 1.0f); matrices.CalcDependencies(); mBuffer->Map(); diff --git a/src/rendering/hwrenderer/scene/hw_drawinfo.cpp b/src/rendering/hwrenderer/scene/hw_drawinfo.cpp index 63dc1234e..db74848b2 100644 --- a/src/rendering/hwrenderer/scene/hw_drawinfo.cpp +++ b/src/rendering/hwrenderer/scene/hw_drawinfo.cpp @@ -135,7 +135,7 @@ void HWDrawInfo::StartScene(FRenderViewpoint &parentvp, HWViewpointUniforms *uni VPUniforms.mClipLine.X = -1000001.f; VPUniforms.mClipHeight = 0; } - else VPUniforms.SetDefaults(); + else VPUniforms.SetDefaults(this); mClipper->SetViewpoint(Viewpoint); ClearBuffers(); @@ -387,14 +387,15 @@ HWPortal * HWDrawInfo::FindPortal(const void * src) // //----------------------------------------------------------------------------- -void HWViewpointUniforms::SetDefaults() +void HWViewpointUniforms::SetDefaults(HWDrawInfo *drawInfo) { mProjectionMatrix.loadIdentity(); mViewMatrix.loadIdentity(); mNormalViewMatrix.loadIdentity(); mViewHeight = viewheight; mGlobVis = (float)R_GetGlobVis(r_viewwindow, r_visibility) / 32.f; - mPalLightLevels = static_cast(gl_bandedswlight) | (static_cast(gl_fogmode) << 8) | (static_cast(gl_lightmode) << 16); + const int lightMode = drawInfo == nullptr ? static_cast(*gl_lightmode) : static_cast(drawInfo->lightmode); + mPalLightLevels = static_cast(gl_bandedswlight) | (static_cast(gl_fogmode) << 8) | (lightMode << 16); mClipLine.X = -10000000.0f; mShadowmapFilter = gl_shadowmap_filter; diff --git a/src/rendering/hwrenderer/scene/hw_viewpointuniforms.h b/src/rendering/hwrenderer/scene/hw_viewpointuniforms.h index 1bd57faa0..8752c76aa 100644 --- a/src/rendering/hwrenderer/scene/hw_viewpointuniforms.h +++ b/src/rendering/hwrenderer/scene/hw_viewpointuniforms.h @@ -3,6 +3,8 @@ #include "r_data/matrix.h" #include "r_utility.h" +struct HWDrawInfo; + struct HWViewpointUniforms { VSMatrix mProjectionMatrix; @@ -23,7 +25,7 @@ struct HWViewpointUniforms mNormalViewMatrix.computeNormalMatrix(mViewMatrix); } - void SetDefaults(); + void SetDefaults(HWDrawInfo *drawInfo); };