Consider second color column of Light_t when calculating vertex colors

This commit is contained in:
Heaven Volkoff 2020-05-16 04:48:11 -03:00
parent de49bf1ac2
commit 1a3034898c
1 changed files with 18 additions and 7 deletions

View File

@ -570,9 +570,15 @@ static void gfx_sp_vertex(size_t n_vertices, size_t dest_index, const Vtx *verti
rsp.lights_changed = false; rsp.lights_changed = false;
} }
int r = rsp.current_lights[rsp.current_num_lights - 1].col[0]; // Inspired by:
int g = rsp.current_lights[rsp.current_num_lights - 1].col[1]; // https://github.com/gonetz/GLideN64/commit/c8cbafff71a81bee5112aaafe6e21d6648ff8125#diff-69d8715ec7f9fd627ec4f5516edd003dL484
int b = rsp.current_lights[rsp.current_num_lights - 1].col[2]; const bool useFirstColor = (dest_index & 1) == 0;
const unsigned char* col = useFirstColor
? rsp.current_lights[rsp.current_num_lights - 1].col
: rsp.current_lights[rsp.current_num_lights - 1].colc;
int r = col[0];
int g = col[1];
int b = col[2];
for (int i = 0; i < rsp.current_num_lights - 1; i++) { for (int i = 0; i < rsp.current_num_lights - 1; i++) {
float intensity = 0; float intensity = 0;
@ -581,9 +587,14 @@ static void gfx_sp_vertex(size_t n_vertices, size_t dest_index, const Vtx *verti
intensity += vn->n[2] * rsp.current_lights_coeffs[i][2]; intensity += vn->n[2] * rsp.current_lights_coeffs[i][2];
intensity /= 127.0f; intensity /= 127.0f;
if (intensity > 0.0f) { if (intensity > 0.0f) {
r += intensity * rsp.current_lights[i].col[0]; // Inspired by:
g += intensity * rsp.current_lights[i].col[1]; // https://github.com/gonetz/GLideN64/commit/c8cbafff71a81bee5112aaafe6e21d6648ff8125#diff-69d8715ec7f9fd627ec4f5516edd003dL492
b += intensity * rsp.current_lights[i].col[2]; col = useFirstColor
? rsp.current_lights[i].col
: rsp.current_lights[i].colc;
r += intensity * col[0];
g += intensity * col[1];
b += intensity * col[2];
} }
} }