This commit is contained in:
Miloslav Číž 2018-09-03 14:31:29 +02:00
parent c41e9a8fd9
commit d1458632e9

View file

@ -110,6 +110,24 @@ inline uint8_t rgbToIndex(uint8_t r, uint8_t g, uint8_t b)
return (r & 0b00000111) | ((g & 0b00000111) << 3) | ((b & 0b00000011) << 6); return (r & 0b00000111) | ((g & 0b00000111) << 3) | ((b & 0b00000011) << 6);
} }
inline uint8_t darkenColor(uint8_t color, uint8_t intensity)
{
uint8_t r = color & 0b00000111;
uint8_t g = (color & 0b00111000) >> 3;
uint8_t b = (color & 0b11000000) >> 6;
r += intensity;
r = r > 7 ? 7 : r;
g += intensity;
g = g > 7 ? 7 : g;
b += intensity / 2;
b = b > 3 ? 3 : b;
return rgbToIndex(r,g,b);
}
class Level class Level
{ {
public: public:
@ -196,10 +214,10 @@ if (pixel.isWall)
if (intensity < 0) if (intensity < 0)
intensity = 0; intensity = 0;
}
if (pixel.isWall)
c = sampleImage(image,pixel.hit.textureCoord,pixel.textureCoordY); c = sampleImage(image,pixel.hit.textureCoord,pixel.textureCoordY);
c = darkenColor(c,intensity);
}
else else
c = rgbToIndex(intensity,intensity,intensity / 2); c = rgbToIndex(intensity,intensity,intensity / 2);