Add fog
This commit is contained in:
parent
c41e9a8fd9
commit
d1458632e9
1 changed files with 20 additions and 2 deletions
22
game.cpp
22
game.cpp
|
@ -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);
|
||||
}
|
||||
|
||||
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
|
||||
{
|
||||
public:
|
||||
|
@ -196,10 +214,10 @@ if (pixel.isWall)
|
|||
|
||||
if (intensity < 0)
|
||||
intensity = 0;
|
||||
}
|
||||
|
||||
if (pixel.isWall)
|
||||
c = sampleImage(image,pixel.hit.textureCoord,pixel.textureCoordY);
|
||||
c = darkenColor(c,intensity);
|
||||
}
|
||||
else
|
||||
c = rgbToIndex(intensity,intensity,intensity / 2);
|
||||
|
||||
|
|
Loading…
Reference in a new issue