From d593294304ffc798e24c1a2708653bbd029b446f Mon Sep 17 00:00:00 2001 From: codeimp <codeimp@e0d998f2-2e9b-42fe-843d-47128df60a06> Date: Sun, 12 Jul 2009 09:58:05 +0000 Subject: [PATCH] Simulate Doom brightness levels in Classic modes as well (now optional in game configs) --- Build/Configurations/Boom.cfg | 3 +++ Build/Configurations/Doom.cfg | 3 +++ Build/Configurations/Doom2.cfg | 3 +++ Build/Configurations/Edge.cfg | 3 +++ Build/Configurations/Eternity_Doom.cfg | 3 +++ Build/Configurations/Eternity_DoomUDMF.cfg | 3 +++ Build/Configurations/Heretic.cfg | 3 +++ Build/Configurations/Hexen.cfg | 3 +++ Build/Configurations/Legacy.cfg | 3 +++ Build/Configurations/Risen3D.cfg | 3 +++ Build/Configurations/Skulltag_Doom.cfg | 3 +++ Build/Configurations/Skulltag_DoomHexen.cfg | 3 +++ Build/Configurations/Strife.cfg | 3 +++ Build/Configurations/UltDoom.cfg | 3 +++ Build/Configurations/ZDoom_Doom.cfg | 3 +++ Build/Configurations/ZDoom_DoomHexen.cfg | 3 +++ Build/Configurations/ZDoom_DoomUDMF.cfg | 3 +++ Build/Configurations/ZDoom_HereticHexen.cfg | 3 +++ Build/Configurations/ZDoom_Hexen.cfg | 3 +++ Build/Configurations/ZDoom_StrifeHexen.cfg | 3 +++ Build/Configurations/jDoom.cfg | 3 +++ Source/Core/Config/GameConfiguration.cs | 3 +++ Source/Core/Map/Sector.cs | 8 ++------ Source/Core/Rendering/IRenderer2D.cs | 3 ++- Source/Core/Rendering/IRenderer3D.cs | 1 + Source/Core/Rendering/Renderer.cs | 14 ++++++++++++++ .../BuilderModes/VisualModes/BaseVisualMode.cs | 8 ++------ .../BuilderModes/VisualModes/VisualCeiling.cs | 2 +- .../BuilderModes/VisualModes/VisualFloor.cs | 2 +- .../BuilderModes/VisualModes/VisualLower.cs | 2 +- .../BuilderModes/VisualModes/VisualMiddleDouble.cs | 2 +- .../BuilderModes/VisualModes/VisualMiddleSingle.cs | 2 +- .../BuilderModes/VisualModes/VisualUpper.cs | 2 +- 33 files changed, 93 insertions(+), 19 deletions(-) diff --git a/Build/Configurations/Boom.cfg b/Build/Configurations/Boom.cfg index 49fbc420..ef79006d 100644 --- a/Build/Configurations/Boom.cfg +++ b/Build/Configurations/Boom.cfg @@ -34,6 +34,9 @@ skills 5 = "Nightmare!"; } +// Simulate Doom brightness levels (turn this off for linear lighting) +doomlightlevels = true; + // When this is set to true, sectors with the same tag will light up when a line is highlighted linetagindicatesectors = true; diff --git a/Build/Configurations/Doom.cfg b/Build/Configurations/Doom.cfg index b23ae2fe..c5d93c29 100644 --- a/Build/Configurations/Doom.cfg +++ b/Build/Configurations/Doom.cfg @@ -35,6 +35,9 @@ skills 5 = "Nightmare!"; } +// Simulate Doom brightness levels (turn this off for linear lighting) +doomlightlevels = true; + // When this is set to true, sectors with the same tag will light up when a line is highlighted linetagindicatesectors = true; diff --git a/Build/Configurations/Doom2.cfg b/Build/Configurations/Doom2.cfg index 65df17ec..38eab75d 100644 --- a/Build/Configurations/Doom2.cfg +++ b/Build/Configurations/Doom2.cfg @@ -35,6 +35,9 @@ skills 5 = "Nightmare!"; } +// Simulate Doom brightness levels (turn this off for linear lighting) +doomlightlevels = true; + // When this is set to true, sectors with the same tag will light up when a line is highlighted linetagindicatesectors = true; diff --git a/Build/Configurations/Edge.cfg b/Build/Configurations/Edge.cfg index fe1594c4..2e720e8d 100644 --- a/Build/Configurations/Edge.cfg +++ b/Build/Configurations/Edge.cfg @@ -34,6 +34,9 @@ skills 5 = "Nightmare!"; } +// Simulate Doom brightness levels (turn this off for linear lighting) +doomlightlevels = true; + // When this is set to true, sectors with the same tag will light up when a line is highlighted linetagindicatesectors = true; diff --git a/Build/Configurations/Eternity_Doom.cfg b/Build/Configurations/Eternity_Doom.cfg index f7454cd6..393a6d16 100644 --- a/Build/Configurations/Eternity_Doom.cfg +++ b/Build/Configurations/Eternity_Doom.cfg @@ -34,6 +34,9 @@ skills 5 = "Nightmare!"; } +// Simulate Doom brightness levels (turn this off for linear lighting) +doomlightlevels = true; + // When this is set to true, sectors with the same tag will light up when a line is highlighted linetagindicatesectors = true; diff --git a/Build/Configurations/Eternity_DoomUDMF.cfg b/Build/Configurations/Eternity_DoomUDMF.cfg index 61620252..881012ad 100644 --- a/Build/Configurations/Eternity_DoomUDMF.cfg +++ b/Build/Configurations/Eternity_DoomUDMF.cfg @@ -34,6 +34,9 @@ skills 5 = "Nightmare!"; } +// Simulate Doom brightness levels (turn this off for linear lighting) +doomlightlevels = true; + // When this is set to true, sectors with the same tag will light up when a line is highlighted linetagindicatesectors = true; diff --git a/Build/Configurations/Heretic.cfg b/Build/Configurations/Heretic.cfg index 56b5dd1f..bf0edb94 100644 --- a/Build/Configurations/Heretic.cfg +++ b/Build/Configurations/Heretic.cfg @@ -35,6 +35,9 @@ skills 5 = "Black plague possesses thee"; } +// Simulate Doom brightness levels (turn this off for linear lighting) +doomlightlevels = true; + // When this is set to true, sectors with the same tag will light up when a line is highlighted linetagindicatesectors = true; diff --git a/Build/Configurations/Hexen.cfg b/Build/Configurations/Hexen.cfg index 49491a83..3e041be6 100644 --- a/Build/Configurations/Hexen.cfg +++ b/Build/Configurations/Hexen.cfg @@ -35,6 +35,9 @@ skills 5 = "Titan / Pope / Archimage"; } +// Simulate Doom brightness levels (turn this off for linear lighting) +doomlightlevels = true; + // When this is set to true, sectors with the same tag will light up when a line is highlighted linetagindicatesectors = false; diff --git a/Build/Configurations/Legacy.cfg b/Build/Configurations/Legacy.cfg index a70f72c4..a8b3e41e 100644 --- a/Build/Configurations/Legacy.cfg +++ b/Build/Configurations/Legacy.cfg @@ -34,6 +34,9 @@ skills 5 = "Nightmare!"; } +// Simulate Doom brightness levels (turn this off for linear lighting) +doomlightlevels = true; + // When this is set to true, sectors with the same tag will light up when a line is highlighted linetagindicatesectors = true; diff --git a/Build/Configurations/Risen3D.cfg b/Build/Configurations/Risen3D.cfg index 2ab766da..a857774d 100644 --- a/Build/Configurations/Risen3D.cfg +++ b/Build/Configurations/Risen3D.cfg @@ -34,6 +34,9 @@ skills 5 = "Nightmare!"; } +// Simulate Doom brightness levels (turn this off for linear lighting) +doomlightlevels = true; + // When this is set to true, sectors with the same tag will light up when a line is highlighted linetagindicatesectors = true; diff --git a/Build/Configurations/Skulltag_Doom.cfg b/Build/Configurations/Skulltag_Doom.cfg index aae210c3..ecf13125 100644 --- a/Build/Configurations/Skulltag_Doom.cfg +++ b/Build/Configurations/Skulltag_Doom.cfg @@ -37,6 +37,9 @@ skills 5 = "Nightmare!"; } +// Simulate Doom brightness levels (turn this off for linear lighting) +doomlightlevels = true; + // When this is set to true, sectors with the same tag will light up when a line is highlighted linetagindicatesectors = true; diff --git a/Build/Configurations/Skulltag_DoomHexen.cfg b/Build/Configurations/Skulltag_DoomHexen.cfg index 235d37ae..81441efd 100644 --- a/Build/Configurations/Skulltag_DoomHexen.cfg +++ b/Build/Configurations/Skulltag_DoomHexen.cfg @@ -37,6 +37,9 @@ skills 5 = "Nightmare!"; } +// Simulate Doom brightness levels (turn this off for linear lighting) +doomlightlevels = true; + // When this is set to true, sectors with the same tag will light up when a line is highlighted linetagindicatesectors = false; diff --git a/Build/Configurations/Strife.cfg b/Build/Configurations/Strife.cfg index 6dd68a52..85e8a03a 100644 --- a/Build/Configurations/Strife.cfg +++ b/Build/Configurations/Strife.cfg @@ -35,6 +35,9 @@ skills 5 = "Bloodbath"; } +// Simulate Doom brightness levels (turn this off for linear lighting) +doomlightlevels = true; + // When this is set to true, sectors with the same tag will light up when a line is highlighted linetagindicatesectors = true; diff --git a/Build/Configurations/UltDoom.cfg b/Build/Configurations/UltDoom.cfg index 22ffe0b1..3f4e3884 100644 --- a/Build/Configurations/UltDoom.cfg +++ b/Build/Configurations/UltDoom.cfg @@ -35,6 +35,9 @@ skills 5 = "Nightmare!"; } +// Simulate Doom brightness levels (turn this off for linear lighting) +doomlightlevels = true; + // When this is set to true, sectors with the same tag will light up when a line is highlighted linetagindicatesectors = true; diff --git a/Build/Configurations/ZDoom_Doom.cfg b/Build/Configurations/ZDoom_Doom.cfg index 21f493c9..7720bec7 100644 --- a/Build/Configurations/ZDoom_Doom.cfg +++ b/Build/Configurations/ZDoom_Doom.cfg @@ -37,6 +37,9 @@ skills 5 = "Nightmare!"; } +// Simulate Doom brightness levels (turn this off for linear lighting) +doomlightlevels = true; + // When this is set to true, sectors with the same tag will light up when a line is highlighted linetagindicatesectors = true; diff --git a/Build/Configurations/ZDoom_DoomHexen.cfg b/Build/Configurations/ZDoom_DoomHexen.cfg index ad14d8b6..538b6181 100644 --- a/Build/Configurations/ZDoom_DoomHexen.cfg +++ b/Build/Configurations/ZDoom_DoomHexen.cfg @@ -37,6 +37,9 @@ skills 5 = "Nightmare!"; } +// Simulate Doom brightness levels (turn this off for linear lighting) +doomlightlevels = true; + // When this is set to true, sectors with the same tag will light up when a line is highlighted linetagindicatesectors = false; diff --git a/Build/Configurations/ZDoom_DoomUDMF.cfg b/Build/Configurations/ZDoom_DoomUDMF.cfg index 38ab698d..2d5f9b31 100644 --- a/Build/Configurations/ZDoom_DoomUDMF.cfg +++ b/Build/Configurations/ZDoom_DoomUDMF.cfg @@ -37,6 +37,9 @@ skills 5 = "Nightmare!"; } +// Simulate Doom brightness levels (turn this off for linear lighting) +doomlightlevels = true; + // When this is set to true, sectors with the same tag will light up when a line is highlighted linetagindicatesectors = false; diff --git a/Build/Configurations/ZDoom_HereticHexen.cfg b/Build/Configurations/ZDoom_HereticHexen.cfg index 7c80a127..69966010 100644 --- a/Build/Configurations/ZDoom_HereticHexen.cfg +++ b/Build/Configurations/ZDoom_HereticHexen.cfg @@ -37,6 +37,9 @@ skills 5 = "Black plague possesses thee"; } +// Simulate Doom brightness levels (turn this off for linear lighting) +doomlightlevels = true; + // When this is set to true, sectors with the same tag will light up when a line is highlighted linetagindicatesectors = false; diff --git a/Build/Configurations/ZDoom_Hexen.cfg b/Build/Configurations/ZDoom_Hexen.cfg index 74658efa..374983ba 100644 --- a/Build/Configurations/ZDoom_Hexen.cfg +++ b/Build/Configurations/ZDoom_Hexen.cfg @@ -37,6 +37,9 @@ skills 5 = "Titan / Pope / Archimage"; } +// Simulate Doom brightness levels (turn this off for linear lighting) +doomlightlevels = true; + // When this is set to true, sectors with the same tag will light up when a line is highlighted linetagindicatesectors = false; diff --git a/Build/Configurations/ZDoom_StrifeHexen.cfg b/Build/Configurations/ZDoom_StrifeHexen.cfg index 4414e63d..c0c5efb2 100644 --- a/Build/Configurations/ZDoom_StrifeHexen.cfg +++ b/Build/Configurations/ZDoom_StrifeHexen.cfg @@ -37,6 +37,9 @@ skills 5 = "Bloodbath"; } +// Simulate Doom brightness levels (turn this off for linear lighting) +doomlightlevels = true; + // When this is set to true, sectors with the same tag will light up when a line is highlighted linetagindicatesectors = false; diff --git a/Build/Configurations/jDoom.cfg b/Build/Configurations/jDoom.cfg index 32cff62a..a47fcc24 100644 --- a/Build/Configurations/jDoom.cfg +++ b/Build/Configurations/jDoom.cfg @@ -34,6 +34,9 @@ skills 5 = "Nightmare!"; } +// Simulate Doom brightness levels (turn this off for linear lighting) +doomlightlevels = true; + // When this is set to true, sectors with the same tag will light up when a line is highlighted linetagindicatesectors = true; diff --git a/Source/Core/Config/GameConfiguration.cs b/Source/Core/Config/GameConfiguration.cs index 5538439a..dbb9c6c3 100644 --- a/Source/Core/Config/GameConfiguration.cs +++ b/Source/Core/Config/GameConfiguration.cs @@ -72,6 +72,7 @@ namespace CodeImp.DoomBuilder.Config private string decorategames; private string skyflatname; private int maxtexturenamelength; + private bool doomlightlevels; // Skills private List<SkillInfo> skills; @@ -155,6 +156,7 @@ namespace CodeImp.DoomBuilder.Config public string DecorateGames { get { return decorategames; } } public string SkyFlatName { get { return skyflatname; } } public int MaxTextureNamelength { get { return maxtexturenamelength; } } + public bool DoomLightLevels { get { return doomlightlevels; } } // Skills public List<SkillInfo> Skills { get { return skills; } } @@ -259,6 +261,7 @@ namespace CodeImp.DoomBuilder.Config decorategames = cfg.ReadSetting("decorategames", ""); skyflatname = cfg.ReadSetting("skyflatname", "F_SKY1"); maxtexturenamelength = cfg.ReadSetting("maxtexturenamelength", 8); + doomlightlevels = cfg.ReadSetting("doomlightlevels", true); for(int i = 0; i < Linedef.NUM_ARGS; i++) makedoorargs[i] = cfg.ReadSetting("makedoorarg" + i.ToString(CultureInfo.InvariantCulture), 0); // Flags have special (invariant culture) conversion diff --git a/Source/Core/Map/Sector.cs b/Source/Core/Map/Sector.cs index 4761b2d4..af9b79e8 100644 --- a/Source/Core/Map/Sector.cs +++ b/Source/Core/Map/Sector.cs @@ -284,12 +284,8 @@ namespace CodeImp.DoomBuilder.Map { if(updateneeded) { - // Brightness color (alpha is opaque) - byte clampedbright = 0; - if((brightness >= 0) && (brightness <= 255)) clampedbright = (byte)brightness; - else if(brightness > 255) clampedbright = 255; - PixelColor brightcolor = new PixelColor(255, clampedbright, clampedbright, clampedbright); - int brightint = brightcolor.ToInt(); + // Brightness color + int brightint = General.Map.Renderer2D.CalculateBrightness(brightness); // Make vertices flatvertices = new FlatVertex[triangles.Vertices.Count]; diff --git a/Source/Core/Rendering/IRenderer2D.cs b/Source/Core/Rendering/IRenderer2D.cs index 13501e43..2785eeae 100644 --- a/Source/Core/Rendering/IRenderer2D.cs +++ b/Source/Core/Rendering/IRenderer2D.cs @@ -53,7 +53,8 @@ namespace CodeImp.DoomBuilder.Rendering PixelColor DetermineLinedefColor(Linedef l); PixelColor DetermineThingColor(Thing t); int DetermineVertexColor(Vertex v); - + int CalculateBrightness(int level); + // Rendering management methods bool StartPlotter(bool clear); bool StartThings(bool clear); diff --git a/Source/Core/Rendering/IRenderer3D.cs b/Source/Core/Rendering/IRenderer3D.cs index 56cc12c2..f28a90f9 100644 --- a/Source/Core/Rendering/IRenderer3D.cs +++ b/Source/Core/Rendering/IRenderer3D.cs @@ -58,6 +58,7 @@ namespace CodeImp.DoomBuilder.Rendering void FinishGeometry(); // Rendering methods + int CalculateBrightness(int level); void SetHighlightedObject(IVisualPickable obj); void AddSectorGeometry(VisualGeometry g); void AddThingGeometry(VisualThing t); diff --git a/Source/Core/Rendering/Renderer.cs b/Source/Core/Rendering/Renderer.cs index eddfa976..d42ed2e8 100644 --- a/Source/Core/Rendering/Renderer.cs +++ b/Source/Core/Rendering/Renderer.cs @@ -85,6 +85,20 @@ namespace CodeImp.DoomBuilder.Rendering #region ================== Methods + // This calculates the sector brightness level + public int CalculateBrightness(int level) + { + float flevel = level; + + // Simulat doom light levels + if((level < 192) && General.Map.Config.DoomLightLevels) + flevel = (192.0f - (float)(192 - level) * 1.5f); + + byte blevel = (byte)General.Clamp((int)flevel, 0, 255); + PixelColor c = new PixelColor(255, blevel, blevel, blevel); + return c.ToInt(); + } + // This is called when the graphics need to be reset public virtual void Reset() { } diff --git a/Source/Plugins/BuilderModes/VisualModes/BaseVisualMode.cs b/Source/Plugins/BuilderModes/VisualModes/BaseVisualMode.cs index 152edf6c..a9d66935 100644 --- a/Source/Plugins/BuilderModes/VisualModes/BaseVisualMode.cs +++ b/Source/Plugins/BuilderModes/VisualModes/BaseVisualMode.cs @@ -156,13 +156,9 @@ namespace CodeImp.DoomBuilder.BuilderModes #region ================== Methods // This calculates brightness level - internal static int CalculateBrightness(int level) + internal int CalculateBrightness(int level) { - float flevel = level; - if(level < 192) flevel = (192.0f - (float)(192 - level) * 1.5f); // simulate doom light levels - byte blevel = (byte)General.Clamp((int)flevel, 0, 255); - PixelColor c = new PixelColor(255, blevel, blevel, blevel); - return c.ToInt(); + return renderer.CalculateBrightness(level); } // This adds a selected object diff --git a/Source/Plugins/BuilderModes/VisualModes/VisualCeiling.cs b/Source/Plugins/BuilderModes/VisualModes/VisualCeiling.cs index 79f708d6..1dc5747a 100644 --- a/Source/Plugins/BuilderModes/VisualModes/VisualCeiling.cs +++ b/Source/Plugins/BuilderModes/VisualModes/VisualCeiling.cs @@ -69,7 +69,7 @@ namespace CodeImp.DoomBuilder.BuilderModes WorldVertex[] verts; WorldVertex v; Sector s = base.Sector.Sector; - int brightness = BaseVisualMode.CalculateBrightness(s.Brightness); + int brightness = mode.CalculateBrightness(s.Brightness); // Load floor texture base.Texture = General.Map.Data.GetFlatImage(s.LongCeilTexture); diff --git a/Source/Plugins/BuilderModes/VisualModes/VisualFloor.cs b/Source/Plugins/BuilderModes/VisualModes/VisualFloor.cs index 2adccff5..f1f8f259 100644 --- a/Source/Plugins/BuilderModes/VisualModes/VisualFloor.cs +++ b/Source/Plugins/BuilderModes/VisualModes/VisualFloor.cs @@ -68,7 +68,7 @@ namespace CodeImp.DoomBuilder.BuilderModes { WorldVertex[] verts; Sector s = base.Sector.Sector; - int brightness = BaseVisualMode.CalculateBrightness(s.Brightness); + int brightness = mode.CalculateBrightness(s.Brightness); // Load floor texture base.Texture = General.Map.Data.GetFlatImage(s.LongFloorTexture); diff --git a/Source/Plugins/BuilderModes/VisualModes/VisualLower.cs b/Source/Plugins/BuilderModes/VisualModes/VisualLower.cs index 585d271c..3b72ca8f 100644 --- a/Source/Plugins/BuilderModes/VisualModes/VisualLower.cs +++ b/Source/Plugins/BuilderModes/VisualModes/VisualLower.cs @@ -65,7 +65,7 @@ namespace CodeImp.DoomBuilder.BuilderModes // This builds the geometry. Returns false when no geometry created. public override bool Setup() { - int brightness = BaseVisualMode.CalculateBrightness(Sidedef.Sector.Brightness); + int brightness = mode.CalculateBrightness(Sidedef.Sector.Brightness); // Calculate size of this wall part float geotop = (float)Sidedef.Other.Sector.FloorHeight; diff --git a/Source/Plugins/BuilderModes/VisualModes/VisualMiddleDouble.cs b/Source/Plugins/BuilderModes/VisualModes/VisualMiddleDouble.cs index 1170ce95..eb4181fe 100644 --- a/Source/Plugins/BuilderModes/VisualModes/VisualMiddleDouble.cs +++ b/Source/Plugins/BuilderModes/VisualModes/VisualMiddleDouble.cs @@ -70,7 +70,7 @@ namespace CodeImp.DoomBuilder.BuilderModes { WorldVertex[] verts; - int brightness = BaseVisualMode.CalculateBrightness(Sidedef.Sector.Brightness); + int brightness = mode.CalculateBrightness(Sidedef.Sector.Brightness); // Calculate size of this wall part float geotop = (float)Math.Min(Sidedef.Sector.CeilHeight, Sidedef.Other.Sector.CeilHeight); diff --git a/Source/Plugins/BuilderModes/VisualModes/VisualMiddleSingle.cs b/Source/Plugins/BuilderModes/VisualModes/VisualMiddleSingle.cs index 35033bd3..a071744e 100644 --- a/Source/Plugins/BuilderModes/VisualModes/VisualMiddleSingle.cs +++ b/Source/Plugins/BuilderModes/VisualModes/VisualMiddleSingle.cs @@ -65,7 +65,7 @@ namespace CodeImp.DoomBuilder.BuilderModes // This builds the geometry. Returns false when no geometry created. public override bool Setup() { - int brightness = BaseVisualMode.CalculateBrightness(Sidedef.Sector.Brightness); + int brightness = mode.CalculateBrightness(Sidedef.Sector.Brightness); // Calculate size of this wall part float geotop = (float)Sidedef.Sector.CeilHeight; diff --git a/Source/Plugins/BuilderModes/VisualModes/VisualUpper.cs b/Source/Plugins/BuilderModes/VisualModes/VisualUpper.cs index 7cb332a6..09a3e204 100644 --- a/Source/Plugins/BuilderModes/VisualModes/VisualUpper.cs +++ b/Source/Plugins/BuilderModes/VisualModes/VisualUpper.cs @@ -65,7 +65,7 @@ namespace CodeImp.DoomBuilder.BuilderModes // This builds the geometry. Returns false when no geometry created. public override bool Setup() { - int brightness = BaseVisualMode.CalculateBrightness(Sidedef.Sector.Brightness); + int brightness = mode.CalculateBrightness(Sidedef.Sector.Brightness); // Calculate size of this wall part float geotop = (float)Sidedef.Sector.CeilHeight;