- [FIX] Calcul de la llum corregit.
This commit is contained in:
13
main.cpp
13
main.cpp
@@ -319,6 +319,7 @@ void loadMap(const char* name)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float light_zoom = 1280;
|
||||||
int actual_sector = -1;
|
int actual_sector = -1;
|
||||||
int last_sector = -1;
|
int last_sector = -1;
|
||||||
void drawColumn(sector &s, int screen_column, int start, int end, float a_inc, vec2 origin, vec2 infi)
|
void drawColumn(sector &s, int screen_column, int start, int end, float a_inc, vec2 origin, vec2 infi)
|
||||||
@@ -376,7 +377,7 @@ void drawColumn(sector &s, int screen_column, int start, int end, float a_inc, v
|
|||||||
float actual_dist = straight_dist / SDL_cosf(a_inc*DEG_TO_RAD);
|
float actual_dist = straight_dist / SDL_cosf(a_inc*DEG_TO_RAD);
|
||||||
int tx = SDL_abs(int(actual_dist * SDL_cosf(angle*DEG_TO_RAD) - position.x)) % s.ceil_surf->w;
|
int tx = SDL_abs(int(actual_dist * SDL_cosf(angle*DEG_TO_RAD) - position.x)) % s.ceil_surf->w;
|
||||||
int ty = SDL_abs(int(actual_dist * SDL_sinf(angle*DEG_TO_RAD) - position.y)) % s.ceil_surf->h;
|
int ty = SDL_abs(int(actual_dist * SDL_sinf(angle*DEG_TO_RAD) - position.y)) % s.ceil_surf->h;
|
||||||
float light_dist = 1.0f - (-actual_dist>512 ? 1.0f : -actual_dist/512);
|
float light_dist = 1.0f - (-actual_dist>light_zoom ? 1.0f : -actual_dist/light_zoom);
|
||||||
float light = 1.0f - (light_dist*s.light);
|
float light = 1.0f - (light_dist*s.light);
|
||||||
uint8_t pixcolor = s.ceil_surf->pixels[tx+ty*s.ceil_surf->w];
|
uint8_t pixcolor = s.ceil_surf->pixels[tx+ty*s.ceil_surf->w];
|
||||||
pixcolor = colormap[pixcolor + int(light*31)*256];
|
pixcolor = colormap[pixcolor + int(light*31)*256];
|
||||||
@@ -393,7 +394,7 @@ void drawColumn(sector &s, int screen_column, int start, int end, float a_inc, v
|
|||||||
if (surf) {
|
if (surf) {
|
||||||
for (int i=0; i<wall_height; ++i) {
|
for (int i=0; i<wall_height; ++i) {
|
||||||
if (wall_start+i>=end) break;
|
if (wall_start+i>=end) break;
|
||||||
float light_dist = 1.0f - (dist>512 ? 1.0f : dist/512);
|
float light_dist = 1.0f - (dist>light_zoom ? 1.0f : dist/light_zoom);
|
||||||
float light = 1.0f - (light_dist*s.light);
|
float light = 1.0f - (light_dist*s.light);
|
||||||
uint8_t pixcolor = surf->pixels[(int(v)%surf->w)+(int(cpix)%surf->h)*surf->w];
|
uint8_t pixcolor = surf->pixels[(int(v)%surf->w)+(int(cpix)%surf->h)*surf->w];
|
||||||
pixcolor = colormap[pixcolor + int(light*31)*256];
|
pixcolor = colormap[pixcolor + int(light*31)*256];
|
||||||
@@ -413,7 +414,7 @@ void drawColumn(sector &s, int screen_column, int start, int end, float a_inc, v
|
|||||||
if (w->upper_surf)
|
if (w->upper_surf)
|
||||||
for (int i=0; i<upper_wall_height; ++i) {
|
for (int i=0; i<upper_wall_height; ++i) {
|
||||||
if (wall_start+i>=end) break;
|
if (wall_start+i>=end) break;
|
||||||
float light_dist = 1.0f - (dist>512 ? 1.0f : dist/512);
|
float light_dist = 1.0f - (dist>light_zoom ? 1.0f : dist/light_zoom);
|
||||||
float light = 1.0f - (light_dist*s.light);
|
float light = 1.0f - (light_dist*s.light);
|
||||||
uint8_t pixcolor = w->upper_surf->pixels[(int(v)%w->upper_surf->w)+(int(cpix)%w->upper_surf->h)*w->upper_surf->w];
|
uint8_t pixcolor = w->upper_surf->pixels[(int(v)%w->upper_surf->w)+(int(cpix)%w->upper_surf->h)*w->upper_surf->w];
|
||||||
pixcolor = colormap[pixcolor + int(light*31)*256];
|
pixcolor = colormap[pixcolor + int(light*31)*256];
|
||||||
@@ -449,7 +450,7 @@ void drawColumn(sector &s, int screen_column, int start, int end, float a_inc, v
|
|||||||
if (w->lower_surf)
|
if (w->lower_surf)
|
||||||
for (int i=0; i<lower_wall_height; ++i) {
|
for (int i=0; i<lower_wall_height; ++i) {
|
||||||
if (wall_end+i>=end) break;
|
if (wall_end+i>=end) break;
|
||||||
float light_dist = 1.0f - (dist>512 ? 1.0f : dist/512);
|
float light_dist = 1.0f - (dist>light_zoom ? 1.0f : dist/light_zoom);
|
||||||
float light = 1.0f - (light_dist*s.light);
|
float light = 1.0f - (light_dist*s.light);
|
||||||
uint8_t pixcolor = w->lower_surf->pixels[(int(v)%w->lower_surf->w)+(int(cpix)%w->lower_surf->h)*w->lower_surf->w];
|
uint8_t pixcolor = w->lower_surf->pixels[(int(v)%w->lower_surf->w)+(int(cpix)%w->lower_surf->h)*w->lower_surf->w];
|
||||||
pixcolor = colormap[pixcolor + int(light*31)*256];
|
pixcolor = colormap[pixcolor + int(light*31)*256];
|
||||||
@@ -470,8 +471,8 @@ void drawColumn(sector &s, int screen_column, int start, int end, float a_inc, v
|
|||||||
int tx = SDL_abs(int(actual_dist * SDL_cosf(angle*DEG_TO_RAD) + position.x)) % s.floor_surf->w;
|
int tx = SDL_abs(int(actual_dist * SDL_cosf(angle*DEG_TO_RAD) + position.x)) % s.floor_surf->w;
|
||||||
int ty = SDL_abs(int(actual_dist * SDL_sinf(angle*DEG_TO_RAD) + position.y)) % s.floor_surf->h;
|
int ty = SDL_abs(int(actual_dist * SDL_sinf(angle*DEG_TO_RAD) + position.y)) % s.floor_surf->h;
|
||||||
|
|
||||||
float light_dist = 1.0f - (actual_dist>512 ? 1.0f : actual_dist/512);
|
float light_dist = (actual_dist>light_zoom ? 1.0f : actual_dist/light_zoom);
|
||||||
float light = 1.0f - (light_dist*s.light);
|
float light = 1.0f - SDL_clamp(s.light-light_dist, 0.0f, 1.0f);
|
||||||
uint8_t pixcolor = s.floor_surf->pixels[tx+ty*s.floor_surf->w];
|
uint8_t pixcolor = s.floor_surf->pixels[tx+ty*s.floor_surf->w];
|
||||||
pixcolor = colormap[pixcolor + int(light*31)*256];
|
pixcolor = colormap[pixcolor + int(light*31)*256];
|
||||||
draw::putpd(screen_column, y, pixcolor, straight_dist);
|
draw::putpd(screen_column, y, pixcolor, straight_dist);
|
||||||
|
|||||||
Reference in New Issue
Block a user