|
|
|
@ -28,9 +28,9 @@ union ColorConv { |
|
|
|
|
* and I guess the compiler can handle it better than shifting |
|
|
|
|
* bits around. |
|
|
|
|
*/ |
|
|
|
|
inline uint32_t new_lighting(uint32_t pixel, int level) { |
|
|
|
|
float factor = level * PERCENT; |
|
|
|
|
|
|
|
|
|
inline uint32_t new_lighting(uint32_t pixel, float dist, int level) { |
|
|
|
|
(void)dist; // ignore for now until I can do more research
|
|
|
|
|
float factor = float(level) * PERCENT; |
|
|
|
|
ColorConv conv{.as_int=pixel}; |
|
|
|
|
conv.as_color.r *= factor; |
|
|
|
|
conv.as_color.g *= factor; |
|
|
|
@ -281,7 +281,7 @@ void Raycaster::cast_rays() { |
|
|
|
|
tex_pos += step; |
|
|
|
|
RGBA pixel = texture[texture_height * tex_y + tex_x]; |
|
|
|
|
int light_level = lights[map_y][map_x]; |
|
|
|
|
$pixels[pixcoord(x, y)] = new_lighting(pixel, light_level); |
|
|
|
|
$pixels[pixcoord(x, y)] = new_lighting(pixel, perp_wall_dist, light_level); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// SET THE ZBUFFER FOR THE SPRITE CASTING
|
|
|
|
@ -349,11 +349,11 @@ void Raycaster::draw_ceiling_floor() { |
|
|
|
|
|
|
|
|
|
// FLOOR
|
|
|
|
|
color = $floor_texture[texture_width * ty + tx]; |
|
|
|
|
$pixels[pixcoord(x, y)] = new_lighting(color, light_level); |
|
|
|
|
$pixels[pixcoord(x, y)] = new_lighting(color, row_distance, light_level); |
|
|
|
|
|
|
|
|
|
// CEILING
|
|
|
|
|
color = $ceiling_texture[texture_width * ty + tx]; |
|
|
|
|
$pixels[pixcoord(x, $height - y - 1)] = new_lighting(color, light_level); |
|
|
|
|
$pixels[pixcoord(x, $height - y - 1)] = new_lighting(color, row_distance, light_level); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|