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

Add freely adjustable layered fog #1428

Merged
merged 3 commits into from
Jan 14, 2023
Merged

Conversation

almrausch
Copy link
Contributor

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.

* Fog logic moved to a separate file
* Restructured JSON scene format, conversion of old scenes
* Fog modes NONE, UNIFORM (classic) and LAYERED
* Freely adjustable fog layers
* Fog density modelled as the sum of sigmoid functions
* GUI not yet adapted to new features
@jackjt8
Copy link
Member

jackjt8 commented Aug 11, 2022

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
Copy link
Member

jackjt8 commented Aug 11, 2022

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

@leMaik
Copy link
Member

leMaik commented Aug 27, 2022

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

@almrausch
Copy link
Contributor Author

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.

@leMaik
Copy link
Member

leMaik commented Sep 16, 2022

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

@nib9888
Copy link

nib9888 commented Oct 19, 2022

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

@jackjt8
Copy link
Member

jackjt8 commented Oct 19, 2022

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
Copy link
Member

@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
Copy link
Member

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

@nib9888 nib9888 mentioned this pull request Oct 19, 2022
@nib9888
Copy link

nib9888 commented Oct 19, 2022

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

@leMaik
Copy link
Member

leMaik commented Oct 20, 2022

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

@leMaik
Copy link
Member

leMaik commented Jan 9, 2023

@almrausch It's been a while. 😅 So TL;DR this PR adds layered fog, doesn't modify the behavior of existing scenes and is ready to be merged, right?

@almrausch
Copy link
Contributor Author

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

Copy link
Member

@leMaik leMaik left a comment

Choose a reason for hiding this comment

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

Thank you for this great new feature! 👏
Can't wait to see more of you video's features in Chunky.

@leMaik leMaik merged commit a5b50f8 into chunky-dev:master Jan 14, 2023
@leMaik
Copy link
Member

leMaik commented Jan 14, 2023

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.

NotStirred pushed a commit to NotStirred/chunky that referenced this pull request Apr 3, 2023
* Add freely adjustable layered fog

* Fog logic moved to a separate file
* Restructured JSON scene format, conversion of old scenes
* Fog modes NONE, UNIFORM (classic) and LAYERED
* Freely adjustable fog layers
* Fog density modelled as the sum of sigmoid functions
* GUI not yet adapted to new features

* Fix skyFogDensity not being loaded from the JSON.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants