Add ditheed shadows

This commit is contained in:
Miloslav Číž 2019-09-27 01:25:22 +02:00
parent f18079cd00
commit ddb4970816
2 changed files with 20 additions and 0 deletions

18
main.c
View File

@ -106,7 +106,25 @@ void SFG_pixelFunc(RCL_PixelInfo *pixel)
if (color != SFG_TRANSPARENT_COLOR) if (color != SFG_TRANSPARENT_COLOR)
{ {
#if SFG_DITHERED_SHADOW
uint8_t fogShadow = (pixel->depth * 2) / RCL_UNITS_PER_SQUARE;
uint8_t fogShadowPart = fogShadow & 0x03;
uint8_t xMod2 = pixel->position.x & 0x01;
uint8_t yMod2 = pixel->position.y & 0x01;
fogShadow >>= 2;
if (((fogShadowPart == 1) && xMod2 && yMod2) ||
((fogShadowPart == 2) && (xMod2 == yMod2)) ||
((fogShadowPart == 3) && (xMod2 || yMod2)))
fogShadow += 1;
shadow += fogShadow;
#else
shadow += pixel->depth / (RCL_UNITS_PER_SQUARE * 2); shadow += pixel->depth / (RCL_UNITS_PER_SQUARE * 2);
#endif
color = palette_minusValue(color,shadow); color = palette_minusValue(color,shadow);
} }
else else

View File

@ -5,4 +5,6 @@
#define SFG_RESOLUTION_X 1024 #define SFG_RESOLUTION_X 1024
#define SFG_RESOLUTION_Y 768 #define SFG_RESOLUTION_Y 768
#define SFG_DITHERED_SHADOW 1
#endif // guard #endif // guard