nipkownix / re4_tweaks

Fixes and tweaks for the "UHD" port of Resident Evil 4
zlib License
340 stars 33 forks source link

Lighting #523

Open TommvinHuwaltzky opened 1 year ago

TommvinHuwaltzky commented 1 year ago

Heya!

First, thanks for the fixes, obviously. Just started replaying the game (since I don't wanna fund Denuvo-cancer by buying the remake) with RE4HDP and re4fixes, and it's pretty neat! Hard though, because Leon takes more damage at 60FPS I believe. Or I'm just bad. Prolly the latter :P

So, my question is: Would it be possible to implement per-pixel-lighting for the flashlight? Similar to how Silent Hill 2 changed from per vertex on PS2 to per pixel on PC (one of the only improvements that port made...)? Just wondering, since I just got to the dark, rainy part after the boat, and the inaccurate lighting is pretty obvious.

Oh yeah, and two other things: Leon's and Ashley's hair will blow even in indoor-areas. Seems the parameters for that are applied globaly. Could that be changed? And the most-important thing: What about Ashley's jiggle? It was on the GC US-version, they toned it way down for GC JAP and EU, and removed it completely on PS2 and PC. They brought it back to the level of GC JAP for "Ultimate HD", which is a port of X360/Wii if I'm not mistaken. For scientific reference (and the furtherment of all mankind): https://youtu.be/KlPr6TeNQRY?t=12 THIS IS IMPORTANT FOR IMMERSION, PLOT, AND THE TEGRIDY OF MIKAMI SHINJI'S ORIGINAL VISION! :'D I'm kinda joking. Still curious.

Klemci commented 1 year ago

The jingle thing as i watched on video (US) is unreal... or a dev's joke.

emoose commented 1 year ago

Huh didn't realize they toned down Ashley there, just had a quick look and seems they did add some code to switch out the ballistics on the gondola ride/boat:

cPlAshley::moveBust:

  if ( (pG->SaveWk_4F90.Flags_STATUS_1_90[0] & STA_PL_BOAT) != 0
    || (pG->SaveWk_4F90.Flags_STATUS_0_8C[0] & STA_RIDE_GONDOLA) != 0 )
  {
    // values on boat/gondola
    BYR = 18;
    BYW = 1.5;
    BYT = 11.0;
  }
  else
  {
    // normal values
    BYR = 20;
    BYW = 7.0;
    BYT = 5.0;
  }

None of that was present in the NTSC GC debug build at least, also those BYR/BYW/BYT values were a little different in NTSC debug, looks like that would always use BYR = 15, BYW = 6.0, BYT = 11.0.

Really looking at that video changing this was probably a good call, but if someone really wants to try restoring it you can maybe use cheat engine and change the following (addrs for 1.1.0): bio4.exe+351024 (2 bytes) = 37008 bio4.exe+35102D (2 bytes) = 37008 bio4.exe+357CC4 (2 bytes) = 37008 bio4.exe+357CCD (2 bytes) = 37008

That would remove the gondola/boat checks at least but doesn't restore the other BYW etc values (the data for those values is shared with some other code so isn't as easy to change)

About per-pixel lighting, it'd be a little difficult because of the way they're emulating the original Gamecube graphics code here, apparently if you play the GC version in Dolphin you can enable a per-pixel hack which works pretty well, so maybe something similar to how that hack works could be added here eventually.


E: hmm, just tested this myself and didn't actually notice much difference with it (even if I patched those BYW values), maybe there's some other checks added elsewhere too.

E2: ah that was just for the player version cPlAshley, cSubChar also has the same code added to it too, added addrs for that above.

Seems changing that does make a pretty large difference on the gondola, I only tested it in 30FPS mode though, code there might also need adjustment for 60FPS but not sure.

albertre4HD commented 1 year ago

Per pixel lighting is one of my wet dreams for this game XDD

TommvinHuwaltzky commented 1 year ago

Was just playing the Ashley-section yesterday, and I think there is some movement of the balistics there as well. Wanted to test/compare it with the US GC-version on Dolphin (it is true though that the emulator has a setting for "per-pixel-lighting" in the options, but as I didn't play the game, I didn't have a look at it), but didn't have any save-games, and couldn't be bothered to play through the game again. Especialy with a controler. Ew.

So, could those...uh..."fixes" be implemented into re4_tweaks? As a laugh, of course :-3 And I dunno if I can test it with Cheat-Engine, since I have version 1.0.6.

only tested it in 30FPS mode though, code there might also need adjustment for 60FPS

Haha yeah, so at 60FPS it could either still run at 30FPS (like fire/water for example), or go totaly nuts and run at double-speed like some other stuff :D

@albertre4HD Per-pixel-lighting is one of my wet dreams for this game

I know, right? :D

emoose commented 1 year ago

Well here's a build that can force it to override with the orig NTSC values, so gondola/boat checks are made redundant, and should make physics closer to NTSC during normal gameplay too (seems it works fine at 60FPS too)

Haven't tested too much yet though, also only tried it with 1.1.0 so far. There's no UI option or anything for it atm neither, will just always be enabled if you're using the build: dinput8-ballisticsFix.zip (extract the DLL from that on top of your re4_tweaks 1.9.1 install)

Maybe will look into adding UI settings & seeing about PRing it later on, after all this does help restore original content... 😅

Code for anyone interested:

// Optional patch to restore original NTSC values to cPlAshley::moveBust & cSubChar::moveBust
// Later releases slightly changed the values used, and also added checks to reduce values even further when inside gondola/boat
// This hook just forces it to always use the values NTSC used, overriding any values set by those gondola/boat checks
{
    auto pattern = hook::pattern("D9 5D EC E8 ? ? ? ? 8D 88 88 00 00 00");

    // Hook
    struct AshleyNTSCValuesFix
    {
        void operator()(injector::reg_pack& regs)
        {
            if (re4t::cfg->bUseAshleyNTSCValues)
            {
                // Values used in initial NTSC release
                const uint8_t BYR = 15;
                const float BYW = 6.0;
                const float BYT = 11.0;

                // Overwrite any values that func had set previously
                *(float*)(regs.ebp - 0x18) = BYW;
                *(float*)(regs.ebp - 0x14) = BYT;
                regs.ebx = BYR;
            }

            // Code that we overwrote
            regs.ecx = regs.eax + 0x88;
        }
    };

    // cPlAshley::moveBust
    injector::MakeInline<AshleyNTSCValuesFix>(pattern.count(2).get(0).get<uint8_t>(8), pattern.count(2).get(0).get<uint8_t>(14));
    // cSubChar::moveBust
    injector::MakeInline<AshleyNTSCValuesFix>(pattern.count(2).get(1).get<uint8_t>(8), pattern.count(2).get(1).get<uint8_t>(14));
}
TommvinHuwaltzky commented 1 year ago

after all this does help restore original content...

What else did you think my intention was...? :-3

Sooo, in normal gameplay nothing has changed (again, would hafta compare it to GC US), but on the "lift" the balistics actualy do their American thing. But they do seem to still update at 30FPS (much like the other effects like fire/certain reload-animations when set to 60).

Haha, it's a start I guess. We're getting closer and closer to conformity with the GC here :P

emoose commented 1 year ago

It looks like it's running at 60 fine for me, maybe not as smooth as it could be though.

Do you have the FixAshleyBustPhysics setting enabled in Frame rate section? That was added a while ago to help fix some 60fps stuff around it.

E: hm, just noticed there is one framerate change inside cSubChar::moveBust which is missing from cPlAshley::moveBust, which isn't fixed by FixAshleyBustPhysics atm... Not sure if that might be the cause of what you saw though, since that would only affect ashley as player character AFAIK.

E2: ah interesting, if I copy that missing change from cSubChar into cPlAshley, when playing as Ashley it seems to make physics much less noticable at 60, but changing back to 30 lets them work fine. If I remove this change then physics seems pretty much identical between them, for playable ashley at least. Maybe this change they made in the follower-Ashley code is actually incorrect then, and removing it could let her match between them...

emoose commented 1 year ago

Here's another build which removes that bad cSubChar framerate code, @TommvinHuwaltzky could you see if this makes 60 feel any better for you? To me it looks like 30/60 both run at exact same speed now (but 60 runs smoother since it's higher fps of course)

dinput8-ballisticsFix2.zip

That also includes the NTSC values like the earlier build as well.

TommvinHuwaltzky commented 1 year ago

Do you have the FixAshleyBustPhysics setting enabled

Oh wow, didn't even notice that setting on my initial setup through the .ini before starting the game. But yeah, seems to be enabled by default.

Now here's the weird thing: I just replayed the section where you control Ashley, and with the "regular" dll the "swaying" is stronger than with your new one. I compared the two dlls, and even took short videos. So yeah, kinda at a loss. Lift-ride seems to be on the GC-level with your fix, but the gameplay is somehow toned down now. Some mix-up of the parameters?

Here's another build

Ah ok, while typing a reply you posted this. Gonna give it a try.

TommvinHuwaltzky commented 1 year ago

Hm, weird...... So the lift-ride is working, and smooth at that (at 60FPS) with your v2.

But when you control Ashley, it's still less compared to the initial 1.9.1.0. Took 2 video-clips again and compared, as a sanity-check.

When she's a companion, the movement is not as pronounced as on the lift, but one would have to compare it to the GC-version if it even should be the same as on the ride in the first place, or if they just exaggerated it for that scenario only.

emoose commented 1 year ago

Guess it might be the value changes, the NTSC ones we're forcing do seem lowered slightly at least, don't really know what these affect yet, but could maybe explain the reduced movement when controlling her:

NTSC: BYR = 15, BYW = 6.0, BYT = 11.0

UHD (normal) BYR = 20, BYW = 7.0, BYT = 5.0

UHD (boat/gondola) BYR = 18, BYW = 1.5, BYT = 11.0

Maybe it'd be better to just patch the boat/gondola checks along with the cSubChar fix from last build, but keep the UHD (normal) values above instead of using NTSC ones.

Here's a version that has it like that: dinput8-ballisticsFix3a.zip

TommvinHuwaltzky commented 1 year ago

Huh, so now the movement while controling Ashley and when she's a companion is restored, but on the gondola "they" now move at twice the speed... :-o

alascokevin1 commented 1 year ago

Questions:

  1. If you guys fix what TommyvinHuwaltzky mentioned on gondala, would you please tell the creator of tweaks to add these fixes on the later updates.

  2. As of now, is dinput8.dll that you guys did version is for 1.9.1? If so, would this apply to all previous versions and the later version?

TommvinHuwaltzky commented 1 year ago

Sooo, been playing through the game again with fix version 3(a?), and when you control Ashley/when she's a companion , "the movement" seems to be just like on the GC US. But yeah, on the gondola-ride, "they" are sped up now. Was fine (and smooth; like GC US as well) in version 2. So seems the values have to be a combination of fixes v2 and 3?

@alascokevin1 Yeah, leave the rest of the files, and just replace dinput8.dll.

alascokevin1 commented 1 year ago

Here's my theory, why not adjust from NTSC: BYR = 15, BYW = 6.0, BYT = 11.0

UHD (normal) BYR = 20, BYW = 7.0, BYT = 5.0

UHD (boat/gondola) BYR = 18, BYW = 1.5, BYT = 11.0

to this one:

NTSC: BYR = 15, BYW = 6.0, BYT = 8

UHD (normal) BYR = 20, BYW = 6.0, BYT = 5.0

UHD (boat/gondola) BYR = 15, BYW = 6.0, BYT = 8

Correct me if I'm wrong

TommvinHuwaltzky commented 1 year ago

I have no clue how to inject code or to dis/re-assemble a .dll. So that would still hafta be done by @emoose