diff --git a/src/common/rendering/gl/gl_framebuffer.h b/src/common/rendering/gl/gl_framebuffer.h index de10ac052..8f8a139b6 100644 --- a/src/common/rendering/gl/gl_framebuffer.h +++ b/src/common/rendering/gl/gl_framebuffer.h @@ -58,7 +58,7 @@ public: void Swap(); bool IsHWGammaActive() const { return HWGammaActive; } - void SetVSync(bool vsync); + void SetVSync(bool vsync) override; void Draw2D() override; void PostProcessScene(bool swscene, int fixedcm, float flash, const std::function &afterBloomDrawEndScene2D) override; diff --git a/src/common/rendering/gl/gl_renderstate.cpp b/src/common/rendering/gl/gl_renderstate.cpp index 5628ca0a5..64e8cc4d1 100644 --- a/src/common/rendering/gl/gl_renderstate.cpp +++ b/src/common/rendering/gl/gl_renderstate.cpp @@ -329,12 +329,24 @@ void FGLRenderState::ApplyMaterial(FMaterial *mat, int clampmode, int translatio if (base->BindOrCreate(tex->GetTexture(), 0, clampmode, translation, layer->scaleFlags)) { - for (int i = 1; iscaleFlags & CTF_Indexed)) { - auto systex = static_cast(mat->GetLayer(i, 0, &layer)); - // fixme: Upscale flags must be disabled for certain layers. - systex->BindOrCreate(layer->layerTexture, i, clampmode, 0, layer->scaleFlags); - maxbound = i; + for (int i = 1; i < numLayers; i++) + { + auto systex = static_cast(mat->GetLayer(i, 0, &layer)); + // fixme: Upscale flags must be disabled for certain layers. + systex->BindOrCreate(layer->layerTexture, i, clampmode, 0, layer->scaleFlags); + maxbound = i; + } + } + else + { + for (int i = 1; i < 3; i++) + { + auto systex = static_cast(mat->GetLayer(i, translation, &layer)); + systex->Bind(i, false); + maxbound = i; + } } } // unbind everything from the last texture that's still active diff --git a/src/common/rendering/hwrenderer/data/buffers.h b/src/common/rendering/hwrenderer/data/buffers.h index 51110c72c..8ef57174e 100644 --- a/src/common/rendering/hwrenderer/data/buffers.h +++ b/src/common/rendering/hwrenderer/data/buffers.h @@ -56,7 +56,7 @@ public: virtual void Resize(size_t newsize) = 0; virtual void Map() {} // Only needed by old OpenGL but this needs to be in the interface. virtual void Unmap() {} - void *Memory() { assert(map); return map; } + void *Memory() { return map; } size_t Size() { return buffersize; } }; diff --git a/src/common/rendering/hwrenderer/data/hw_renderstate.h b/src/common/rendering/hwrenderer/data/hw_renderstate.h index 1a628e107..c52ef83ab 100644 --- a/src/common/rendering/hwrenderer/data/hw_renderstate.h +++ b/src/common/rendering/hwrenderer/data/hw_renderstate.h @@ -4,6 +4,7 @@ #include "matrix.h" #include "hw_material.h" #include "texmanip.h" +#include "version.h" struct FColormap; class IVertexBuffer; @@ -290,7 +291,7 @@ public: mStreamData.uGradientBottomPlane = { 0.0f, 0.0f, 0.0f, 0.0f }; mStreamData.uSplitTopPlane = { 0.0f, 0.0f, 0.0f, 0.0f }; mStreamData.uSplitBottomPlane = { 0.0f, 0.0f, 0.0f, 0.0f }; - mStreamData.uDynLightColor = { 0.0f, 0.0f, 0.0f, 0.0f }; + mStreamData.uDynLightColor = { 0.0f, 0.0f, 0.0f, 1.0f }; mStreamData.uDetailParms = { 0.0f, 0.0f, 0.0f, 0.0f }; #ifdef NPOT_EMULATION mStreamData.uNpotEmulation = { 0,0 }; @@ -459,7 +460,15 @@ public: void SetDynLight(float r, float g, float b) { - mStreamData.uDynLightColor = { r, g, b, 0.0f }; + mStreamData.uDynLightColor.X = r; + mStreamData.uDynLightColor.Y = g; + mStreamData.uDynLightColor.Z = b; + } + + void SetScreenFade(float f) + { + // This component is otherwise unused. + mStreamData.uDynLightColor.W = f; } void SetObjectColor(PalEntry pe) @@ -569,7 +578,7 @@ public: mMaterial.mChanged = true; mTextureModeFlags = mat->GetLayerFlags(); auto scale = mat->GetDetailScale(); - mStreamData.uDetailParms = { scale.X, scale.Y, 0, 0 }; + mStreamData.uDetailParms = { scale.X, scale.Y, 2, 0 }; } void SetMaterial(FGameTexture* tex, EUpscaleFlags upscalemask, int scaleflags, int clampmode, int translation, int overrideshader) diff --git a/src/common/rendering/hwrenderer/data/hw_shaderpatcher.cpp b/src/common/rendering/hwrenderer/data/hw_shaderpatcher.cpp index 0362306d3..fb3b8a535 100644 --- a/src/common/rendering/hwrenderer/data/hw_shaderpatcher.cpp +++ b/src/common/rendering/hwrenderer/data/hw_shaderpatcher.cpp @@ -277,7 +277,7 @@ const FDefaultShader defaultshaders[] = {"Warp 2", "shaders/glsl/func_warp2.fp", "shaders/glsl/material_normal.fp", ""}, {"Specular", "shaders/glsl/func_spec.fp", "shaders/glsl/material_specular.fp", "#define SPECULAR\n#define NORMALMAP\n"}, {"PBR","shaders/glsl/func_pbr.fp", "shaders/glsl/material_pbr.fp", "#define PBR\n#define NORMALMAP\n"}, - {"Paletted", "shaders/glsl/func_paletted.fp", "shaders/glsl/material_nolight.fp", ""}, + {"Paletted", "shaders/glsl/func_paletted.fp", "shaders/glsl/material_nolight.fp", "#define PALETTE_EMULATION\n"}, {"No Texture", "shaders/glsl/func_notexture.fp", "shaders/glsl/material_normal.fp", "#define NO_LAYERS\n"}, {"Basic Fuzz", "shaders/glsl/fuzz_standard.fp", "shaders/glsl/material_normal.fp", ""}, {"Smooth Fuzz", "shaders/glsl/fuzz_smooth.fp", "shaders/glsl/material_normal.fp", ""}, diff --git a/src/common/rendering/hwrenderer/hw_draw2d.cpp b/src/common/rendering/hwrenderer/hw_draw2d.cpp index 1d5c47773..5652777c2 100644 --- a/src/common/rendering/hwrenderer/hw_draw2d.cpp +++ b/src/common/rendering/hwrenderer/hw_draw2d.cpp @@ -130,6 +130,7 @@ void Draw2D(F2DDrawer *drawer, FRenderState &state) vb.UploadData(&vertices[0], vertices.Size(), &indices[0], indices.Size()); state.SetVertexBuffer(&vb); state.EnableFog(false); + state.SetScreenFade(drawer->screenFade); for(auto &cmd : commands) { @@ -168,13 +169,17 @@ void Draw2D(F2DDrawer *drawer, FRenderState &state) } state.SetFog(cmd.mColor1, 0); state.SetColor(1, 1, 1, 1, cmd.mDesaturate); + state.SetSoftLightLevel(cmd.mLightLevel); + state.SetLightParms(0, 0); state.AlphaFunc(Alpha_GEqual, 0.f); if (cmd.mTexture != nullptr && cmd.mTexture->isValid()) { auto flags = cmd.mTexture->GetUseType() >= ETextureType::Special? UF_None : cmd.mTexture->GetUseType() == ETextureType::FontChar? UF_Font : UF_Texture; - state.SetMaterial(cmd.mTexture, flags, 0, cmd.mFlags & F2DDrawer::DTF_Wrap ? CLAMP_NONE : CLAMP_XY_NOMIP, cmd.mTranslationId, -1); + + auto scaleflags = cmd.mFlags & F2DDrawer::DTF_Indexed ? CTF_Indexed : 0; + state.SetMaterial(cmd.mTexture, flags, scaleflags, cmd.mFlags & F2DDrawer::DTF_Wrap ? CLAMP_NONE : CLAMP_XY_NOMIP, cmd.mTranslationId, -1); state.EnableTexture(true); // Canvas textures are stored upside down @@ -226,6 +231,7 @@ void Draw2D(F2DDrawer *drawer, FRenderState &state) state.EnableBrightmap(true); state.SetTextureMode(TM_NORMAL); state.EnableFog(false); + state.SetScreenFade(1); state.ResetColor(); drawer->mIsFirstPass = false; twoD.Unclock();