Browse Source

Hellfire: Fix light fall off not with in it's radious

pull/6036/head
Anders Jenbo 3 years ago
parent
commit
eef0b10e1f
  1. 37
      Source/lighting.cpp

37
Source/lighting.cpp

@ -369,29 +369,26 @@ void MakeLightTable()
LoadFileInMem("gendata\\pause.trn", PauseTable); LoadFileInMem("gendata\\pause.trn", PauseTable);
// Generate light falloffs ranges // Generate light falloffs ranges
if (IsAnyOf(leveltype, DTYPE_NEST, DTYPE_CRYPT)) { const float maxDarkness = 15;
for (size_t j = 0; j < NumLightRadiuses; j++) { const float maxBrightness = 0;
double fa = (sqrt((double)(16 - j))) / 128; for (size_t radius = 0; radius < NumLightRadiuses; radius++) {
fa *= fa; size_t maxDistance = (radius + 1) * 8;
for (int i = 0; i < 128; i++) { for (size_t distance = 0; distance < 128; distance++) {
uint8_t color = 15 - static_cast<uint8_t>(fa * (double)((128 - i) * (128 - i))); if (distance > maxDistance) {
if (color > 15) LightFalloffs[radius][distance] = 15;
color = 0;
color -= static_cast<uint8_t>((NumLightRadiuses - j - 1) / 2);
if (color > 15)
color = 0;
LightFalloffs[NumLightRadiuses - j - 1][i] = color;
}
}
} else { } else {
for (size_t j = 0; j < NumLightRadiuses; j++) { const float factor = static_cast<float>(distance) / maxDistance;
for (size_t i = 0; i < 128; i++) { float scaled;
if (i > (j + 1) * 8) { if (IsAnyOf(leveltype, DTYPE_NEST, DTYPE_CRYPT)) {
LightFalloffs[j][i] = 15; // quardratic falloff with over exposure
const float brightness = radius * 1.5;
scaled = factor * factor * brightness + (maxDarkness - brightness);
scaled = std::max(maxBrightness, scaled);
} else { } else {
double fs = (double)15 * i / ((double)8 * (j + 1)); // Leaner falloff
LightFalloffs[j][i] = static_cast<uint8_t>(fs + 0.5); scaled = factor * maxDarkness;
} }
LightFalloffs[radius][distance] = static_cast<uint8_t>(scaled + 0.5F); // round up
} }
} }
} }

Loading…
Cancel
Save