michael-fadely / sadx-dc-lighting

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

Lighting issues in Chao Race #62

Closed PiKeyAr closed 7 years ago

PiKeyAr commented 7 years ago

Since the original SADX level ignores lighting altogether, this is an enhancement request of sorts.

In SA1, the Chao Race Entry is Act 1 of the Chao Race, while the actual Chao Race is Act 2. The entry loads PL1G0B.BIN, the actual race loads PL1G1B.BIN. While the Chao Race PL file loading works fine in the mod, it appears that the entry level is loading the Station Square garden's file (PL1D0B.BIN), which causes lighting inaccuracy in the restored SA1 Chao Race lobby. I tried loading a different PL file using a callback but it didn't work out.

If correct PL/SL file selection is implemented for Chao Race Entry, we could try the same trick we did with the gardens to see if the original SADX race entry looks any better with lighting.

When Chao Race Entry is loaded, the value for current Chao stage at 0x0339F87C equals 2.

michael-fadely commented 7 years ago

I've pushed a change that should correct the PL loading aspect, but it looks like the light direction is wrong.

PiKeyAr commented 7 years ago

Deleting SL1G1B.BIN has no effect on Chao Race but deleting SL1G0B.BIN affects light direction in both Entry and Race. So I guess it's light direction not updating properly when transitioning between stages?

Confirmed: when SL1G0B.BIN is replaced with something else, it affects both the entrance and Chao Race. Making SL1G0B identical to SL1G1B fixes the light direction issue in Chao Race (though obviously breaks it in the entry stage).

So it's just the light direction from SL1G0B being carried over to Chao Race.

michael-fadely commented 7 years ago

It looks like the Chao Race is quite lenient about its stage parameters. It applies its light direction once on load and doesn't touch it after that point. Problem is, this happens before the Chao stage number is set, so the level change hooks in place to handle palette/source switching don't get called in time. Consequently, the light direction, while it does get properly loaded from the SL file, never gets applied to the scene in the shader.

I've made light direction management a little more aggressive by always updating the shader parameter when the other light direction information is updated. Let me know if this works out.

PiKeyAr commented 7 years ago

Tried on the latest master. Still appears off, unfortunately. But now, even replacing SL1G0B with SL1G1B doesn't seem to fix it.

PiKeyAr commented 7 years ago

After the reversal, here's what it looks like: No files replaced: image SL1G0B replaced with SL1G1B image The last image is what it looks like in SA1.

PiKeyAr commented 7 years ago

Looks perfect now, thanks!

I've tried removing the ignore lighting flag on SADX Chao Race Entry materials, and it ended up looking too dark so I think it's best not to change it. The SA1 levels look great, so this can be closed.