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

Elevation Band Material #9132

Merged
merged 29 commits into from
Dec 21, 2020
Merged

Elevation Band Material #9132

merged 29 commits into from
Dec 21, 2020

Conversation

IanLilleyT
Copy link
Contributor

@IanLilleyT IanLilleyT commented Sep 3, 2020

Merge #9287 first

This material is very similar to the ElevationRamp material (https://sandcastle.cesium.com/?src=Globe%20Materials.html) but provides a lot more flexibility and accuracy. The main limitation with ElevationRamp is the quality is tied to the texture resolution, so it's not possible to map colors or gradients to exact elevations without extremely large textures. ElevationBand works a bit differently. It feeds a texture of heights and a texture of colors at those heights to the shader, which does a binary search from an input height to find out which two colors to interpolate between. This means unique colors and gradients can be mapped to many different elevation ranges with minimal texture memory and still be quite performant.

While the ElevationBand height and color textures can be created from scratch, it's much easier to go through the createElevationBandMaterial.js helper file which takes an array of layers, each containing an array of height / color pairs, and flattens them on top of each other, returning a single Material. This way you can implement more complex behaviors like background gradients, movable bands, etc.

Here's the feature in action. Everything in the gif, including the narrow white grid lines on the mountain, is ultimately a single material. It gets recreated whenever the UI changes.
Peek 2020-09-03 11-48

Sandcastle demo on local host

Also, a Sandcastle demo on local host for showing the difference between creating a simple gradient with ElevationRamp and ElevationBand. The results should look identical.

@cesium-concierge
Copy link

Thanks for the pull request @IanLilleyT!

  • ✔️ Signed CLA found.
  • CHANGES.md was not updated.
    • If this change updates the public API in any way, please add a bullet point to CHANGES.md.

Reviewers, don't forget to make sure that:

  • Cesium Viewer works.
  • Works in 2D/CV.
  • Works (or fails gracefully) in IE11.

@OmarShehata
Copy link
Contributor

Looks amazing! Is there a reason someone would choose to use the old elevation material over this?

@IanLilleyT
Copy link
Contributor Author

IanLilleyT commented Sep 4, 2020

ElevationRamp might be a bit faster because it only has to do one texture lookup. It's also a bit more straightforward in some cases.

@IanLilleyT
Copy link
Contributor Author

It's possible this new material can deprecate ElevationRamp since it has all the same functionality and more. Plus we won't have to awkwardly go through the css gradient setup. I wonder if with a little bit of work similar materials like SlopeRamp and AspectRamp can use this new system too. The ElevationBand shader is hardcoded to materialInput.height, but there's no reason we can't make this a common function that all three materials call with their own input.

@mramato
Copy link
Contributor

mramato commented Sep 4, 2020

👍 for deprecating and then removing other classes if we can replace them with different usages for this. If the setup is non-obvious, we can use helper functions or derived classes so that the API is easy but the overall implementation is less code.

The less code overall, the better.

@cesium-concierge
Copy link

Thanks again for your contribution @IanLilleyT!

No one has commented on this pull request in 30 days. Maintainers, can you review, merge or close to keep things tidy?

I'm going to re-bump this in 30 days. If you'd like me to stop, just comment with @cesium-concierge stop. If you want me to start again, just delete the comment.

1 similar comment
@cesium-concierge
Copy link

Thanks again for your contribution @IanLilleyT!

No one has commented on this pull request in 30 days. Maintainers, can you review, merge or close to keep things tidy?

I'm going to re-bump this in 30 days. If you'd like me to stop, just comment with @cesium-concierge stop. If you want me to start again, just delete the comment.

@IanLilleyT IanLilleyT changed the base branch from master to betterFloatPack December 16, 2020 14:04
Base automatically changed from betterFloatPack to master December 18, 2020 18:39
@Samulus Samulus merged commit a76a868 into master Dec 21, 2020
@Samulus Samulus deleted the elevationBand branch December 21, 2020 14:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants