Skip to content

Commit

Permalink
[jak3] Fix alpha for prims, entity-table (#3609)
Browse files Browse the repository at this point in the history
Fix issue where light-trail is invisible and some actors not spawning
due to out of memory.
  • Loading branch information
water111 authored Jul 27, 2024
1 parent 3856ae5 commit 9d00097
Show file tree
Hide file tree
Showing 8 changed files with 513 additions and 275 deletions.
27 changes: 26 additions & 1 deletion decompiler/config/jak3/all-types.gc
Original file line number Diff line number Diff line change
Expand Up @@ -25908,8 +25908,33 @@
:flag-assert #xe00000010
)

;; doesn't exist, but referenced by type ref in the entity table.
(deftype sail-boat-a (process-drawable-reserved)
()
)

(deftype cty-window-a (process-drawable-reserved)
()
)

(deftype city-window-a (process-drawable-reserved)
()
)

(deftype cty-guard-turret (process-drawable-reserved)
()
)

(deftype cty-fruit-stand (process-drawable-reserved)
()
)

(deftype torn (process-drawable-reserved)
()
)

(deftype entity-info (basic)
((ptype type :offset-assert 4) ;; guessed by decompiler
((ptype object :offset-assert 4) ;; guessed by decompiler
(pool symbol :offset-assert 8) ;; guessed by decompiler
(heap-size int32 :offset-assert 12)
)
Expand Down
2 changes: 1 addition & 1 deletion game/graphics/opengl_renderer/foreground/Generic2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,10 @@ void Generic2::render_in_mode(DmaFollower& dma,
auto p = prof.make_scoped_child("setup");
switch (mode) {
case Mode::NORMAL:
case Mode::PRIM:
setup_draws(true, true);
break;
case Mode::LIGHTNING:
case Mode::PRIM:
setup_draws(false, true);
break;
case Mode::WARP:
Expand Down
10 changes: 10 additions & 0 deletions game/graphics/opengl_renderer/foreground/Generic2_Build.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,16 @@ void Generic2::determine_draw_modes(bool enable_at, bool default_fog) {
current_mode.set_alpha_fail(reg.afail());
current_mode.set_zt(reg.zte());
current_mode.set_depth_test(reg.ztest());

// detect a strange way of disabling z writes by light-trail.
// we don't actually handle alpha_fail later on in Direct - it doesn't map well to modern
// graphics and would require a draw call per primitive.
if (current_mode.get_alpha_fail() == GsTest::AlphaFail::FB_ONLY &&
current_mode.get_aref() == 0x80 &&
current_mode.get_alpha_test() == DrawMode::AlphaTest::GEQUAL) {
current_mode.set_alpha_test(DrawMode::AlphaTest::ALWAYS);
current_mode.disable_depth_write();
}
}

m_adgifs[i].mode = current_mode;
Expand Down
2 changes: 1 addition & 1 deletion goal_src/jak3/engine/entity/entity-h.gc
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ that gets accessed by the accompanying process."
(set! (-> actor-group heap-base) (the-as uint 8))

(deftype entity-info (basic)
((ptype type)
((ptype object)
(pool symbol)
(heap-size int32)
)
Expand Down
Loading

0 comments on commit 9d00097

Please sign in to comment.