glow rendering fixes to bring stars back

This commit is contained in:
asrael 2026-02-10 11:10:37 -06:00
parent 657b590b6f
commit c538641ec8
26 changed files with 773 additions and 1491 deletions

View file

@ -11,7 +11,9 @@ extern "C" {
#define PXL8_LIGHT_LEVELS 8
#define PXL8_LIGHT_ROWS (PXL8_LIGHT_COLORS * PXL8_LIGHT_LEVELS)
#define PXL8_BLEND_ROWS 256
#define PXL8_COLORMAP_ROWS (PXL8_LIGHT_ROWS + PXL8_BLEND_ROWS)
#define PXL8_ADDITIVE_ROWS (PXL8_LIGHT_COLORS * PXL8_LIGHT_LEVELS)
#define PXL8_ADDITIVE_START (PXL8_LIGHT_ROWS + PXL8_BLEND_ROWS)
#define PXL8_COLORMAP_ROWS (PXL8_LIGHT_ROWS + PXL8_BLEND_ROWS + PXL8_ADDITIVE_ROWS)
#define PXL8_COLORMAP_SIZE (256 * PXL8_COLORMAP_ROWS)
#define PXL8_FULLBRIGHT_START 240
@ -47,6 +49,7 @@ static const pxl8_rgb pxl8_light_colors[PXL8_LIGHT_COLORS] = {
typedef struct {
u8 table[PXL8_COLORMAP_SIZE];
u8 luminance[256];
} pxl8_colormap;
void pxl8_colormap_generate(pxl8_colormap* cm, const u32* palette);
@ -68,6 +71,17 @@ static inline u8 pxl8_colormap_blend(const pxl8_colormap* cm, u8 src, u8 dst) {
return cm->table[(blend_row << 8) + dst];
}
static inline u8 pxl8_colormap_additive(const pxl8_colormap* cm, u8 pal_idx, pxl8_light_color light_color, u8 intensity) {
u32 row = PXL8_ADDITIVE_START + ((u32)light_color << 3) + (intensity >> 5);
return cm->table[(row << 8) + pal_idx];
}
static inline u8 pxl8_colormap_additive_dithered(const pxl8_colormap* cm, u8 pal_idx, pxl8_light_color light_color, u8 intensity, u32 x, u32 y) {
u8 dithered = pxl8_gfx_dither((f32)intensity + 0.5f, x, y);
u32 row = PXL8_ADDITIVE_START + ((u32)light_color << 3) + (dithered >> 5);
return cm->table[(row << 8) + pal_idx];
}
#ifdef __cplusplus
}
#endif