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

Globe translucency #8726

Merged
merged 125 commits into from
May 26, 2020
Merged

Globe translucency #8726

merged 125 commits into from
May 26, 2020

Conversation

lilleyse
Copy link
Contributor

@lilleyse lilleyse commented Apr 5, 2020

For #5665
Fixes #5163
Fixes #7257
Fixes #8752

This PR adds the ability to set translucency on the globe surface. Translucency takes into account the globe's material, imagery layers, and base color, as well as new options frontFaceAlpha and frontFaceAlphaByDistance for front faces and backFaceAlpha and backFaceAlphaByDistance for back faces.

Most of the work happens in a new file GlobeTranslucency. It creates derived commands for globe commands and maintains a framebuffer for rendering classification primitives. I tried to design the code so that it would work for classification primitive on 3D Tiles in the future. I also tried to make the globe translucency logic as invasive in other files as possible, but some logic does slip through in Globe, GlobeSurfaceTileProvider, and Scene.

There are also a few miscellaneous fixes in here.

  • I noticed that globe materials were combining uniform map objects for every tile every frame. Now it only combines when the material is dirty.
  • The sky atmosphere was writing NaNs to the framebuffer which completely broke translucent globe + HDR. I capped the color to a large number which fixed that problem and also got rid of the red/yellow artifact you'd see sometimes. An even more minor bug with sky atmosphere was HSB coloring was modifying the alpha when it shouldn't. There's still a bug related to sky atmosphere in HDR mode though: Sky atmosphere gets brighter when the sun is offscreen in HDR mode #8718.
  • Billboards were doing manual depth testing against the globe even when depthTestAgainstTerrain was false.

Globe translucency affects a lot of systems and I tried to test as many configurations as I could think of. I enabled globe translucency in every Sandcastle to help discover bugs, but mainly I tested with these two sandcastles: sandcastle1 sandcastle2. My checklist so far is:

  • Objects in the center of globe aren't culled
  • Picking objects below the translucent globe works
  • Rendering, picking, and drill picking classification primitives, textured ground primitives, and lines on the translucent globe works. This was by far the hardest thing to support in this PR.
  • Works in IE, Firefox, and Chrome
  • OIT, log depth, depthTestAgainstTerrain, pickTranslucentDepth, HDR work
  • All translucency modes work when underground
  • 2D mostly works. CV works. Morphing looks correct.
  • Ground atmosphere and fog work
  • Switching globe materials works
  • Sky, sun, moon etc render correctly for various translucency modes and when underground

To do:

  • Unit tests
  • Underground fog so you don't always see the opposite side's imagery
  • Performance testing. Sandcastle - CPU perf seems good based on the Chrome profiler in built sandcastle. FPS drops 5-10 fps during flight which can explained by more tiles being rendered (like opposite side of globe), more fragment shader throughput for all the translucent fragment, and sky atmosphere running per-fragment instead of per-vertex. Opaque perf is unchanged in this branch.
  • Why does the water material hide the globe? - It's because water material's translucent property is false and the primitive is being rendered in the opaque pass and writing depth that obstructs the translucent globe.
  • Is it possible to make sky atmosphere look better when the globe's translucent?
  • Only render sky atmosphere frag shader mode when camera is above ground and front/back are translucent OR if camera is underground and front are translucent
  • Generate derived commands on demand
  • Translucency inside rectangle region: Partial translucency on globe #8752
  • Globe blend commands. See Globe translucency #8726 (comment)
  • Fix artifacts when skirts are disabled. See Globe translucency #8726 (comment)
  • Fix shadows on translucent globe. See Globe translucency #8726 (comment)
  • 2D lighting and ground polylines look weird sometimes. 2D is due to multifrustum and multiple layers seems to overlap each other. See * [ ] Fix artifacts when skirts are disabled. See Globe translucency #8726 (comment)
  • Fix VR mode for classification primitives on translucent globe

sandcastle

Globe translucency sandcastle

underground5

Drawing on translucent terrain

checkers

Checker material sandcastle

sky-atmosphere

atmosphere

underground1

underground-gif

zoom-in-2

inside-2

@gberaudo @fredj

@lilleyse lilleyse changed the base branch from master to sky-atmosphere-per-fragment May 23, 2020 01:38
Base automatically changed from sky-atmosphere-per-fragment to master May 25, 2020 15:53
Copy link
Contributor

@IanLilleyT IanLilleyT left a comment

Choose a reason for hiding this comment

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

This PR really shows how complicated transparency can be with all the different edge cases it introduces, but the code is pretty well isolated and I didn't see any problems in the sandcastles. Thanks @lilleyse!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
6 participants