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

feat(code): Gentling the Zoom #10087

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

Conversation

Zitchas
Copy link
Member

@Zitchas Zitchas commented May 20, 2024

Bug fix
Currently, players can add their own zoom values as desired. If they happen to enter values that are significantly farther out than the defaults, the starscape and haze start to tile significantly and look increasingly terrible; and the game performance drops massively. On some machines this may even be able to crash or freeze the game, but that's just speculative. If nothing else, it renders the game unplayable and ugly.

Summary

This is both a safety and aesthetic factor in the form of a check to see if the zoom is below 0.35, and if so convert the baseZoom through a formula that reduces how much it will zoom out. This process gives increasingly slow returns that smoothly slows down how fast the background will zoom out; but has no effect on any in-game elements

Zooming farther out than 0.35 results in a diminishing return. Meaning the starfield and haze don't zoom out as fast, and prevents significant amounts of tiling even at extreme distances.

This effectively allows players greater freedom to use whatever zoom values they want without risk of creating unplayable (or ugly) gameplay.

Screenshots

Current vanilla out somewhere around 0.011 zoom: (Yes, this is a ridiculously far out zoom, even for me.)

Vanilla going to extreme zooms

WIth this PR at somewhere close to the same zoom:

Vanilla (with PR) going to extreme zooms

Testing Done

Played the game with extreme zoom values.

Test values used

To test this, here's a set of zoom values you can use. Just copy it into your interfaces.txt file overwriting the current interface "main view" item.

interface "main view"
	list "zooms"
		.008
		.009
		.011
		.013
		.016
		.019
		.022
		.026
		.031
		.037
		.044
		.053
		.063
		.074
		.088
		.105
		.125
		.149
		.177
		.21
		.25
		.30
		.35
		.42
		.5
		.59
		.71
		.84
		1.
		1.19
		1.41
		1.68
		2.
		2.38
		2.83
		3.36
		4.
		4.76
		5.66
Vanilla zoom values for comparison
interface "main view"
	list "zooms"
		.25
		.35
		.5
		.7
		1.
		1.4
		2.

Save File

Any pilot

Performance Impact

This will significantly reduce the performance impact for players using custom zoom values.

On my computer, this is the difference between 2541% GPU usage, and <50% GPU usage out at zoom values of 0.011.

For vanilla players it will have a slight impact on the furthest-out zoom, as that level is the only one that is far enough out to meet the criteria; and the effect is minor.

This is both a safety and aesthetic factor.

Zooming farther out than 0.35 results in a diminishing return. Meaning the starfield and haze don't zoom out as fast, and prevents significant amounts of tiling even at extreme distances.

On my computer, this is the difference between 2541% GPU usage, and <50% GPU usage out at zoom values of 0.011
@Zitchas Zitchas added bug Something in the game is not behaving as intended mechanics Things dealing with the mechanics & code of how the game works labels May 20, 2024
@Zitchas Zitchas requested a review from a team May 20, 2024 11:54
@RisingLeaf
Copy link
Contributor

I have to disagree with this being a bug, it is just behaviour that exists because the engine is not designed for these zoom values.
Adjusting the values under the hood is counterintuitive and not how this should be handled, let people do stupid things if they want to.
Acceptable solutions would be:

  • a warning for low zooms
  • a comment on what zooms give acceptable results
  • or a hard Limit that is also mentioned in the documentation (wiki)

Or just don't do anything and let people experience.

@Zitchas
Copy link
Member Author

Zitchas commented May 20, 2024

That's kind of the point. 2 lines of code and suddenly our engine does handle these zooms quite nicely. Or at least, the spaceships, combat, and activity handles it nicely; and with this, so does the starscape and haze. The only part missing is the asteroid field. Even so, moving from 1 of 3 up to 2 of 3 is a good improvement in my books.

Having a warning message patronizingly telling players "You really shouldn't use these zooms, they don't work well. Remove them, and go back to what we provided you." followed up by delivering an unplayable game with heavy tiling just seems vindictive when we have the capability of fixing it so that it does work nicely.

That being said, if you want I could bump the start point out a bit more. 0.35 is where I felt it looked best, but moving it out to 0.25 would mean it would have zero effect on vanilla values and still look decent. Or out to 0.21 so people could take it a step farther than vanilla without triggering it, and then have it beyond that. Doesn't look as good, and doesn't reduce the performance hit of scaling as much, but it still prevents the >1000% GPU load at the tested levels.

@Zitchas
Copy link
Member Author

Zitchas commented May 20, 2024

As an aside, from practical playing experience, with the tiling and performance issues managed, having access to zooms down to about 0.044 are interesting and fun to use from time to time. Especially for watching big battles. (the testing zoom list has ten levels beyond that)

Copy link
Contributor

@Koranir Koranir left a comment

Choose a reason for hiding this comment

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

I do think this is a great change, I've been had by trying to zoom out too far in the past multiple times.

@@ -137,6 +137,10 @@ void StarField::Draw(const Point &pos, const Point &vel, double zoom, const Syst
bool isParallax = (parallaxSetting == Preferences::BackgroundParallax::FANCY ||
parallaxSetting == Preferences::BackgroundParallax::FAST);

// This slows down the effect of the player's zoom when they go past 0.25 to prevent tiling
if(baseZoom < 0.35)
baseZoom = baseZoom + ((0.35 - baseZoom) / 2);
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there any reason we're using this scaling in particular instead of a logarithmic curve?

Copy link
Member Author

Choose a reason for hiding this comment

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

Not particularly. I tried a few different formulas until I got one that looked good, and this was it.

I've tried a range of values from 0.4 to 0.2, and found that 0.25 and 0.35 look the best, with the latter being a bit better in my opinion than the former.

source/StarField.cpp Outdated Show resolved Hide resolved
@TomGoodIdea
Copy link
Member

I agree with Leaf that this isn't the proper solution.
Visible tiling is a problem by itself (and is still present in the second screenshot). And, if you zoom out that far, you should expect performance dropoffs as there's drastically more drawing to be done.
Perhaps we could add a "Fancy" haze mode, so that people can adjust it to match their computers' capability.

@Zitchas
Copy link
Member Author

Zitchas commented May 20, 2024

I'm all for having a "fancy" haze mode.

That being said, I have absolutely no clue what a "fancy" haze mode would be or do, or why we'd need it.

Performance aside, the tiling at that scale just looks bad. So even if one's computer could handle it without issues, I don't see anyone wanting that tiling anyway.

Anyway, yes, there's a little bit of tiling there. a handful of instances on a 1440p screen. Barely enough to be noticeable unless you're looking for it. I would posit that this is a massive improvement for this particular detail of the game, and unless someone is interested in coding a "fancy" haze manager, it's this or just actively trying to make life miserable for people who dare to experiment.

As an aside, this also makes the zooming more realistic. ;) Not entirely so, but more than it was before.

@Zitchas
Copy link
Member Author

Zitchas commented May 20, 2024

let people do stupid things if they want to.

Just to be clear, we're talking about me here, and probably more than a few other people. While the values provided are extreme, I do, in fact, like having about a dozen steps more zoom beyond what ES provides. You're welcome to consider that "stupid" if you wish, but I would personally prefer to call it "adventuresome" or perhaps "experimental." I'd like to think that we encourage curiosity and experimentation, rather than doing our best to make life miserable for those who push beyond the decreed limits.

As a player that goes down to about 5-6 steps, as a content creator I like the full range. It's useful to be able to see system formations and NPC movement patterns. This isn't just an idle suggestion, this is code that I find personally beneficial to making ES better and friendlier to end-user modification. It's already implemented in Delta, I just thought that people might appreciate something that reduces the system load and makes the game look better for those that experiment.

@RisingLeaf
Copy link
Contributor

Just to be clear, when I say stupid I don't mean to say that you are stupid but that some things are "stupid" for the game engine as in it doesn't make sense to do so.

I will also say that ES has an orthographic perspective which means that everything should scale the same. And again I have a problem with adjusting things under the hood that are specifically set by the player.

Also I dont see a warning as patronising the player. It is just a warning, you will leave the terrain that is supposed to be used, no warranty.

And lastly on the performance side, this could probably easily be fixed with mipmaps. If it's really the haze that's the problem ( it is probably the stars, so just render every second one might help too).

@Zitchas
Copy link
Member Author

Zitchas commented May 20, 2024

I didn't think you were, but especially in an environment where most of us are learning how to do any of this, labelling an action as "stupid" isn't productive.

Thank you for the explanation, though. That's quite a bit more informative that merely saying we should skip solving the problem and just slap a warning on it. That being said, I disagree. The amount of things that are kept orthographically to scale with each other are minimal. As has been pointed out, ships have a laughable degree of scale between them; and then there's planets and stars that are so far out of scale that it's irrelevant. The starscape and haze are objects so far in the background that they really shouldn't be zooming at all, ever, nevermind at the same rate of scale that the ships do.

Personally, I'd appreciate it if you try it out, and tell me how it feels. Tell me what it feels like. What impressions does it give you?

@RisingLeaf
Copy link
Contributor

Ok I like how it looks, but I still dont like the hard cut at some point, instead I would prefer if the zoom of the background would be modeled by a function, f(x) = 0.5x^2 + 0.2 would be one I find fitting for example, it is fairly linear between 1 and 2 and then gently approaches 0.2 as the zoom gets closer to 0
f(x)=0.5 x^(2)+0.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something in the game is not behaving as intended mechanics Things dealing with the mechanics & code of how the game works
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants