From bdc99d976880ed550a58402d55d94a827732306d Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Wed, 21 Jun 2017 04:03:37 -0400 Subject: [PATCH 1/5] - fixed: fillsimplepoly drawer was using an inverted scale, leading to incorrect automap texture display. --- src/swrenderer/r_swcanvas.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/swrenderer/r_swcanvas.cpp b/src/swrenderer/r_swcanvas.cpp index 087d0ca87..88c0a6b29 100644 --- a/src/swrenderer/r_swcanvas.cpp +++ b/src/swrenderer/r_swcanvas.cpp @@ -271,8 +271,8 @@ void SWCanvas::FillSimplePoly(DCanvas *canvas, FTexture *tex, FVector2 *points, viewport->RenderTarget->Lock(true); - scalex /= tex->Scale.X; - scaley /= tex->Scale.Y; + scalex = tex->Scale.X / scalex; + scaley = tex->Scale.Y / scaley; // Use the CRT's functions here. cosrot = cos(rotation.Radians()); From a6b7ce00c2a92f8c4bd5a050cc4134eaeb27b245 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 21 Jun 2017 11:39:59 +0200 Subject: [PATCH 2/5] - made DropItem fully read-only by changing the two places which messed around with DropItem.Amount to use a local variable instead. The pointers themselves should have been declared read-only from the start but for that it is too late, so now all its members are. --- wadsrc/static/zscript/base.txt | 2 +- wadsrc/static/zscript/doom/bossbrain.txt | 14 ++++++++++---- wadsrc/static/zscript/shared/randomspawner.txt | 9 ++++++--- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/wadsrc/static/zscript/base.txt b/wadsrc/static/zscript/base.txt index d6f7f318e..726e46fcc 100644 --- a/wadsrc/static/zscript/base.txt +++ b/wadsrc/static/zscript/base.txt @@ -449,7 +449,7 @@ struct DropItem native native readonly DropItem Next; native readonly name Name; native readonly int Probability; - native int Amount; + native readonly int Amount; } class SpotState : Object native diff --git a/wadsrc/static/zscript/doom/bossbrain.txt b/wadsrc/static/zscript/doom/bossbrain.txt index 5b87182c9..fadc280e3 100644 --- a/wadsrc/static/zscript/doom/bossbrain.txt +++ b/wadsrc/static/zscript/doom/bossbrain.txt @@ -318,11 +318,12 @@ extend class Actor { if (di.Name != 'None') { - if (di.Amount < 0) + int amt = di.Amount; + if (amt < 0) { - di.Amount = 1; // default value is -1, we need a positive value. + amt = 1; // default value is -1, we need a positive value. } - n += di.Amount; // this is how we can weight the list. + n += amt; // this is how we can weight the list. } } di = drop; @@ -331,7 +332,12 @@ extend class Actor { if (di.Name != 'none') { - n -= di.Amount; // logically, none of the -1 values have survived by now. + int amt = di.Amount; + if (amt < 0) + { + amt = 1; + } + n -= amt; } if ((di.Next != null) && (n >= 0)) { diff --git a/wadsrc/static/zscript/shared/randomspawner.txt b/wadsrc/static/zscript/shared/randomspawner.txt index b6e28cc37..7488fdd4d 100644 --- a/wadsrc/static/zscript/shared/randomspawner.txt +++ b/wadsrc/static/zscript/shared/randomspawner.txt @@ -48,8 +48,9 @@ class RandomSpawner : Actor { if (!nomonsters || !IsMonster(di)) { - if (di.Amount < 0) di.Amount = 1; // default value is -1, we need a positive value. - n += di.Amount; // this is how we can weight the list. + int amt = di.Amount; + if (amt < 0) amt = 1; // default value is -1, we need a positive value. + n += amt; // this is how we can weight the list. } di = di.Next; } @@ -69,7 +70,9 @@ class RandomSpawner : Actor if (di.Name != 'None' && (!nomonsters || !IsMonster(di))) { - n -= di.Amount; + int amt = di.Amount; + if (amt < 0) amt = 1; + n -= amt; if ((di.Next != null) && (n > -1)) di = di.Next; else From 28acf2ad0616f3b300a246cb89d3879b357f002e Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Thu, 22 Jun 2017 00:01:57 +0200 Subject: [PATCH 3/5] - Fix OpenGL software diminishing light to be identical to truecolor swrenderer and softpoly All there is left is to make globVis an uniform and move the LightVisibility::SetVisibility calculations out of the software renderer. That will make it 100% correct for all r_visiblity values and aspect ratios. --- wadsrc/static/shaders/glsl/main.fp | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/wadsrc/static/shaders/glsl/main.fp b/wadsrc/static/shaders/glsl/main.fp index 5b4d1438f..fd520ce0b 100644 --- a/wadsrc/static/shaders/glsl/main.fp +++ b/wadsrc/static/shaders/glsl/main.fp @@ -103,34 +103,29 @@ vec4 getTexel(vec2 st) //=========================================================================== float R_DoomLightingEquation(float light) { - // Calculated from r_visibility. It differs between walls, floor and sprites. + // globVis = WallVisibility / r_viewwindow.FocalTangent / 32.0 // - // Wall: globVis = r_WallVisibility - // Floor: r_FloorVisibility / abs(plane.Zat0 - ViewPos.Z) - // Sprite: same as wall - // All are calculated in R_SetVisibility and seem to be decided by the - // aspect ratio amongst other things. - // - // 1706 is the value for walls on 1080p 16:9 displays. - float globVis = 1706.0; + // WallVisibility is calculated in LightVisibility::SetVisibility + // 1706 is the default value for WallVisibility on 1080p 16:9 displays. + float globVis = 1706.0 / 1.3333333333333333 / 32.0; - /* L is the integer light level used in the game */ + // L is the integer light level used in the game float L = light * 255.0; - /* z is the depth in view/eye space, positive going into the screen */ + // z is the depth in view/eye space, positive going into the screen float z = pixelpos.w; - /* The zdoom light equation */ - float vis = globVis / z; - float shade = 64.0 - (L + 12.0) * 32.0/128.0; + // The zdoom light equation + float vis = min(globVis / z, 24.0 / 32.0); + float shade = 2.0 - (L + 12.0) / 128.0; float lightscale; if (uPalLightLevels != 0) - lightscale = clamp(float(int(shade - min(24.0, vis))) / 32.0, 0.0, 31.0/32.0); + lightscale = float(int(shade - vis)); else - lightscale = clamp((shade - min(24.0, vis)) / 32.0, 0.0, 31.0/32.0); + lightscale = shade - vis; // Result is the normalized colormap index (0 bright .. 1 dark) - return lightscale; + return clamp(lightscale, 0.0, 31.0 / 32.0); } //=========================================================================== From f49794d6c6379f6b40b381500557c8e10268d8f2 Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Wed, 21 Jun 2017 19:00:39 -0400 Subject: [PATCH 4/5] - fixed: Due to recent changes, textures now use 'bgra' format in OpenGL. The palette tonemap shader had not yet been updated to reflect this. --- src/gl/renderer/gl_postprocess.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gl/renderer/gl_postprocess.cpp b/src/gl/renderer/gl_postprocess.cpp index 2f9b31bbb..06ae5d86b 100644 --- a/src/gl/renderer/gl_postprocess.cpp +++ b/src/gl/renderer/gl_postprocess.cpp @@ -531,9 +531,9 @@ void FGLRenderer::CreateTonemapPalette() { PalEntry color = GPalette.BaseColors[(uint8_t)PTM_BestColor((uint32_t *)GPalette.BaseColors, (r << 2) | (r >> 4), (g << 2) | (g >> 4), (b << 2) | (b >> 4), 0, 256)]; int index = ((r * 64 + g) * 64 + b) * 4; - lut[index] = color.r; + lut[index] = color.b; lut[index + 1] = color.g; - lut[index + 2] = color.b; + lut[index + 2] = color.r; lut[index + 3] = 255; } } From 42293896801364cfb4eb1e316a868f23aabb92c1 Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Wed, 21 Jun 2017 19:10:39 -0400 Subject: [PATCH 5/5] - fixed: banded sw light was broken in a recent commit. Added back the 32 light levels and also made it prefer darker shades. --- wadsrc/static/shaders/glsl/main.fp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wadsrc/static/shaders/glsl/main.fp b/wadsrc/static/shaders/glsl/main.fp index fd520ce0b..ee113676b 100644 --- a/wadsrc/static/shaders/glsl/main.fp +++ b/wadsrc/static/shaders/glsl/main.fp @@ -120,7 +120,7 @@ float R_DoomLightingEquation(float light) float shade = 2.0 - (L + 12.0) / 128.0; float lightscale; if (uPalLightLevels != 0) - lightscale = float(int(shade - vis)); + lightscale = float(-int(-(shade - vis) * 32.0)) / 32.0; else lightscale = shade - vis;