ddnet / ddnet

DDraceNetwork, a free cooperative platformer game
https://ddnet.org
Other
589 stars 417 forks source link

Parallax-Aware Zoom Discussion #6196

Open Patiga opened 1 year ago

Patiga commented 1 year ago

Parallax-Zoom pull request: #5696 from @Fireball-Teeworlds

Let me start off by saying I love the new way of zooming. It feels much more intuitive, looks better, and considering how long it is already in effect, it seems to also works very nicely with old maps.

Short relevant context:

Not long ago, I first realized that it was introduced alongside an addition to the map format, which I generally don't have an issue with. Implementing the parsing pretty straight forward for my project TwMap. Currently, I want to propose to change or remove the way that it is integrated in the map format.

Full understanding of parallax and parallax-aware zoom

Parallax was made to simulate objects that are closer to the camera or further away. This is done by making the move more or less than the physics/game group. Now, if parallax would just be distance, those objects would behave the same on the x- and y-axis. Since we are in 2D, we can easily make them move differently relative to the physics group on both axes. This was done and now we have parallax_x and parallax_y. When zoom was introduced, the parallax was only partially considered: Everything gets smaller the same way, except for when both parallaxes are 0, in that case it will stay the same size independent of the zoom level (used for background color mostly, parallax 0 means infinite distance). Parallax-wise, this doesn't make sense, since it should be something similar to distance and things further away should zoom out slower. To be fair, it is a bit ambiguous what distance objects should be considered to be, since the two different parallaxes for the two axes kind of break the concept of distance.

Parallax-zoom wants to tidy up this mess, so that parallax 0 isn't a special cased anymore, but just part of a general rule. For that, parallax-zoom needs to derive a sensible distance from the two parallaxes. The formula is currently clamp(max(parallax_x, parallax_y), 0, 100). This is how currently all maps are rendered differently.

However, a parallax_zoom value is also stored inside the map file now. When a map is loaded that doesn't have that value yet, it is simply set to the default parallax zoom level. While parallax_zoom is on the default value in the editor, any changes to the parallaxes that would change the default parallax-zoom level will automatically change the parallax_zoom. You can currently also change the zoom-perceived distance of a group by setting a custom parallax_zoom level.

Removal considerations

The great thing about parallax-aware zoom imo is that is 'logical', parallax sets some kind of distance, which then is also used for zooming. I don't understand yet, why parallax_zoom should be editable to any arbitrary value. I'd argue that the default value should be kept and globally tweaked if we find a better one. To phrase it differently, I think the parallax-aware zoom is a great new feature. I'm not so sure about the second feature of making it a custom field for every group. In the pull request, it felt like the option B1 (https://github.com/ddnet/ddnet/pull/5696#issuecomment-1203804445) was chosen to be able to fix up maps that break with the new feature, this appears to not be needed.

Why the value is complicated to handle right now

The other point: currently that value is a bit hard to handle. Let's recall what the editor does

While parallax_zoom is on the default value in the editor, any changes to the parallaxes that would change the default parallax-zoom level will automatically change the parallax_zoom. You can currently also change the zoom-perceived distance of a group by setting a custom parallax_zoom level.

This is very complicated behavior for such a value. Two things in particular:

Currently, there are 2 maps that use at least one custom parallax_zoom value:

Proposals

  1. Remove the map setting: I don't think it makes a lot of sense, and it also hasn't found a use yet in maps, so it wouldn't break stuff.
  2. Replace the custom value with a mode value: Off, Default and maybe provide more defaults if we find others that would be useful.

I'm ofc willing to implement the changes myself, this issue is for discussion. I didn't really mean to turn this into an essay, that kind of just happened.

def- commented 1 year ago

@Fireball-Teeworlds ^

Patiga commented 1 year ago

I want to rephrase

I don't understand yet, why parallax_zoom should be editable to any arbitrary value.

To: "I don't think we will find this kind of setting in any other 2D map format of other games (i.e. the "Tiled" map format). I don't think that such a setting needs to exist"

HiRavie commented 1 year ago

I've got a few words to say about this feature, personally not really a fan of it. Zoom parallax affects the position and scale of layers in relation to each other, which isn't really a good thing. Often when making a map you will check how layers with parallax behave when the camera is in a given area, zoom parallax adds a new headache to this process. Some backgrounds even break completely with it, like the one on Cerberus. I also don't think the zoom parallax effect looks correct. When a camera is zooming in or out, things always appear the same in relation to each other. Perspective only changes if you physically move closer or further away, but that is not what the name 'zoom' suggests is happening. I'm in favor of keeping the map setting though, it enables some effects that were previously impossible like 0 parallax hats that don't grow when you zoom out.

Patiga commented 1 year ago

Thanks for commenting @HiRavie!

Looking at Cerberus with and without Parallax-Zoom, I didn't manage to see how the background breaks with Parallax-Zoom. My experience so far was that pretty much nothing breaks, but I was very surprised by that, so I won't be surprised if I missed stuff.

My suggestion currently would be adding a value parallax_mode. One mode would be PARALLAX_ZOOM_DEFAULT, which would be the current default.

I personally don't think that the hat-like thing needs to exist necessarily, but that is ofc very much open for discussion.

Patiga commented 1 year ago

I had a thorough chat with @HiRavie and I'll summarize our results here:

The map "Cerberus" isn't a special case of Parallax-Zoom

Previous comments talked about whether Parallax-Zoom breaks the background of "Cerberus". To clear that up: Parallax-Zoom doesn't introduce any visual artifacts/overlaps/gaps in the design. However, zooming out looks weird/worse with Parallax-Zoom enabled, to both the mappers, @HiRavie and ofc probably more. So this isn't really an issue with Parallax-Zoom on this map, but a more general one.

Zooming versus Camera Movement

As a 2D game, the word zooming might be interpreted in different ways.

  1. Zooming as in literally zooming with a camera, which is the old behavior
  2. Moving the camera forwards/backwards, which is what Parallax Zoom imitates

The art style of Teeworlds/DDNet is orthogonal, which would suggest the old method. On the other hand, Parallax-Zoom was very well received, I haven't even noticed any backlash, which is quite unusual for a feature that changes old behavior.

Does Parallax-Zoom break Maps

Not that I'm aware of, at least no DDNet map. Some menu background map had to be changed afaik, but that is a pretty niche map.

It could break something: Consider "Cerberus", the lava has parallax 0, but the mountains at the very back have a horizontal parallax. Due to this, Parallax-Zoom scales the mountains but not the lava, which makes them overlap. In the actual map, the lava is not transparent, but if we would add some, that overlap would cause a visual bug: screenshot_2023-01-17_16-33-01

Some thoughts about future changes

Mappers are ofc affected the most by Parallax-Zoom, and now we know of three who dislike it and how it changes their maps. It would be very interesting to know if there is a significant portion of the community who also dislike Parallax-Zoom. However, as pointed out, Parallax-Zoom seems to work well regardless of what map it is on. So having it as a setting on each group seems misplaced to me currently. A map setting would already make more sense to me, but that still misses the point. Maybe a client setting?

One negative effect of a client setting, would be that maps look different depending on how the client is configured. So far we have the detail flag on layers and I suppose the zoom level. Parallax-Zoom as a client setting would add yet another thing mappers potentially have to care about. @HiRavie pointed out that they dislike any setting in general, which messes with how their maps look, which the mappers also have no control over.

Patiga commented 1 year ago

Regarding the art style: Orthogonal projection is already broken before. I think that a more accurate description would be that the art style of Teeworlds/DDNet is orthogonal on each depth separately.

We don't have orthogonal projection right now, because:

  1. Objects in the background are smaller (mountains, clouds, etc.)
  2. Parallax wouldn't exist

I currently favor:

Create a client option to turn Parallax-Zoom off. If we ever need to, add a setting to groups to turn off parallax zoom.

Fireball-Teeworlds commented 1 year ago

I think @Patiga's description of the feature is on point.

Considerations I've had when implementing it:

  1. A lot (maybe most of the maps) were breaking on high zoom-out levels (either when playing on a big screen or when zooming out to check the map ahead). This made it harder to enjoy maps without enabling entities.
  2. Making zoom aware of the "distance" between layers, the way it's usually done in 2d animation: https://youtu.be/3YIR39KeJMk?t=259, has the nice effect that: a) You don't need to make background layers very large to accommodate zoomed-out players: previously 2x zoom needed 2x larger background layer, but now of stuff like clouds layer you need like 1.3x larger background, a buffer which is often already there for parallax. b) Small details like stars in background no longer become indistinguishable on zoom-out.
  3. The formula for camera moving closer/further away is supposed to be physically correct (this one: float Scale = (ParallaxZoom * (Zoom - 1.0f) + 100.0f) / 100.0f / Zoom – from render.cpp).
  4. Some maps were using weird values for Parallax{X,Y} that'd look even weirder with zoom. In order to not make those maps worse I've added clamp(max(parallax_x, parallax_y), 0, 100).
  5. You can now make TimeShop menus work perfectly (when zoomed-out) by setting ParallaxZoom to 0 on some of the groups, where the inferred value was still not good enough.
  6. I didn't want to make it harder for mappers to create maps (having to control 1 more parallax value on top of the existing 2) - which is the reason for the parallax value is set automatically by the editor by default (with an opt-out).
Fireball-Teeworlds commented 1 year ago

Maybe we could add a setting to the map that makes it default to ParallaxZoom=0 for all layer groups? As an opt-in from the mapper, where they'd be specifying that they want the zoom to not behave as a camera moving closer/further away. This way mappers who don't like this feature can disable it and at the same time they wouldn't need to worry about players having it set to different values.

Patiga commented 1 year ago
  1. You can now make TimeShop menus work perfectly (when zoomed-out) by setting ParallaxZoom to 0 on some of the groups, where the inferred value was still not good enough.

I don't really see an issue with how TimeShop is right now. The map wasn't changed, and it seems to work just fine.

  1. I didn't want to make it harder for mappers to create maps (having to control 1 more parallax value on top of the existing 2) - which is the reason for the parallax value is set automatically by the editor by default (with an opt-out).

Maybe we could add a setting to the map that makes it default to ParallaxZoom=0 for all layer groups? As an opt-in from the mapper, where they'd be specifying that they want the zoom to not behave as a camera moving closer/further away. This way mappers who don't like this feature can disable it and at the same time they wouldn't need to worry about players having it set to different values.

I think this issue is difficult to deal with. I would argue that mapper probably don't have to worry about parallax zoom at all. We retroactively enabled it in all older maps, with pretty much zero actual issues that I know of. It doesn't seem to me as if Parallax-Zoom would need to be disabled to fix maps. I don't like the current situation: That some people seem to like the old style more, even on old maps. Disabling it on new maps because of preference seems off to me. Maybe mappers can showcase how this makes mapping harder, but if it works on literally all old maps, then I myself don't really see it yet.

Again, I do see how the edge-case like on Cerberus exists. Note that the map looks great with Parallax-Zoom (to me, as someone who likes the effect). The visuals of the map truly amazing. In that specific case, the lava maybe also should've gotten parallax 5 like the mountains in the back.

AssassinTee commented 1 year ago

@Patiga just a note: There a negative paras, which have usecases, too. You can use them to move stuff faster than the Tee, if you move in X-direction, the quad with negative paraX moves faster in X direction. This can and has been used for a dot in a simulated Minimap. I know some other cases, where this is used and wish, that this feature stays

Patiga commented 1 year ago

@AssassinTee This discussion is not about the normal parallax, but the more specialized Parallax-Zoom. https://youtu.be/W7eXQN0gRFI shows off the feature.

Jupeyy commented 1 year ago

without having thought deeply into it, and considering the discussion i had with patiga on discord, i think it would indeed be better to have a good default behavior instead of introducing another map item for this. it seems on maps, like timeshop, where the original problem arrised from, the "default" values for the parallax zooming is enough without any customization.

Short relevant context:

  • the zoom is currently enabled by default on all new and old maps, without a change in their map file
  • despite worries in the pull request, this did not break menu maps like "Time Shop"

this is the important part of the issue imo, and i agree with that