diff --git a/specs/udmf_zdoom.txt b/specs/udmf_zdoom.txt index 8cb110321d..62a50e4883 100644 --- a/specs/udmf_zdoom.txt +++ b/specs/udmf_zdoom.txt @@ -201,9 +201,12 @@ Note: All fields default to false unless mentioned otherwise. uppercolor_bottom = ; // Material color of the top of the lower tier. lowercolor_bottom = ; // Material color of the bottom of the lower tier. (Hardware rendering only.) - coloradd_top = ; // Additive material color to apply to top section of sidedef. Takes precedence over sector setting. Default is black (0x000000) - coloradd_mid = ; // Additive material color to apply to middle section of sidedef. Takes precedence over sector setting. Default is black (0x000000) - coloradd_bottom = ; // Additive material color to apply to bottom section of sidedef. Takes precedence over sector setting. Default is black (0x000000) + useowncoloradd_top = ; // Whether or not to use the given additive color for the top section of the sidedef. + coloradd_top = ; // Additive material color to apply to top section of sidedef. Default is black (0x000000) + useowncoloradd_mid = ; // Whether or not to use the given additive color for the middle section of the sidedef. + coloradd_mid = ; // Additive material color to apply to middle section of sidedef. Default is black (0x000000) + useowncoloradd_bottom = ; // Whether or not to use the given additive color for the bottom section of the sidedef. + coloradd_bottom = ; // Additive material color to apply to bottom section of sidedef. Default is black (0x000000) } sector diff --git a/src/namedef.h b/src/namedef.h index 57207eed99..a0d395f888 100644 --- a/src/namedef.h +++ b/src/namedef.h @@ -659,8 +659,11 @@ xx(clampgradient_bottom) xx(useowncolors_bottom) xx(uppercolor_bottom) xx(lowercolor_bottom) +xx(useowncoloradd_top) xx(coloradd_top) +xx(useowncoloradd_mid) xx(coloradd_mid) +xx(useowncoloradd_bottom) xx(coloradd_bottom) xx(Renderstyle) diff --git a/src/p_udmf.cpp b/src/p_udmf.cpp index e2d3ebdffa..603b1cc13a 100644 --- a/src/p_udmf.cpp +++ b/src/p_udmf.cpp @@ -1329,7 +1329,7 @@ public: break; case NAME_useowncolors_top: - Flag(sd->textures[side_t::top].flags, side_t::part::UseOwnColors, key); + Flag(sd->textures[side_t::top].flags, side_t::part::UseOwnSpecialColors, key); break; case NAME_uppercolor_top: @@ -1353,7 +1353,7 @@ public: break; case NAME_useowncolors_mid: - Flag(sd->textures[side_t::mid].flags, side_t::part::UseOwnColors, key); + Flag(sd->textures[side_t::mid].flags, side_t::part::UseOwnSpecialColors, key); break; case NAME_uppercolor_mid: @@ -1377,7 +1377,7 @@ public: break; case NAME_useowncolors_bottom: - Flag(sd->textures[side_t::bottom].flags, side_t::part::UseOwnColors, key); + Flag(sd->textures[side_t::bottom].flags, side_t::part::UseOwnSpecialColors, key); break; case NAME_uppercolor_bottom: @@ -1400,6 +1400,14 @@ public: sd->SetAdditiveColor(side_t::bottom, CheckInt(key)); break; + case NAME_useowncoloradd_top: + sd->textures[side_t::top].flags |= side_t::part::UseOwnAdditiveColor * CheckBool(key); + + case NAME_useowncoloradd_mid: + sd->textures[side_t::mid].flags |= side_t::part::UseOwnAdditiveColor * CheckBool(key); + + case NAME_useowncoloradd_bottom: + sd->textures[side_t::bottom].flags |= side_t::part::UseOwnAdditiveColor * CheckBool(key); default: break; diff --git a/src/r_defs.h b/src/r_defs.h index c93a240fbc..587caa73cc 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -1150,7 +1150,8 @@ struct side_t NoGradient = 1, FlipGradient = 2, ClampGradient = 4, - UseOwnColors = 8, + UseOwnSpecialColors = 8, + UseOwnAdditiveColor = 16, }; double xOffset; double yOffset; @@ -1301,22 +1302,37 @@ struct side_t auto &part = textures[which]; if (part.flags & part::NoGradient) slot = 0; if (part.flags & part::FlipGradient) slot ^= 1; - return (part.flags & part::UseOwnColors) ? part.SpecialColors[slot] : frontsector->SpecialColors[sector_t::walltop + slot]; + return (part.flags & part::UseOwnSpecialColors) ? part.SpecialColors[slot] : frontsector->SpecialColors[sector_t::walltop + slot]; } - void SetAdditiveColor(int which, PalEntry rgb, bool use = true) + void EnableAdditiveColor(int which, bool enable) { - rgb.a = use ? 255 : 0; + int flag = enable ? part::UseOwnAdditiveColor : 0; + if (enable) + { + textures[which].flags |= flag; + } + else + { + textures[which].flags &= (~flag); + } + } + + void SetAdditiveColor(int which, PalEntry rgb) + { + rgb.a = 255; textures[which].AdditiveColor = rgb; } PalEntry GetAdditiveColor(int which, sector_t *frontsector) const { - auto &color = textures[which].AdditiveColor; - if (color.a == 0) { + if (textures[which].flags & part::UseOwnAdditiveColor) { + return textures[which].AdditiveColor; + } + else + { return frontsector->AdditiveColors[sector_t::walltop]; // Used as additive color for all walls } - return color; } DInterpolation *SetInterpolation(int position); diff --git a/src/scripting/vmthunks.cpp b/src/scripting/vmthunks.cpp index 7181375b7a..9d529d29d1 100644 --- a/src/scripting/vmthunks.cpp +++ b/src/scripting/vmthunks.cpp @@ -1558,11 +1558,11 @@ DEFINE_ACTION_FUNCTION_NATIVE(_Sector, RemoveForceField, RemoveForceField) return 0; } - static void SetSideAdditiveColor(side_t *self, int tier, int color, bool use) + static void SetSideAdditiveColor(side_t *self, int tier, int color) { if (tier >= 0 && tier < 3) { - self->SetAdditiveColor(tier, color, use); + self->SetAdditiveColor(tier, color); } } @@ -1571,8 +1571,24 @@ DEFINE_ACTION_FUNCTION_NATIVE(_Sector, RemoveForceField, RemoveForceField) PARAM_SELF_STRUCT_PROLOGUE(side_t); PARAM_INT(tier); PARAM_COLOR(color); - PARAM_BOOL(use); - SetSideAdditiveColor(self, tier, color, use); + SetSideAdditiveColor(self, tier, color); + return 0; + } + + static void EnableSideAdditiveColor(side_t *self, int tier, bool enable) + { + if (tier >= 0 && tier < 3) + { + self->EnableAdditiveColor(tier, enable); + } + } + + DEFINE_ACTION_FUNCTION_NATIVE(_Side, EnableAdditiveColor, EnableSideAdditiveColor) + { + PARAM_SELF_STRUCT_PROLOGUE(side_t); + PARAM_INT(tier); + PARAM_BOOL(enable); + EnableSideAdditiveColor(self, tier, enable); return 0; } diff --git a/wadsrc/static/zscript/mapdata.txt b/wadsrc/static/zscript/mapdata.txt index 155888581c..53a6b4bad7 100644 --- a/wadsrc/static/zscript/mapdata.txt +++ b/wadsrc/static/zscript/mapdata.txt @@ -87,7 +87,8 @@ struct Side native play native void MultiplyTextureYScale(int which, double delta); native void SetSpecialColor(int tier, int position, Color scolor); native Color GetAdditiveColor(int tier); - native void SetAdditiveColor(int tier, Color color, bool use = true); + native void SetAdditiveColor(int tier, Color color); + native void EnableAdditiveColor(int tier, bool enable); //native DInterpolation *SetInterpolation(int position); //native void StopInterpolation(int position);