Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Binocular zoom has almost no blur when using mousewheel #45

Closed
emoose opened this issue Jan 25, 2022 · 13 comments
Closed

Binocular zoom has almost no blur when using mousewheel #45

emoose opened this issue Jan 25, 2022 · 13 comments

Comments

@emoose
Copy link
Collaborator

emoose commented Jan 25, 2022

Some reason using mouse scrollwheel to zoom the binoculars only results in very minor blurring, while controller has a much stronger effect, must be something to do with how the mousewheel zoom was implemented - seems mousewheel makes it snap to different zoom levels, while controller stick lets it go smoothly between them.

I guess blurring effect is kept active while controller is going between them until controller stick is released, while with mousewheel maybe it's being treated as "released" as soon as it's snapped to a level, not really sure how much could be done to improve this, if anyone has any ideas please let me know.

@nipkownix
Copy link
Owner

nipkownix commented Jan 25, 2022

It is the call to FocusAnimation::move at the end of CameraScope::move.
That section is testing for some value to know whether the focus should be happening or not.
It seems that, with a controller, the value it is testing against gets enabled as soon as you push the stick and stays on for a set period of time, regardless of whether or not you're still holding the analog stick in position.
With the mouse, that value resets as soon as the wheel completes a "cycle", so that's why the focus animation stops quickly and we end up with a softer effect.

Haven't found a clean way to improve this yet. Hmm.

@emoose
Copy link
Collaborator Author

emoose commented Jan 25, 2022

Looks like the value being tested in CameraScope::move is something time related, at least it seems to do something with pG->deltaTime to set it earlier in the func, while I think the second param to FocusAnimation::move is a bool to enable/disable the effect.

Could be that the time value is only being changed when controller is used, letting it countdown & stay active after it's released, while kb/m doesn't update it, so the effect is disabled almost instantly, not sure though.

@emoose
Copy link
Collaborator Author

emoose commented Jan 26, 2022

Seems part of the code that used pG->deltaTime multiplies something against 0xC63011, that byte seems to be RS Y axis as a signed int8, looks like there's a deadzone there before the value changes and game zooms the screen & applies blur.

The KB+M code also seems to change that 0xC63011 byte, but for some reason the byte only changes when scrollwheel is changed a lot, small changes don't seem to affect the byte, but do still zoom in the screen.

Kinda seems like there might still be some deadzone applying to scrollwheel which makes it so that only large scrollwheel changes actually get used to calculate blur strength, but not sure how zoom still gets applied though.

@nipkownix
Copy link
Owner

Added something that appears to be working pretty nicely in 04400fc.

Let me know what you think.

@emoose
Copy link
Collaborator Author

emoose commented Jan 26, 2022

Hm, I think there's an improvement there, but it still doesn't seem to apply the blur in some cases, eg. I'd expect 1 click of the mouse-wheel to zoom it in & apply slight blur while it happens, but doesn't seem any blur is applied at all, only seems to apply blur when I move scrollwheel a bunch of clicks at once.

Controller on the other hand seems to apply blur no matter how little you push it, the zoom factor on the side also goes up in smaller steps with controller, maybe related to it somehow:

Here's an example with controller with very light stick movement:

ctrl2.webm.mp4

and with mouse, trying to move it at around the same speed (I messed up encoding so it might look like blur is applied here, but there wasn't any blur at all)

mouse.webm.mp4

You can also see there how the zoom count is increasing by 1 with controller there too, while mouse seems to be doubling it each time or something.

@nipkownix
Copy link
Owner

Hmm, the sniper rifle has smaller zoom steps, so the fix does look better there, but a single scroll of the mouse wheel is indeed not triggering the effect. Hmm.

@emoose
Copy link
Collaborator Author

emoose commented Jan 27, 2022

Ohh I just realized your fix is FixSniperZoom, but I'm testing with binoculars, looks like binoculars has its own CameraBinocular::move function which is similar to CameraScope::move, maybe binoculars would also need another hook in place for that func too.

E: oh nvm, looks like your hook is for FocusAnimation::move which both binocular & scope make use of.

@nipkownix
Copy link
Owner

E: oh nvm, looks like your hook is for FocusAnimation::move which both binocular & scope make use of.

Yeah, that's right. I assumed the result would end up looking similar for both of them, but the binocular one needs less "scrolls" to move faster.
Haven't found out excatly why fewer scrolls don't trigger the effect :/

@emoose
Copy link
Collaborator Author

emoose commented Jan 27, 2022

Added some extra structs & names around the CameraBinocular/CameraScope/FocusAnimation etc classes to latest IDB, hopefully might help with looking into it: emoose/re4-research#1 (comment)

@emoose
Copy link
Collaborator Author

emoose commented Jan 28, 2022

The code around 0x9692AB seems to be what converts scroll-wheel into RS input, the push 7F there is basically setting RS as 0x7F (fully pressed up), while 0x9692D6 sets it as -0x7F (fully down), looks like that value is passed to some min/max function to make sure it's between -0x7F-0x7F (which seems pointless since it's hardcoded...), then stored at 0xC63011 signed byte.

Halving the values it pushes there makes the bino zoom in much smaller steps, but blur doesn't really seem affected... seems this is maybe only converting it to the RS input for a single frame, and maybe blur code wants it to have several frames of input, might explain why scrolling multiple clicks allows blur to be activated too, since those would let the RS input get changed for more than 1 frame.

Maybe the focus animation works by fading in the blur over several frames, then fading it out when RS is released - since this is only setting RS for a single frame per wheel click, could be that blur never got faded in enough for it to be visible at all.

Two ways I can think of to fix it, either see if FocusAnimation stuff can be changed so that it sets itself to full blur on every change (would probably need to make this KB/M only I'd guess), or change the wheel->RS code so that it changes RS over a number of frames instead of just once (if we're lucky maybe this could make the scope actually "zoom" in naturally when using wheel too, instead of snapping to each position)

@nipkownix
Copy link
Owner

nipkownix commented Jan 28, 2022

Added some extra structs & names around the CameraBinocular/CameraScope/FocusAnimation etc classes to latest IDB, hopefully might help with looking into it: emoose/re4-research#1 (comment)

Ah, thank you!

Hmm, I think I have an ugly workaround in mind. Let me see if it works properly.

Edit: okay, seems to be working fine with both CameraBinocular and CameraScope now.

My workaround is basically making the game play the focus animation for at least X ammount of time, so it doesn't end too soon.

Let me know if 96d176d solves this once and for all :p

@emoose
Copy link
Collaborator Author

emoose commented Jan 29, 2022

Wow that works great, excellent work! Pretty much how I hoped it would be.

I do still wonder about making the wheel->RS work over multiple frames though, instead of snapping to each position, might try looking into that some time, for now I guess this issue is fixed though :)

@emoose emoose closed this as completed Jan 29, 2022
@nipkownix
Copy link
Owner

I also have another of my ugly hack ideas to smoothen the zoom with the mouse.
I'll let you know if it works decently enough.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants