diff --git a/Source/Plugins/BuilderModes/VisualModes/BaseVisualMode.cs b/Source/Plugins/BuilderModes/VisualModes/BaseVisualMode.cs index 4f621ba7..152edf6c 100644 --- a/Source/Plugins/BuilderModes/VisualModes/BaseVisualMode.cs +++ b/Source/Plugins/BuilderModes/VisualModes/BaseVisualMode.cs @@ -155,6 +155,16 @@ namespace CodeImp.DoomBuilder.BuilderModes #region ================== Methods + // This calculates brightness level + internal static 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(); + } + // This adds a selected object internal void AddSelectedObject(IVisualEventReceiver obj) { diff --git a/Source/Plugins/BuilderModes/VisualModes/VisualCeiling.cs b/Source/Plugins/BuilderModes/VisualModes/VisualCeiling.cs index ab670075..79f708d6 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; - byte brightness = (byte)General.Clamp(s.Brightness, 0, 255); + int brightness = BaseVisualMode.CalculateBrightness(s.Brightness); // Load floor texture base.Texture = General.Map.Data.GetFlatImage(s.LongCeilTexture); @@ -89,9 +89,7 @@ namespace CodeImp.DoomBuilder.BuilderModes for(int i = 0; i < s.Triangles.Vertices.Count; i++) { // Use sector brightness for color shading - PixelColor pc = new PixelColor(255, brightness, brightness, brightness); - verts[i].c = pc.ToInt(); - //verts[i].c = -1; + verts[i].c = brightness; // Grid aligned texture coordinates if(base.Texture.IsImageLoaded) diff --git a/Source/Plugins/BuilderModes/VisualModes/VisualFloor.cs b/Source/Plugins/BuilderModes/VisualModes/VisualFloor.cs index ad23119e..2adccff5 100644 --- a/Source/Plugins/BuilderModes/VisualModes/VisualFloor.cs +++ b/Source/Plugins/BuilderModes/VisualModes/VisualFloor.cs @@ -1,4 +1,4 @@ - + #region ================== Copyright (c) 2007 Pascal vd Heiden /* @@ -68,7 +68,7 @@ namespace CodeImp.DoomBuilder.BuilderModes { WorldVertex[] verts; Sector s = base.Sector.Sector; - byte brightness = (byte)General.Clamp(s.Brightness, 0, 255); + int brightness = BaseVisualMode.CalculateBrightness(s.Brightness); // Load floor texture base.Texture = General.Map.Data.GetFlatImage(s.LongFloorTexture); @@ -88,9 +88,7 @@ namespace CodeImp.DoomBuilder.BuilderModes for(int i = 0; i < s.Triangles.Vertices.Count; i++) { // Use sector brightness for color shading - PixelColor pc = new PixelColor(255, brightness, brightness, brightness); - verts[i].c = pc.ToInt(); - //verts[i].c = -1; + verts[i].c = brightness; // Grid aligned texture coordinates if(base.Texture.IsImageLoaded) diff --git a/Source/Plugins/BuilderModes/VisualModes/VisualLower.cs b/Source/Plugins/BuilderModes/VisualModes/VisualLower.cs index 7da56821..585d271c 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() { - byte brightness = (byte)General.Clamp(Sidedef.Sector.Brightness, 0, 255); + int brightness = BaseVisualMode.CalculateBrightness(Sidedef.Sector.Brightness); // Calculate size of this wall part float geotop = (float)Sidedef.Other.Sector.FloorHeight; @@ -134,17 +134,14 @@ namespace CodeImp.DoomBuilder.BuilderModes v2 = Sidedef.Line.Start.Position; } - // Use sector brightness for color shading - PixelColor pc = new PixelColor(255, brightness, brightness, brightness); - // Make vertices WorldVertex[] verts = new WorldVertex[6]; - verts[0] = new WorldVertex(v1.x, v1.y, geobottom, pc.ToInt(), t1.x, t2.y); - verts[1] = new WorldVertex(v1.x, v1.y, geotop, pc.ToInt(), t1.x, t1.y); - verts[2] = new WorldVertex(v2.x, v2.y, geotop, pc.ToInt(), t2.x, t1.y); + verts[0] = new WorldVertex(v1.x, v1.y, geobottom, brightness, t1.x, t2.y); + verts[1] = new WorldVertex(v1.x, v1.y, geotop, brightness, t1.x, t1.y); + verts[2] = new WorldVertex(v2.x, v2.y, geotop, brightness, t2.x, t1.y); verts[3] = verts[0]; verts[4] = verts[2]; - verts[5] = new WorldVertex(v2.x, v2.y, geobottom, pc.ToInt(), t2.x, t2.y); + verts[5] = new WorldVertex(v2.x, v2.y, geobottom, brightness, t2.x, t2.y); // Keep properties base.top = geotop; diff --git a/Source/Plugins/BuilderModes/VisualModes/VisualMiddleDouble.cs b/Source/Plugins/BuilderModes/VisualModes/VisualMiddleDouble.cs index 0dbb6b49..1170ce95 100644 --- a/Source/Plugins/BuilderModes/VisualModes/VisualMiddleDouble.cs +++ b/Source/Plugins/BuilderModes/VisualModes/VisualMiddleDouble.cs @@ -69,8 +69,8 @@ namespace CodeImp.DoomBuilder.BuilderModes public override bool Setup() { WorldVertex[] verts; - - byte brightness = (byte)General.Clamp(Sidedef.Sector.Brightness, 0, 255); + + int brightness = BaseVisualMode.CalculateBrightness(Sidedef.Sector.Brightness); // Calculate size of this wall part float geotop = (float)Math.Min(Sidedef.Sector.CeilHeight, Sidedef.Other.Sector.CeilHeight); @@ -146,17 +146,14 @@ namespace CodeImp.DoomBuilder.BuilderModes v2 = Sidedef.Line.Start.Position; } - // Use sector brightness for color shading - PixelColor pc = new PixelColor(255, brightness, brightness, brightness); - // Make vertices verts = new WorldVertex[6]; - verts[0] = new WorldVertex(v1.x, v1.y, texbottom, pc.ToInt(), t1.x, t2.y); - verts[1] = new WorldVertex(v1.x, v1.y, textop, pc.ToInt(), t1.x, t1.y); - verts[2] = new WorldVertex(v2.x, v2.y, textop, pc.ToInt(), t2.x, t1.y); + verts[0] = new WorldVertex(v1.x, v1.y, texbottom, brightness, t1.x, t2.y); + verts[1] = new WorldVertex(v1.x, v1.y, textop, brightness, t1.x, t1.y); + verts[2] = new WorldVertex(v2.x, v2.y, textop, brightness, t2.x, t1.y); verts[3] = verts[0]; verts[4] = verts[2]; - verts[5] = new WorldVertex(v2.x, v2.y, texbottom, pc.ToInt(), t2.x, t2.y); + verts[5] = new WorldVertex(v2.x, v2.y, texbottom, brightness, t2.x, t2.y); // Keep properties base.top = textop; diff --git a/Source/Plugins/BuilderModes/VisualModes/VisualMiddleSingle.cs b/Source/Plugins/BuilderModes/VisualModes/VisualMiddleSingle.cs index 5a010c5f..35033bd3 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() { - byte brightness = (byte)General.Clamp(Sidedef.Sector.Brightness, 0, 255); + int brightness = BaseVisualMode.CalculateBrightness(Sidedef.Sector.Brightness); // Calculate size of this wall part float geotop = (float)Sidedef.Sector.CeilHeight; @@ -134,17 +134,14 @@ namespace CodeImp.DoomBuilder.BuilderModes v2 = Sidedef.Line.Start.Position; } - // Use sector brightness for color shading - PixelColor pc = new PixelColor(255, brightness, brightness, brightness); - // Make vertices WorldVertex[] verts = new WorldVertex[6]; - verts[0] = new WorldVertex(v1.x, v1.y, geobottom, pc.ToInt(), t1.x, t2.y); - verts[1] = new WorldVertex(v1.x, v1.y, geotop, pc.ToInt(), t1.x, t1.y); - verts[2] = new WorldVertex(v2.x, v2.y, geotop, pc.ToInt(), t2.x, t1.y); + verts[0] = new WorldVertex(v1.x, v1.y, geobottom, brightness, t1.x, t2.y); + verts[1] = new WorldVertex(v1.x, v1.y, geotop, brightness, t1.x, t1.y); + verts[2] = new WorldVertex(v2.x, v2.y, geotop, brightness, t2.x, t1.y); verts[3] = verts[0]; verts[4] = verts[2]; - verts[5] = new WorldVertex(v2.x, v2.y, geobottom, pc.ToInt(), t2.x, t2.y); + verts[5] = new WorldVertex(v2.x, v2.y, geobottom, brightness, t2.x, t2.y); // Keep properties base.top = geotop; diff --git a/Source/Plugins/BuilderModes/VisualModes/VisualUpper.cs b/Source/Plugins/BuilderModes/VisualModes/VisualUpper.cs index c7b55e5e..7cb332a6 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() { - byte brightness = (byte)General.Clamp(Sidedef.Sector.Brightness, 0, 255); + int brightness = BaseVisualMode.CalculateBrightness(Sidedef.Sector.Brightness); // Calculate size of this wall part float geotop = (float)Sidedef.Sector.CeilHeight; @@ -134,17 +134,14 @@ namespace CodeImp.DoomBuilder.BuilderModes v2 = Sidedef.Line.Start.Position; } - // Use sector brightness for color shading - PixelColor pc = new PixelColor(255, brightness, brightness, brightness); - // Make vertices WorldVertex[] verts = new WorldVertex[6]; - verts[0] = new WorldVertex(v1.x, v1.y, geobottom, pc.ToInt(), t1.x, t2.y); - verts[1] = new WorldVertex(v1.x, v1.y, geotop, pc.ToInt(), t1.x, t1.y); - verts[2] = new WorldVertex(v2.x, v2.y, geotop, pc.ToInt(), t2.x, t1.y); + verts[0] = new WorldVertex(v1.x, v1.y, geobottom, brightness, t1.x, t2.y); + verts[1] = new WorldVertex(v1.x, v1.y, geotop, brightness, t1.x, t1.y); + verts[2] = new WorldVertex(v2.x, v2.y, geotop, brightness, t2.x, t1.y); verts[3] = verts[0]; verts[4] = verts[2]; - verts[5] = new WorldVertex(v2.x, v2.y, geobottom, pc.ToInt(), t2.x, t2.y); + verts[5] = new WorldVertex(v2.x, v2.y, geobottom, brightness, t2.x, t2.y); // Keep properties base.top = geotop;