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

Increase FOV when moving fast (Issue#716) #812

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

Tottel
Copy link

@Tottel Tottel commented Dec 4, 2024

Picked up this issue: #716

I added a smooth FOV transition when the player goes from walking to sprinting, and vice-versa.,

This is a draft PR, because I am unsure if:

  • The player should directly tell the renderer to change fov (as it does now), or
  • The renderer polls with the player what the current FOV modifier is (probably better?)

I think it should probably be the second, especially because the FOV vs FOVExtra in the renderer file is a little awkward.

Copy link
Member

@IntegratedQuantum IntegratedQuantum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that the second approach would be better, since it avoids the need for one extra variable.

I also looked through the rest of your code.

src/game.zig Outdated Show resolved Hide resolved
defer mutex.unlock();
return fovMod;
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just make fovMod atomic?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question: Why does it have to be atomic, when other, similar, variables (like eyeVel or eyePos) are not atomic either?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it's only ever used by the update and render functions, then you are right, it doesn't need to be thread safe.

src/game.zig Outdated Show resolved Hide resolved
src/game.zig Outdated Show resolved Hide resolved
src/renderer.zig Show resolved Hide resolved
src/renderer.zig Outdated Show resolved Hide resolved
src/renderer.zig Outdated Show resolved Hide resolved
@ikabod-kee
Copy link
Collaborator

I have a few issues with how FOV is handled in this PR:

  1. FOV should be based on the player's speed, not just if they're sprinting. Perhaps use a velocity threshold to determine when the player should start having their FOV changed.
  2. The player should gain FOV if they're facing the direction of their motion. (So if they're looking down while sprinting, there should not be any FOV change, as it just makes them look taller.)

Already, this commit is promising, and makes the game feel better! It just needs a different approach to implementation that can work in multiple scenarios, such as falling, flying, etc.

@ikabod-kee
Copy link
Collaborator

Also, if possible, you should add an option to lower the amount of FOV change, like how Minecraft has a slider.

@Tottel
Copy link
Author

Tottel commented Dec 14, 2024

I have a few issues with how FOV is handled in this PR:

  1. FOV should be based on the player's speed, not just if they're sprinting. Perhaps use a velocity threshold to determine when the player should start having their FOV changed.
  2. The player should gain FOV if they're facing the direction of their motion. (So if they're looking down while sprinting, there should not be any FOV change, as it just makes them look taller.)

Already, this commit is promising, and makes the game feel better! It just needs a different approach to implementation that can work in multiple scenarios, such as falling, flying, etc.

Thanks!

  1. I did it that way at first, but it became super disorienting, with the FOV changing all the time (even when falling from a block). I could consider a variation where we don't take the vertical speed into account?
  2. That makes sense!

@Tottel
Copy link
Author

Tottel commented Dec 14, 2024

Also, if possible, you should add an option to lower the amount of FOV change, like how Minecraft has a slider.

Sure, can add! I thought it would be a bit much to put that as a specific option, but it could be nice

@ikabod-kee
Copy link
Collaborator

  1. I did it that way at first, but it became super disorienting, with the FOV changing all the time (even when falling from a block). I could consider a variation where we don't take the vertical speed into account?

I do think that vertical speed should have a larger threshold, perhaps half of the terminal velocity so it doesn't change when you drop down a single block.

@ikabod-kee
Copy link
Collaborator

ikabod-kee commented Dec 14, 2024

Don't worry about motion sickness for now, we can always smooth things out with interpolation.

src/renderer.zig Outdated Show resolved Hide resolved
@Tottel Tottel marked this pull request as ready for review December 23, 2024 10:44

fn fovSpeedAddFormatter(allocator: main.utils.NeverFailingAllocator, value: f32) []const u8 {
return std.fmt.allocPrint(allocator.allocator, "#ffffffFoV Speed Widening: {d:.0}°", .{value}) catch unreachable;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not happy with the naming here. How do other games call this option?

Also the naming is inconsistent: The function is called fovSpeedAdd, the option is called speedFovAdd and the user sees FoV Speed Widening.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not happy with the naming here. How do other games call this option?

Also the naming is inconsistent: The function is called fovSpeedAdd, the option is called speedFovAdd and the user sees FoV Speed Widening.

Good point. I'll check what other games do as nothing comes to mind right now.

Not sure why I skipped over the naming inconsistencies. Will fix, thanks!

What do you think of the points brought up by Ikabod-kee? I imagine you have the final say, right? :D

@IntegratedQuantum
Copy link
Member

What do you think of the points brought up by Ikabod-kee? I imagine you have the final say, right? :D

Ikabod is good at explaining how these kind of things feels, and how they might be improved.
Now I'm mostly good at telling you how physically accurate it is, which is why I usually give Ikabod the last word when it comes to things like this.

In the current state of this PR I think the FOV transition feels weird and disorienting. Coupling FOV directly to velocity might help with this (furthermore it would fix the bug that your FOV still increases when running into a block).

But I don't think that this is capturing the essence of what this effect is supposed to do. It's not about conveying to the player how fast they are, in RL your FOV also doesn't change if you move faster. I think it's more about conveying the effects that you normally can't see, like the power level of the character or the acceleration force on your body.

If you think about it, FOV correlates with the distance between the eyes and the screen. So changing FOV is equivalent to moving the player head in relation to the screen, which is equivalent to acceleration, like if you sit in a car and the acceleration pushes you back in your seat.

So maybe it would be the most realistic to change FOV depending on acceleration in the direction of the camera, instead of velocity. Now I haven't seen any game that does it, but it might be worth a try?

@ikabod-kee
Copy link
Collaborator

Yeah, think about it like the wind blowing past you. :)

@Tottel
Copy link
Author

Tottel commented Dec 25, 2024

So maybe it would be the most realistic to change FOV depending on acceleration in the direction of the camera, instead of velocity. Now I haven't seen any game that does it, but it might be worth a try?

That sounds really cool, actually. I'll experiment a little. Thanks for all the input you two!

@archbirdplus
Copy link
Contributor

Yeah, think about it like the wind blowing past you. :)

Hm, I wonder if we could simulate the distortion due to the refractive index of air changing in front of your face due to compression.
On second thought, I haven't even seen that on spacecraft reentry so its going to be an entirely fictitious phenomenon.

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

Successfully merging this pull request may close these issues.

4 participants