open-goal / jak-project

Reviving the language that brought us the Jak & Daxter Series
https://opengoal.dev
ISC License
2.79k stars 170 forks source link

[jak3] texture animations catch-all #3582

Open Hat-Kid opened 2 months ago

Hat-Kid commented 2 months ago

Most texture animations have been added and work, but a couple of issues still remain:

TomChapple commented 1 month ago

[!WARNING] I have very little experience here so it is likely I may be misinterpreting something.

On the topic of "hanga-sprite", I'm curious if "glider-ring-dest" should contain "glider-ring-dest2" within its texture data in that ImGui screenshot.

Looking at the dynamic data, "glider-ring-dest" refers to "glider-ring-dest2" in the first element (layer?). Each layer is interpolated, so it makes sense to me that it is pulling from this other animated texture. I'm tempted to compare this to the part "group-forest-ring", but there are some minor differences that look like it will act differently. Nevertheless, I haven't found a function call that will warp me to "foresta-ring-chase" to compare them.

TomChapple commented 1 month ago

Well I have something, but I'm not sure how relevant it is. Changing the source texture for layer 0 of "glider-ring-dest" to match the destination texture of "gilder-ring-dest2" (currently hardcoded) results in the animated texture being visible in-game as seen below.

Screenshot of Glider Ring in Jak 3 with incorrect hue

I got this effect with the following snippet:

diff --git a/game/graphics/opengl_renderer/TextureAnimator.cpp b/game/graphics/opengl_renderer/TextureAnimator.cpp
index 9025a6d..beb4a93 100644
--- a/game/graphics/opengl_renderer/TextureAnimator.cpp
+++ b/game/graphics/opengl_renderer/TextureAnimator.cpp
@@ -2526,8 +2526,15 @@ void TextureAnimator::run_fixed_animation(FixedAnim& anim, float time) {
           (time - layer_def.start_time) / (layer_def.end_time - layer_def.start_time),
           &interpolated_values, layer_dyn.start_vals, layer_dyn.end_vals);

+      // Force to 936
+      auto stex = anim.src_textures.at(layer_idx);
+      if (anim.def.tex_name == "glider-ring-dest" && layer_idx == 0) {
+        stex = 936;
+        lg::debug("forcing glider-ring-dest layer #0 source texture to {}", stex);
+      }
+
       // shader setup
-      set_up_opengl_for_fixed(layer_def, anim.src_textures.at(layer_idx));
+      set_up_opengl_for_fixed(layer_def, stex);

       set_draw_data_from_interpolated(&draw_data, interpolated_values, anim.fbt->width(),
                                       anim.fbt->height());

However, it can probably be seen that the hue is no where near as blue as it should be. Not only that, but the animation is awfully still in comparison with the original game. It's animated, but it is as if the intensities of the keyframes are incorrect in some regard. The "splash-foam" looks static for the most part.

The ID of the destination texture for "glider-ring-dest2" was 936 in my case, but I'm not sure if it changes depending on different loading patterns.

I have a feeling that something is intended to happen between writing to the destination texture in "glider-ring-dest2" and using the source texture in "glider-ring-dest", maybe some other form of interpolation to change the hues and intensities. But other than that, I hope this helps with any diagnosis!

TomChapple commented 1 month ago

I have been doing some thinking about the difference in hue from the little test I did and the vanilla game. When I look back at TextureAnimator, I didn't see any configuration for manipulating the texture's colour. The "gilder-ring-dest2" definitely takes advantage of this, even setting the blue component to about twice its usual value.

Has blending animated textures with colour been implemented? If it isn't, that would explain why the hue is off. I totally expect that I have missed it somewhere.

TomChapple commented 1 month ago

I was able to discover how colour blending is implemented, so I have answered my own question. I didn't realise that the static data was defined again in TextureAnimatorDefs.cpp but the dynamic data (including the colour) was loaded in from DMA. At least I now have a point of reference to go from.