-
-
Notifications
You must be signed in to change notification settings - Fork 21.4k
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
Use circular fade instead of linear fade for distance fade #50294
Use circular fade instead of linear fade for distance fade #50294
Conversation
Orthographic projections should still use a linear fade, or it will cause artifacts while panning. |
I guess I have to apply the same godot/scene/resources/material.cpp Lines 678 to 680 in a71169c
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My suggested changes are functionally equivalent to your code except shorter and much faster.
0b84915
to
ffba867
Compare
Rebased and tested again, it works as expected for Pixel Alpha and Pixel Dither. Edit (2022-08-31): Fixed thanks to clayjohn's review suggestion. I added a testing project to OP. @clayjohn Do your suggestions handle orthogonal camera projections automatically? Edit (2022-08-31): It seems distance fade makes objects invisible in orthogonal camera, even before this PR. I'm confused at how the distance is supposed to be calculated when using an orthogonal camera anyway. |
ffba867
to
4d077ed
Compare
Could this be reviewed again for 3.6? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code changes are fine. My only concern is with the comment which will quickly become out of date.
I am fine with substituting Akien's suggested comment above.
4d077ed
to
69e42cd
Compare
This makes distance fade look the same regardless of the camera angle, for all distance fade modes (Pixel Alpha, Pixel Dither, Object Dither). Distance fade now behaves like fog in this regard.
69e42cd
to
d926be7
Compare
Done 🙂 |
Thanks! |
This has significant conflicts now, so would be worth a dedicated backport. |
I thought this was for 3.x? This was started before 4.0 was even released. |
The code in this PR changed quite a bit compared to its first revision, and |
There were some original pushes last year that never made it, surely those would have been relevant for 3.x then as they would be now? @clayjohn did a revision at some point, what caused it to be shelved until 3.x became non-priority? |
@elvisish Many PRs take a looong time to get merged, for whatever reason (personally I think it's the sheer number of PRs open vs small number of contributors who can merge) |
master
version of #69959.This makes distance fade look the same regardless of the camera angle, for all distance fade modes (Pixel Alpha, Pixel Dither, Object Dither). Distance fade now behaves like fog in this regard.
This has a minimal performance cost, but the quality increase is worth it. When viewing a plane that fully covers the screen, I get 215 FPS instead of 218 FPS with Pixel Dither in 4K, but this does not reflect the typical use case of distance fade (which is for LOD purposes). Besides, there are likely other ways to improve dithering efficiency (such as reducing branching or using interleaved gradient noise).
Thanks to @mrjustaguy for providing the formula here: godotengine/godot-proposals#2963 (comment)
This can be cherry-picked without conflicts to the
3.x
branch. I tested this PR on the3.x
branch on both GLES3 and GLES2, and it works as expected there too. This PR can be merged independently of #50297 as both can work together.This closes #53853 and partially addresses godotengine/godot-proposals#2963.
Testing project: test_distance_fade_circular.zip
Preview
Note: These images should be viewed on a desktop device at 1:1 resolution by clicking them. Otherwise, they will not look as expected due to the nature of dithering.
Pixel Alpha
Pixel Dither