michael-fadely / sadx-dc-lighting

Sonic Adventure 1 palette lighting for SADX PC.
MIT License
39 stars 3 forks source link

Mystic Ruins light direction #74

Closed PiKeyAr closed 5 years ago

PiKeyAr commented 5 years ago

I thought we'd figured this out for good, but... Here we go again. Up until now the assumption was that the light direction in SA1 Mystic Ruins ignores Y/Z rotation specified in the SL file, and its vector is therefore always { 0, -1, 0 }. The rotations specified in the SL file are indeed ignored. However, the light vector is still rotated. While investigating a related report, I found out that light direction in almost all parts of the Mystic Ruins is offset, sometimes very slightly so it's almost unnoticeable. After retrieving light rotations from memory I found out that it's hardcoded for all acts except Eggman's base. The values differ between acts and times of day. Here are all of them:

Main area/Act 0: Day 53760 63488, Night 22016 32, Evening 22016 8192
Angel Island/Act 1: Day 10752 64512, Night 22016 32, Evening 22016 8192
Jungle/Act 2: Day 31744 64512, Night 33280 65280, Evening 48128 11264

How to deal with this in the Lantern mod, I'm not sure. It has to be a code-based solution because there aren't enough SL files for MR to cover all rotations. Perhaps use the function referenced as "SkyBox_MysticRuins_TimeOfDayLightDirection" in the disassembly?

PiKeyAr commented 5 years ago

Turns out the code "Allow Dynamic Light Direction Globally" in the Mod Loader enabled this functionality in SADX. Looks like the rotation values are the same between SADX and SA1. I remember having to introduce a workaround because light direction was breaking at the Final Egg base, I think it may've been caused by the light direction being rotated before the rotation is reset while switching between acts. I'll post here if I catch it again.