Throw in the distance to mess with it later.
This commit is contained in:
parent
65c9e4b0c6
commit
0a40135f5d
1 changed files with 6 additions and 6 deletions
|
@ -28,9 +28,9 @@ union ColorConv {
|
||||||
* and I guess the compiler can handle it better than shifting
|
* and I guess the compiler can handle it better than shifting
|
||||||
* bits around.
|
* bits around.
|
||||||
*/
|
*/
|
||||||
inline uint32_t new_lighting(uint32_t pixel, int level) {
|
inline uint32_t new_lighting(uint32_t pixel, float dist, int level) {
|
||||||
float factor = level * PERCENT;
|
(void)dist; // ignore for now until I can do more research
|
||||||
|
float factor = float(level) * PERCENT;
|
||||||
ColorConv conv{.as_int=pixel};
|
ColorConv conv{.as_int=pixel};
|
||||||
conv.as_color.r *= factor;
|
conv.as_color.r *= factor;
|
||||||
conv.as_color.g *= factor;
|
conv.as_color.g *= factor;
|
||||||
|
@ -281,7 +281,7 @@ void Raycaster::cast_rays() {
|
||||||
tex_pos += step;
|
tex_pos += step;
|
||||||
RGBA pixel = texture[texture_height * tex_y + tex_x];
|
RGBA pixel = texture[texture_height * tex_y + tex_x];
|
||||||
int light_level = lights[map_y][map_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
|
// SET THE ZBUFFER FOR THE SPRITE CASTING
|
||||||
|
@ -349,11 +349,11 @@ void Raycaster::draw_ceiling_floor() {
|
||||||
|
|
||||||
// FLOOR
|
// FLOOR
|
||||||
color = $floor_texture[texture_width * ty + tx];
|
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
|
// CEILING
|
||||||
color = $ceiling_texture[texture_width * ty + tx];
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue