From 138d9b616de68a525520aa32830839960e204007 Mon Sep 17 00:00:00 2001 From: "Skyth (Asilkan)" <19259897+blueskythlikesclouds@users.noreply.github.com> Date: Sun, 9 Feb 2025 13:16:03 +0300 Subject: [PATCH] Fix the Gaia Temple pedestal flashing black. (#334) --- UnleashedRecomp/patches/video_patches.cpp | 24 +++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/UnleashedRecomp/patches/video_patches.cpp b/UnleashedRecomp/patches/video_patches.cpp index d3ccb58..e57fcf2 100644 --- a/UnleashedRecomp/patches/video_patches.cpp +++ b/UnleashedRecomp/patches/video_patches.cpp @@ -113,3 +113,27 @@ PPC_FUNC(sub_8260BBF8) SetDefaultMaterialParameters(reinterpret_cast(base + PPC_LOAD_U32(PPC_LOAD_U32(ctx.r4.u32)))); __imp__sub_8260BBF8(ctx, base); } + +// The pedestal in Gaia Temple is placed on an opaque mesh slot, despite using additive blending. +// This somehow works. Except when the delta time is too stable, it flashes black for one frame. +// We can fix it by detecting the asset runtime, and swapping the mesh slots to transparent by hand. + +// Hedgehog::Mirage::CModelData::Make +PPC_FUNC_IMPL(__imp__sub_82E38650); +PPC_FUNC(sub_82E38650) +{ + if (ctx.r5.u32 == 0xBB90 && XXH3_64bits(base + ctx.r4.u32, ctx.r5.u32) == 0xB524C8C3B80C3F54) + { + // Mesh Count + std::swap( + *reinterpret_cast(base + ctx.r4.u32 + 0x18), + *reinterpret_cast(base + ctx.r4.u32 + 0x20)); + + // Mesh Offset + std::swap( + *reinterpret_cast(base + ctx.r4.u32 + 0x1C), + *reinterpret_cast(base + ctx.r4.u32 + 0x24)); + } + + __imp__sub_82E38650(ctx, base); +}