From 452f1329ddda4c870aa9a61f50bcab12cc258528 Mon Sep 17 00:00:00 2001 From: water111 <48171810+water111@users.noreply.github.com> Date: Sat, 5 Oct 2024 12:53:57 -0400 Subject: [PATCH] [jak3] fix envmap texture and strength (#3704) Fix the envmap texture using the eye texture by default (will require a re-extract to fix), fix envmap strength in all three games being off by 2x. (oops) With envmap scale fix: ![image](https://github.com/user-attachments/assets/3b0ef8b7-cbdc-4402-8a12-af368538c16e) without envmap scale fix (but with texture fix): ![image](https://github.com/user-attachments/assets/fd72d75b-f0bb-455c-a7c9-56916fbd4a67) --------- Co-authored-by: water111 --- decompiler/level_extractor/extract_merc.cpp | 11 +++++++++-- game/kernel/jak3/kscheme.cpp | 2 -- goal_src/jak2/engine/gfx/foreground/foreground.gc | 3 ++- goal_src/jak3/engine/gfx/foreground/foreground.gc | 3 ++- 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/decompiler/level_extractor/extract_merc.cpp b/decompiler/level_extractor/extract_merc.cpp index 2a97ef17828..f5f5e1fa5d5 100644 --- a/decompiler/level_extractor/extract_merc.cpp +++ b/decompiler/level_extractor/extract_merc.cpp @@ -853,12 +853,19 @@ ConvertedMercEffect convert_merc_effect(const MercEffect& input_effect, u32 tidx = (env >> 8) & 0b1111'1111'1111; tex_combo = (((u32)tpage) << 16) | tidx; } break; - case GameVersion::Jak2: - case GameVersion::Jak3: { + case GameVersion::Jak2: { u32 tpage = 0x1f; u32 tidx = 2; tex_combo = (((u32)tpage) << 16) | tidx; } break; + case GameVersion::Jak3: { + // (define *generic-envmap-texture* (get-texture pal-environment-front environment-generic)) + // (defconstant environment-generic 2) tpage + // (def-tex pal-environment-front environment-generic 1) texture + u32 tpage = 2; + u32 tidx = 1; + tex_combo = (((u32)tpage) << 16) | tidx; + } break; default: ASSERT_NOT_REACHED(); } diff --git a/game/kernel/jak3/kscheme.cpp b/game/kernel/jak3/kscheme.cpp index 634d617ffbf..7a9d7c1efa3 100644 --- a/game/kernel/jak3/kscheme.cpp +++ b/game/kernel/jak3/kscheme.cpp @@ -1085,8 +1085,6 @@ u64 type_typep(Ptr t1, Ptr t2) { u64 method_set(u32 type_, u32 method_id, u32 method) { Ptr type(type_); - if (method_id > 255) - printf("[METHOD SET ERROR] tried to set method %d\n", method_id); auto existing_method = type->get_method(method_id).offset; diff --git a/goal_src/jak2/engine/gfx/foreground/foreground.gc b/goal_src/jak2/engine/gfx/foreground/foreground.gc index 03b010e83c3..649f2120ac0 100644 --- a/goal_src/jak2/engine/gfx/foreground/foreground.gc +++ b/goal_src/jak2/engine/gfx/foreground/foreground.gc @@ -1423,7 +1423,8 @@ ) (cond ((or (nonzero? (-> bucket-info must-use-mercneric-for-clip)) - (or (< 0.0 t-amount) (logtest? (-> geo effect effect-idx effect-bits) (effect-bits cross-fade))) + ;; force envmap mode, even if strength is zero - PC renderer will handle this case. + (or #|(< 0.0 t-amount)|# #t (logtest? (-> geo effect effect-idx effect-bits) (effect-bits cross-fade))) ) (let ((a0-33 (&-> tint-info tint)) (v1-74 (the-as object (-> bucket-info effect effect-idx))) diff --git a/goal_src/jak3/engine/gfx/foreground/foreground.gc b/goal_src/jak3/engine/gfx/foreground/foreground.gc index f3ff9fd9556..a5e7dbc702c 100644 --- a/goal_src/jak3/engine/gfx/foreground/foreground.gc +++ b/goal_src/jak3/engine/gfx/foreground/foreground.gc @@ -2102,7 +2102,8 @@ ) (cond ((or (nonzero? (-> bucket-info must-use-mercneric-for-clip)) - (or (< 0.0 t-amount) (logtest? (-> geo effect effect-idx effect-bits) (effect-bits cross-fade))) + ;; force envmap mode, even if strength is zero - PC renderer will handle this case. + (or #t #|(< 0.0 t-amount)|# (logtest? (-> geo effect effect-idx effect-bits) (effect-bits cross-fade))) ) (let ((a0-33 (&-> tint-info tint)) (v1-74 (the-as object (-> bucket-info effect effect-idx)))