mirror of https://github.com/sm64pc/sm64pc.git
Merge pull request #126 from HeavenVolkoff/gfx_use_second_light_color
Consider second color column of Light_t when calculating vertex colors
This commit is contained in:
commit
f5e73a099b
|
@ -572,9 +572,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;
|
||||||
|
@ -583,9 +589,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];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue