This commit is contained in:
Rachael Alexanderson 2017-06-22 01:42:33 -04:00
commit 9001009fcf
6 changed files with 33 additions and 29 deletions

View file

@ -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)]; 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; int index = ((r * 64 + g) * 64 + b) * 4;
lut[index] = color.r; lut[index] = color.b;
lut[index + 1] = color.g; lut[index + 1] = color.g;
lut[index + 2] = color.b; lut[index + 2] = color.r;
lut[index + 3] = 255; lut[index + 3] = 255;
} }
} }

View file

@ -271,8 +271,8 @@ void SWCanvas::FillSimplePoly(DCanvas *canvas, FTexture *tex, FVector2 *points,
viewport->RenderTarget->Lock(true); viewport->RenderTarget->Lock(true);
scalex /= tex->Scale.X; scalex = tex->Scale.X / scalex;
scaley /= tex->Scale.Y; scaley = tex->Scale.Y / scaley;
// Use the CRT's functions here. // Use the CRT's functions here.
cosrot = cos(rotation.Radians()); cosrot = cos(rotation.Radians());

View file

@ -103,34 +103,29 @@ vec4 getTexel(vec2 st)
//=========================================================================== //===========================================================================
float R_DoomLightingEquation(float light) 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 // WallVisibility is calculated in LightVisibility::SetVisibility
// Floor: r_FloorVisibility / abs(plane.Zat0 - ViewPos.Z) // 1706 is the default value for WallVisibility on 1080p 16:9 displays.
// Sprite: same as wall float globVis = 1706.0 / 1.3333333333333333 / 32.0;
// 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;
/* 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; 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; float z = pixelpos.w;
/* The zdoom light equation */ // The zdoom light equation
float vis = globVis / z; float vis = min(globVis / z, 24.0 / 32.0);
float shade = 64.0 - (L + 12.0) * 32.0/128.0; float shade = 2.0 - (L + 12.0) / 128.0;
float lightscale; float lightscale;
if (uPalLightLevels != 0) 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 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) // Result is the normalized colormap index (0 bright .. 1 dark)
return lightscale; return clamp(lightscale, 0.0, 31.0 / 32.0);
} }
//=========================================================================== //===========================================================================

View file

@ -449,7 +449,7 @@ struct DropItem native
native readonly DropItem Next; native readonly DropItem Next;
native readonly name Name; native readonly name Name;
native readonly int Probability; native readonly int Probability;
native int Amount; native readonly int Amount;
} }
class SpotState : Object native class SpotState : Object native

View file

@ -318,11 +318,12 @@ extend class Actor
{ {
if (di.Name != 'None') 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; di = drop;
@ -331,7 +332,12 @@ extend class Actor
{ {
if (di.Name != 'none') 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)) if ((di.Next != null) && (n >= 0))
{ {

View file

@ -48,8 +48,9 @@ class RandomSpawner : Actor
{ {
if (!nomonsters || !IsMonster(di)) if (!nomonsters || !IsMonster(di))
{ {
if (di.Amount < 0) di.Amount = 1; // default value is -1, we need a positive value. int amt = di.Amount;
n += di.Amount; // this is how we can weight the list. 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; di = di.Next;
} }
@ -69,7 +70,9 @@ class RandomSpawner : Actor
if (di.Name != 'None' && if (di.Name != 'None' &&
(!nomonsters || !IsMonster(di))) (!nomonsters || !IsMonster(di)))
{ {
n -= di.Amount; int amt = di.Amount;
if (amt < 0) amt = 1;
n -= amt;
if ((di.Next != null) && (n > -1)) if ((di.Next != null) && (n > -1))
di = di.Next; di = di.Next;
else else