-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
Make Models be affected by Fog #4196
Comments
This feature has two parts: fog culling (tiles in the distance for horizon views should use lower-resolution tiles) and fog rendering (Blend the model color with the atmosphere color like terrain does. Fog culling is already implemented in CesiumJS, but not enabled by default. It goes by the term This is an unfamiliar part of the 3D Tiles code for me, so I explored the code a bit yesterday and now can explain the parameters better:
Another observation: Fog culling rolls off with the camera angle. It has a maximum effect when the camera is facing the horizon, and no effect when the camera is facing straight up or straight down. Here's a diagram of what the fog culling SSE adjustment looks like: Here's what the density parameter does: Here's what the SSE Factor parameter does: And here's an animation that shows how culling is strongest when the camera is low, but rolls off as the height increases past the falloff point. Footnotes
|
Before we enable fog culling by default, we'd like to do some performance testing to evaluate how well it works and what parameters would be the best defaults. For the first round of tests, I'm using Google Photorealistic 3D Tiles to test how well this feature helps reduce tiles loaded for world-scale datasets. This involves
I've already started some of these measurements, I will post the data and a summary once I have the rest of the numbers. |
P3DT Fog Performance Test ResultsI ran the above tests for comparison. I used 5 different areas of Google P3DT, and for each area 3 views (aerial, street level, top-down) for comparison. Here's an example HTML file for one of the test setups. I adjusted the parameters in the Here's a summary of the time to first load, averaged over all the different views:
For the full data (which includes other metrics like number of tiles loaded), see this CSV file: |
Another thing we wanted to check: Does fog culling serve as a workaround for horizon culling for world-scale tilesets? Freeze frame will help here: As I suspected, it doesn't completely replace horizon culling (as tiles on the other side of the globe still render), but it does reduce the LODs loaded. Not perfect, but definitely an improvement! |
Thanks @ptrgags for the research!
|
I started prototyping a very barebones Here's Google P3DT with There's still several more details to determine:
|
More notes from exploring the existing globe shader and a discussion with @lilleyse:
|
Update: I added some new automatic uniforms and created some new builtin functions for computing the scattering color. I also created a new The shader for FogPipelineStage is still very bare-bones, there's quite a bit of code I have to add from There's still a lot left to do here, so let me organize my thoughts:
|
It looks like the scattering code is likely where it happens, though I'm still trying to figure out why. Along the way, I'm finding some corner cases with some of the variables that seem a bit off to me, though these don't seem to be a problem for terrain. Documenting them for future reference. First, the variable Second, the variable Still poking around the code a bit. I also want to do a bit of reading up on atmosphere rendering to understand the scattering functions better. |
This article was a helpful resource at understanding the concepts here about Rayleigh and Mie scattering, with plenty of good diagrams. |
Well that's one thing that seems off. For fragments above the horizon, the lightHeight computed in the inner loop seems to be negative somehow 🤔
|
Hm, rendering I get weird values. the reddish colors above the horizon would mean +x here which is definitely wrong (+x is eastern hemisphere, this view is California). Also not sure why there are two colors. Terrain for comparison for a similar view. All blue, even above the horizon. So something about the coordinates used for the computation must be different between globe and Model... though this function uses only built-in uniforms so not sure what's different here.
|
Today I've been focusing on other details of 3D Tiles fog and thinking towards the future of atmosphere rendering. See #11681 (comment) for more details on what I think the atmosphere setting structure should be (although getting there requires quite a few deprecations). For now, I'm sticking to non-breaking changes until it can be discussed further. Then I wired up the flags that enable/disable the fog pipeline stage. |
I added an enum to select between the 3 dynamic lighting modes (
For safekeeping, here's a Local Sandcastle for WIP branch |
@ggetz I clarified the product details of 3D Tiles fog with @shehzan10 today, and he clarified that right now the priority is focusing on 3D Tiles performance for world-scale datasets like Google P3DT. The visual rendering details are at a lower priority for now. So I'm splitting this issue up into the following smaller issues:
I'm closing this issue in favor of the 4 above. |
glTF Models are currently not affected by Fog. This creates a highly unrealistic image. It would be desirable to have Models be affected by Fog just like the Terrain Primitives are.
The text was updated successfully, but these errors were encountered: