NieRAutomata-LodMod
NieRAutomata-LodMod copied to clipboard
Improved distant LODs
Made a little progress improving the distance-LODs - game has two systems HighMapController & LowMapController that handle loading/unloading the high-detail/low-detail versions of the map, seems those systems are both inited with a "max count" of 7.
Found a way to increase the distance the HQ versions stay loaded in for (float at 0xF560A4), but since there's only room for 7 at once, and the HQ ones are staying loaded in for longer distances, this stops other HQ LODs from being loaded in (you end up pretty much running right up against the LQ LOD before game throws up a "Loading map..." message and slowly loads in the HQ stuff.) Looks pretty nice though, just not really playable atm :P https://slow.pics/c/Yd1UnR29 https://slow.pics/c/nKwmWW7K
Anyway seems the "max count" number can be changed pretty easily (which also needs the "HIGH FILE/VRAM" / "LOW FILE/VRAM" child-heap & parent-heap sizes updated)
But then there's a truly awful block of code at 0x815420 which uses an unrolled loop that's pretty much copy-pasted 7 times over, extending that would need variables moved around & stack space increased & probably more things, easily over ~30 patches... and then there's the LowMapController version of that code at 0x8159A0 with the same unrolled copy-pasted 7 times issue, so this weird variable moving fix would need to be done twice :(
Even then I'm not 100% sure if this will actually improve it or not though... I do know at least that changing this "max count" number to 1 does make the game show far less HQ buildings at once, but changing it to say 14 still only makes the game process 7 at most, testing showed the loops I mentioned being responsible for it not going above 7.
Will probably try looking at it again soon, but figured these findings are still worth writing down somewhere.
(E: looking at NA debug EXE, the loops are pretty normal there, none of this unrolled/copy-pasted crap... maybe will have to see if I can reimplement that somehow)
(E2: ah fug, seems the two MapControllers also store two static vect4[7] arrays inside them (+0x80), even though they used a vector sized to the "max count" I mentioned, they hardcoded these arrays to 7... even more crap that'd need to be patched & redirected ;_;)
E3: many hours later and I seem to have something working, so far added 8 extra LOD slots, which increases the distance a lot without even needing to change the float I mentioned above.
For every slot I have to find out the coordinates for it manually though, game uses some weird diagonal coordinates or something, haven't found a way to calculate the coords for each slot (the game does calculate the coords for distance = 1 at 0x7C7433, but that doesn't work for distance = 2... something something dot product something something "shufps xmm3, xmm2, 0x55 0xCC 0xC6" ;-;) There's 8 more slots I need to add to fully cover distance = 2, ugh E4: oh, after 18 slots there's not enough room in graphics heap for more, heap only goes up to 0xFFFFFFFF bytes atm, hoping it'll maybe let me use int64 for size instead.