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

@ -474,6 +474,32 @@ pxl8_bsp_lightmap pxl8_bsp_lightmap_mapped(u8 width, u8 height, u32 offset) {
};
}
u8 pxl8_bsp_light_at(const pxl8_bsp* bsp, f32 x, f32 y, f32 z, u8 ambient) {
if (!bsp || !bsp->vertices || !bsp->vertex_lights) return 255;
f32 best_dist = FLT_MAX;
u32 best_idx = 0;
for (u32 i = 0; i < bsp->num_vertices; i++) {
f32 dx = bsp->vertices[i].position.x - x;
f32 dy = bsp->vertices[i].position.y - y;
f32 dz = bsp->vertices[i].position.z - z;
f32 dist = dx * dx + dy * dy + dz * dz;
if (dist < best_dist) {
best_dist = dist;
best_idx = i;
}
}
if (best_idx >= bsp->num_vertex_lights) return 255;
u32 packed = bsp->vertex_lights[best_idx];
u8 direct = (packed >> 24) & 0xFF;
u8 ao = (packed >> 16) & 0xFF;
f32 combined = (f32)direct + ((f32)ambient / 255.0f) * (f32)ao;
return (u8)(combined > 255.0f ? 255.0f : combined);
}
pxl8_bsp_lightmap_sample pxl8_bsp_sample_lightmap(const pxl8_bsp* bsp, u32 face_idx, f32 u, f32 v) {
pxl8_bsp_lightmap_sample white = {255, 255, 255};