chunky
chunky copied to clipboard
Add freely adjustable layered fog
Completely rewrote the code for the fog so that fog can e.g. concentrate at the bottom, allowing for a wider range of effects. Fog density is modelled as a function of y. It is a sum of bell shaped sigmoid functions. Each fog layer has a center y coordinate, a density and a breadth value. Scattering works only for one layer so far. The scene JSON structure has been altered so that all fog data is stored in one JsonObject. The previous fog behavior is still supported and old scenes will be saved in the new format.
Import the following settings to test the new features:
{"fog":{"mode":"LAYERED","layers":[{"y":62,"breadth":10,"density":1}]}}
{"fog":{"mode":"UNIFORM","uniformDensity":0.05}}
{"fog":{"mode":"NONE"}}
A GUI implementation is still missing. So far the GUI still works the same except that the mode must be set to UNIFORM via JSON. I'd like to leave the GUI part to someone else.
At the time of doing this write up, Fast Fog off has only been tested with LAYERED and it has been found to make no difference. I have not tested UNIFORM with Fast Fog disabled.
SkyFog Blending does not currently work with either UNIFORM or LAYERED modes. Given UNIFORM is a 1:1 with the old method of fog this feature needs to be fixed before merging.
Performance old vs UNIFORM vs LAYERED (1-16)
| Version | Mode | Time | SPS | % |
|---|---|---|---|---|
| 2.4.3-DEV | FF=ON | 2584 | 200577 | |
| SNAPSHOT.182.gffcf79e | FF=ON | 2409 | 215192 | |
| 2.5.0-PR.1428.185.g92c768a | UNIFORM | 2411 | 214982 | |
| LAYERED-1 | 2569 | 201758 | -6.2 | |
| LAYERED-2 | 2584 | 200583 | -6.7 | |
| LAYERED-4 | 2580 | 200885 | -6.6 | |
| LAYERED-8 | 2702 | 191815 | -10.8 | |
| LAYERED-16 | 2649 | 195692 | -9.0 |
Performance of UNIFORM is effectively the same as old fog. LAYERED fog starts out at around 6% slower with one layer before increasing to 10% with 8 or more layers*. The loss in performance is minimal
2.4.3-DEV

SNAPSHOT.182.gffcf79e

2.5.0-PR.1428.185.g92c768a - UNIFORM

2.5.0-PR.1428.185.g92c768a - LAYERED-1

2.5.0-PR.1428.185.g92c768a - LAYERED-16 (ie semi-random layers)

Breadth
1

5

10

50

100

Y
62

80

100

200

Regarding SkyFog Blending, I performed a difference operation between 2.5.0-PR.1428.185.g92c768a - UNIFORM and 2.5.0 SNAPSHOT.182.gffcf79e:

Hm… Maybe we can somehow keep the existing blending for uniform fog. :thinking: That would make this perfect.
The issue was that the sky fog blending setting wasn't loaded from the JSON. It is intended that there is no use for the skyFogBlending and fastFog settings in LAYERED mode.
@almrausch Thanks for the update! :partying_face: So as I understand it, this adds layered fog and removes nothing. I'll review it asap.
As @jackjt8 and I discussed in the discord, here's a suggestion for UI for this pull:
I went ahead and labelled it for clarity too:

Personally, I don't think that the live preview at the side needs to be interactive (dragging handles for width etc), except maybe for editing y levels of layers. Also, since this pull doesn't add different fog colours for different layers, there's no colour edit here, but space for one could be reserved for the future.
Hopefully a javafx wizard could share their thoughts on feasibility, because it would be really cool if this is possible as-is (except a lot less mockup-y, of course). Personally, I find this quite intuitive and think it would work fairly well under a dropdown like we have for Sky mode settings
Hopefully a javafx wizard could share their thoughts on feasibility, because it would be really cool if this is possible as-is (except a lot less mockup-y, of course). Personally, I find this quite intuitive and think it would work fairly well under a dropdown like we have for
Sky mode settings
@ShirleyNekoDev - You are probably the closest to our resident JavaFX wizard. How feasible is a UI like this?
@ShirleyNekoDev - You are probably the closest to our resident JavaFX wizard. How feasible is a UI like this?
Looks good, I think I can pull off something like that. But don't wait with merging this PR, I'll need some time and will create another PR for it.
Probably best to move your UI mockup to a new issue and assign it to me 👍
@ShirleyNekoDev I've opened #1479, so you can get assigned to that if you want.
In the meantime, when this gets merged but doesn't yet have a dedicated UI, what should we do with the current fog controls? Do they currently work as before but with the new backend?
@nib9888 the old controls should work as before, you just can't select layered fog with them
@almrausch It's been a while. :sweat_smile: So TL;DR this PR adds layered fog, doesn't modify the behavior of existing scenes and is ready to be merged, right?
Indeed. It's complete from my side and doesn't interfere with existing scenes.
A GUI implementation is still missing. So far the GUI still works the same except that the mode must be set to UNIFORM via JSON. I'd like to leave the GUI part to someone else.
Until we have a UI, I now changed it to be UNIFORM by default to work as before.