michael-fadely / sadx-dc-lighting

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

Native palette buffer #82

Closed PiKeyAr closed 2 years ago

PiKeyAr commented 2 years ago

This PR makes the mod use the game's leftover palette data array instead of storing palette pairs in LanternInstance. This enables integration with the game's own palette mixing code which is still functional: lig_convHalfBrightPalette (0x004123C0) reduces the brightness of all colors in a palette. It's used for the lights in Gamma's briefing cutscene. lig_fillOffsetPalette (0x00412180) fills a palette with a specific color. It's used in Casino when Sonic is transported to pinball stages. lig_supplementPalette (0x00412280) fills a palette with colors resulting from blending two other palettes. It's used by a debug object in Station Square called LightChanger. lig_cpyPalette (0x00412210) copies one palette to another. It's used for backing up and restoring the original palettes in Gamma's briefing cutscene. This function isn't hooked so if it's used on its own, palette atlas regeneration must be done manually.

More sophisticated effects can be created by using these functions in mods, though I suspect blending is going to be slower than with Lantern API.

Should be fully compatible with mods that already use the API.

michael-fadely commented 2 years ago

More sophisticated effects can be created by using these functions in mods, though I suspect blending is going to be slower than with Lantern API.

Yes, blending using the API should be preferred for mod developers unless they need something more complex than A-to-B blending. If the atlas texture is updated too frequently, it could end up causing performance problems due to the texture locking requirement.