diff --git a/src/gl/renderer/gl_postprocess.cpp b/src/gl/renderer/gl_postprocess.cpp index 827dd7da2..acc0a08b4 100644 --- a/src/gl/renderer/gl_postprocess.cpp +++ b/src/gl/renderer/gl_postprocess.cpp @@ -612,9 +612,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; } } 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()); diff --git a/wadsrc/static/shaders/glsl/main.fp b/wadsrc/static/shaders/glsl/main.fp index 5b4d1438f..ee113676b 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) * 32.0)) / 32.0; 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); } //=========================================================================== 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