chunky icon indicating copy to clipboard operation
chunky copied to clipboard

Add freely adjustable layered fog

Open almrausch opened this issue 3 years ago • 5 comments

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.

almrausch avatar Aug 09 '22 16:08 almrausch

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 DWAEBH_fog_test-2 4 3_dev

SNAPSHOT.182.gffcf79e DWAEBH_fog_test-2 5 0_snapshot

2.5.0-PR.1428.185.g92c768a - UNIFORM DWAEBH_fog_test_uni

2.5.0-PR.1428.185.g92c768a - LAYERED-1 DWAEBH_fog_test_layer62

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


Breadth

1 DWAEBH_fog_test_breadth1

5 DWAEBH_fog_test_breadth5

10 DWAEBH_fog_test_breadth10

50 DWAEBH_fog_test_breadth50

100 DWAEBH_fog_test_breadth100


Y 62 DWAEBH_fog_test_layer62

80 DWAEBH_fog_test_layer80

100 DWAEBH_fog_test_layer100

200 DWAEBH_fog_test_layer200

jackjt8 avatar Aug 11 '22 21:08 jackjt8

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

jackjt8 avatar Aug 11 '22 21:08 jackjt8

Hm… Maybe we can somehow keep the existing blending for uniform fog. :thinking: That would make this perfect.

leMaik avatar Aug 27 '22 11:08 leMaik

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 avatar Sep 01 '22 15:09 almrausch

@almrausch Thanks for the update! :partying_face: So as I understand it, this adds layered fog and removes nothing. I'll review it asap.

leMaik avatar Sep 16 '22 20:09 leMaik

As @jackjt8 and I discussed in the discord, here's a suggestion for UI for this pull: notlabelled I went ahead and labelled it for clarity too: labelled

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

nib9888 avatar Oct 19 '22 17:10 nib9888

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?

jackjt8 avatar Oct 19 '22 17:10 jackjt8

@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.

ShirleyNekoDev avatar Oct 19 '22 18:10 ShirleyNekoDev

Probably best to move your UI mockup to a new issue and assign it to me 👍

ShirleyNekoDev avatar Oct 19 '22 18:10 ShirleyNekoDev

@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 avatar Oct 19 '22 18:10 nib9888

@nib9888 the old controls should work as before, you just can't select layered fog with them

leMaik avatar Oct 20 '22 06:10 leMaik

@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?

leMaik avatar Jan 09 '23 21:01 leMaik

Indeed. It's complete from my side and doesn't interfere with existing scenes.

almrausch avatar Jan 10 '23 11:01 almrausch

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.

leMaik avatar Jan 14 '23 00:01 leMaik