Room culling woes
First, some background. If you've ever ported a map from Majora's Mask to Ocarina of Time, chances are you've seen missing or de-loading map meshes if you get too close.
"What causes this?", you might ask yourself. Let's inspect the data in decomp and find out.
The negative numbers may catch your attention. I'm not certain why they are negatives. But lets try to substitute those for positive numbers and see if that see what happens.
Perfect, everything works now. Case closed. Except, not really. This doesn't fix them on a global basis. If you ported other maps, they would all need to be fixed to do this. This isn't an ideal fix in the long run.
Turns out, Majora's Mask actually handled room culling differently then Ocarina of Time. How different? Well, all the changes aren't exciting for what we need. Rather, I'll cut straight to the chase, as I did solve what actually does this.
In Ocarina of Time and Majora's Mask, there are meshs that use the RSP Culling radius. I inspected both Clock Tower's interior from MM and Hyrule Field from OOT as a way to tell what that was doing. Fast64 does not interp the negative numbers, rather, sets them to 0, which can also fix these, but again, we want a global method to this madness.
So what exactly does MM do that OOT doesn't? Simple answer: Extra Math
OOT only does the (-(f32)roomShapeCullableEntry->boundsSphereRadius < projectedPos.z, while MM does this under a var_fv1 (which in turn, is apart of the new else statement not shown), and the statment is ABS_ALT(roomShapeCullableEntry->boundsSphereRadius). However, what MM adds that OOT did not is ABS_ALT.
What is ABS_ALT, and what does that have to do with this? I'm glad you asked.
#define ABS_ALT(x) ((x) < 0 ? -(x) : (x))
This is some math. I don't know exactly what it does (math wasn't my strongsuit), but I know its doing some wicked stuff over a less then symbol. ABS_ALT does not exist in OOT.
"But Zelda! It does exist in OOT!" I hear Skawo cry, and yes, he is correct... only in the audio section on the latest decomp. 😆
(no offense to you Skawo!)
Base OOT does not have this, and hence, it must be added to make the new code work.
[Editors note: We use z64rom, and the specific forks from decomp for OOT (z64oot) and harbour masters for MM (z64mm). Thats why Skawo's comment is mentioned, as we are not using latest branch for either]
So because of the new ABS_ALT being used, it unlocks the usage for negative numbers... for whatever reason Nintendo wanted them to be used. And this works on the global case we need it to be, thus not only fixing ALL MM maps backported to OOT, but thanks to OOT map ports to MM years ago, I can safely say the code works as expected with all base-game maps!
In short, MM added extra math to work with negative numbers on the RSP Culling System. Why, is still the mystery, but the main issue plaguing us since the late 2000's and early 2010's is finally solved thanks to my efforts at digging.
I'd like to give my thanks to Z64me, who's Cylindrical Billboarding Woes page was used for some of the early text, and inspiration for how to write this blog post in general. And for him keeping me going with OOT after I got bored of it. With both topics solved, MM maps are perfectly rendering in OOT, with the additional bank system we've added to Z64rom to load scene textures from a specific bank for those maps. Few things that are far easier, are left to do! See you next time, modders! 😎









Comments
Post a Comment