From 8a363c2fc95159773122b442af841e4b6688fb64 Mon Sep 17 00:00:00 2001 From: water111 <48171810+water111@users.noreply.github.com> Date: Sat, 25 Feb 2023 17:55:55 -0500 Subject: [PATCH] [jak2] fix foreground light calculation (#2254) Fixes the abrupt change in lighting when walking around here ![image](https://user-images.githubusercontent.com/48171810/221382856-17f0ec18-1ce8-40f9-b65c-a59cf2d7d93f.png) --- game/graphics/opengl_renderer/foreground/Merc2.cpp | 8 ++++++++ goal_src/jak1/engine/gfx/foreground/bones.gc | 4 ++-- goal_src/jak2/engine/gfx/foreground/foreground.gc | 12 ++++++------ 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/game/graphics/opengl_renderer/foreground/Merc2.cpp b/game/graphics/opengl_renderer/foreground/Merc2.cpp index f3cd382a08..b456d5703e 100644 --- a/game/graphics/opengl_renderer/foreground/Merc2.cpp +++ b/game/graphics/opengl_renderer/foreground/Merc2.cpp @@ -449,6 +449,14 @@ void Merc2::handle_pc_model(const DmaTransfer& setup, // allocate lights u32 lights = alloc_lights(current_lights); + for (int i = 0; i < 3; i++) { + float debug_length = current_lights.direction0[i] * current_lights.direction0[i] + + current_lights.direction1[i] * current_lights.direction1[i] + + current_lights.direction2[i] * current_lights.direction2[i]; + if (debug_length > 0.01 && debug_length < 0.98) { + fmt::print("likely incorrect merc light direction {}\n", debug_length); + } + } // loop over effects, creating draws for each for (size_t ei = 0; ei < model->effects.size(); ei++) { diff --git a/goal_src/jak1/engine/gfx/foreground/bones.gc b/goal_src/jak1/engine/gfx/foreground/bones.gc index 67f88cfa65..2eae1687be 100644 --- a/goal_src/jak1/engine/gfx/foreground/bones.gc +++ b/goal_src/jak1/engine/gfx/foreground/bones.gc @@ -284,11 +284,11 @@ ) ) (.lvf vf9 (&-> arg1 dir1 levels quad)) - (let ((a3-1 (make-u128 t1-1 v1-0))) + (let ((a3-1 (the uint128 (make-u128 t1-1 v1-0)))) (.lvf vf6 (&-> arg1 dir2 color quad)) (.pcpyud v1-1 v1-0 t1-1) (.lvf vf10 (&-> arg1 dir2 levels quad)) - (let ((a2-2 (make-u128 (the-as int t0-1) a2-1))) + (let ((a2-2 (the uint128 (make-u128 (the-as int t0-1) a2-1)))) (.lvf vf7 (&-> arg1 ambi color quad)) (.mul.x.vf vf4 vf4 vf8) (.lvf vf11 (&-> arg1 ambi levels quad)) diff --git a/goal_src/jak2/engine/gfx/foreground/foreground.gc b/goal_src/jak2/engine/gfx/foreground/foreground.gc index 09bb4ab806..0904518752 100644 --- a/goal_src/jak2/engine/gfx/foreground/foreground.gc +++ b/goal_src/jak2/engine/gfx/foreground/foreground.gc @@ -414,12 +414,12 @@ ;; ???????? (let ((a3-0 (the-as uint128 (new 'static 'vector :x 1.0 :y 1.0 :z 1.0 :w 1.0)))) (nop!) - (let ((a2-0 (-> arg1 dir0 direction quad))) + (let ((a2-0 (-> arg1 dir0 direction quad))) ;; a2-0 = l0.dir (nop!) - (let ((t1-0 (-> arg1 dir1 direction quad))) + (let ((t1-0 (-> arg1 dir1 direction quad))) ;; t1-0 = l1.dir (nop!) - (.lvf vf4 (&-> arg1 dir0 color quad)) - (.pextlw v1-0 t1-0 a2-0) + (.lvf vf4 (&-> arg1 dir0 color quad)) ;; vf4 = l0.col + (.pextlw v1-0 t1-0 a2-0) ;; (let ((t0-0 (-> arg1 dir2 direction quad))) (.pextuw a2-1 t1-0 a2-0) (.lvf vf8 (&-> arg1 dir0 extra quad)) @@ -431,11 +431,11 @@ ) ) (.lvf vf9 (&-> arg1 dir1 extra quad)) - (let ((a3-1 (make-u128 t1-1 v1-0))) + (let ((a3-1 (the uint128 (make-u128 t1-1 v1-0)))) (.lvf vf6 (&-> arg1 dir2 color quad)) (.pcpyud v1-1 v1-0 t1-1) (.lvf vf10 (&-> arg1 dir2 extra quad)) - (let ((a2-2 (make-u128 t0-1 a2-1))) + (let ((a2-2 (the uint128 (make-u128 t0-1 a2-1)))) (.lvf vf7 (&-> arg1 ambi color quad)) (.mul.x.vf vf4 vf4 vf8) (.lvf vf11 (&-> arg1 ambi extra quad))