michael-fadely / sadx-dc-lighting

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

Palette selection for character models #11

Closed PiKeyAr closed 7 years ago

PiKeyAr commented 7 years ago

It appears that player models in the Dreamcast version use the third base palette (5) and the third specular (6) in most cases, however there are some exceptions. Tails' shoes and jumpball use specular 4 (8), same for most of E102 Gamma's body. There seems to be a correlation between the "ignore specular" material flag in character models and palette selection. In addition, certain parts of character models (Gamma's eyes etc.) have the "ignore lighting" flag, which makes them glow in the dark.

Therefore, base and specular palette selection for character models should be as follows: Base palette: always use base 3 (5) Ignore lighting on - not palettized Ignore lighting off, ignore specular on - use specular 3 (6) Ignore lighting off, ignore specular off - use specular 4 (8)

michael-fadely commented 7 years ago

I'm hoping to have at least the character palette selection done before release.

michael-fadely commented 7 years ago

Added the character specular selection changes. Unfortunately though, SADX Sonic's materials seem to be weirdly configured, so his jump ball uses the wrong palette. This can be fixed, though.

michael-fadely commented 7 years ago

Character materials have been corrected as of c0031beba7d5f366fedeb46cc457171e0d2e6fb6, so now all characters should have the correct palettes selected. Nothing on bosses yet.

PiKeyAr commented 7 years ago

A couple of things I overlooked: Material 00012048 (Amy's hairband) should ignore specular, not ignore lighting. Material 0011A080 (Big's belt buckle without upgrades) should also ignore specular. Materials 0011E8E0 and 0011E718 (Big's fishing coil without upgrades) also ignore specular. Looks accurate apart from these three.

michael-fadely commented 7 years ago

Should be fixed in 2f9a67ab2f2a9b91227c190893647122b25f5064

michael-fadely commented 7 years ago

Considering this fixed!

michael-fadely commented 7 years ago

oops I broke it

michael-fadely commented 7 years ago

I've just pushed a commit to help with the recent breaking of everything. Using the debug functions included in that commit, I can identify all instances where materials need to be updated based on patterns of texture IDs. By doing it this way, we can avoid setting values every frame that only realistically need to be set once.

That being said, let me know if it's closer to your original implementation now.

PiKeyAr commented 7 years ago

As of 1.0.21, it's a lot closer but there are still a few things:

(edited to make it a checklist --SF94)

michael-fadely commented 7 years ago

Latest commit should address those issues.

Unless something else comes up, here's what needs to be done to consider this fixed:

michael-fadely commented 7 years ago

I guess this is fixed!

PiKeyAr commented 7 years ago

I noticed a few lighting differences while messing with the API, and they seem to affect the latest release version as well. I suggest reopening this.

Here's the test specular palette I was using: image

(left is SA1, right is SADX)

  1. Amy's hairband - should use a higher specular index image

  2. Big (with upgrades) shoes and fishing rod use stage specular for some reason image

  3. Gamma (with upgrades) Jet Booster and laser reticle should be using object specular, and the base of the reticle should use the level specular image

  4. Gamma's chest is using object specular, while it should be using the second character specular image

  5. Big (no upgrades) belt buckle and shoes image

  6. Gamma (no upgrades) trigger I guess. I'm not sure which specular it is, but it looks like it just isn't applied at all. I've confirmed the last two (unused) specular sections in the PL file aren't involved in this. image

  7. Birdie should use stage specular image

PiKeyAr commented 7 years ago

One more thing. When fighting Chaos 4, the moment it switches control to Sonic, the character's specular palette gets replaced with level specular. It only happens in Chaos 4 and only with Sonic, so this might be something SADX does on purpose (it doesn't happen in SA1 though). This also occurs on pre-API builds of the PL mod. I think the best way to avoid things like these is to hardcode palette indices for characters. Perhaps doing all characters using the API would work.

PiKeyAr commented 7 years ago

Here's a bunch of arrays and functions to fix character and boss materials using the API. This isn't meant to replace the FixCharacterMaterials thing, instead it can be integrated into it or if FixCharacterMaterials is rewritten to use the API they can be merged. materialfixes.txt

PiKeyAr commented 7 years ago

bool SpecialBossFunction(NJS_MATERIAL* material, Uint32 flags) { set_diffuse(4, false); set_specular(5, false); use_default_diffuse(true); return true; }

bool Chaos2Function(NJS_MATERIAL* material, Uint32 flags) { if (CurrentLevel == 16) { set_diffuse(4, false); set_specular(5, false); } else { set_diffuse(2, false); set_specular(3, false); } use_default_diffuse(true); return true; }

michael-fadely commented 7 years ago

👍