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

dayAlpha and nightAlpha in the ImageryLayer #8868

Merged
merged 9 commits into from
Jun 1, 2020

Conversation

epranka
Copy link

@epranka epranka commented May 18, 2020

Yesterday I created this pull request: #8862. But I closed it because, after some tests, I found that it has a big issue than using the multi-layers setup. Sorry for that, I had to test more before opening the pull request.

But today I create it again with improvement. I added the two options to ImageryLayer:

  • dayAlpha: The alpha blending value of this layer on the day side of the globe.
  • nightAlpha: The alpha blending value of this layer on the night side of the globe.

This only takes effect when enableLighting is true

The main reason to do this was to have day and night Earth textures depending on the lighting as an example below.

Also, I created the showcase of it called Night textures on the shade side in the Sandcastle.

Earth night textures example

Sample usage code (from showcase):

var globe = new Cesium.Globe();
globe.enableLighting = true;
globe.dynamicAtmosphereLightingFromSun = true;
globe.showGroundAtmosphere = true;

var clock = new Cesium.Clock({
  multiplier: 4000,
  shouldAnimate: true,
});

var viewer = new Cesium.Viewer("cesiumContainer", {
  imageryProvider: new Cesium.IonImageryProvider({ assetId: 3845 }),
  clockViewModel: new Cesium.ClockViewModel(clock),
  globe: globe,
});

var nightLayer = viewer.imageryLayers.addImageryProvider(
  new Cesium.IonImageryProvider({ assetId: 3812 })
);

// Line below sets that nightLayer invisible on the day side of the globe.
// So it only visible on the night side.
nightLayer.dayAlpha = 0.0;

@cesium-concierge
Copy link

Thanks for the pull request @epranka!

  • ✔️ Signed CLA found.

Reviewers, don't forget to make sure that:

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

@hpinkos
Copy link
Contributor

hpinkos commented May 18, 2020

Thanks for the pull request @epranka! This is a really cool feature. @lilleyse or @IanLilleyT would you be able to take a look at this?

@epranka epranka marked this pull request as ready for review May 18, 2020 15:30
@IanLilleyT
Copy link
Contributor

IanLilleyT commented May 26, 2020

Thanks for the feature @epranka! I just reviewed it and the only major change I made was moving this behavior to the Earth at Night sandcastle instead of its own. Toggle Dynamic lighting to see it in action.

If anyone else wants to take a quick look at this before the month is over, please do! This should be able to fit in the June release if all goes well.

@hpinkos
Copy link
Contributor

hpinkos commented May 29, 2020

Looks good to me! @IanLilleyT do you want to merge this?

@IanLilleyT IanLilleyT merged commit 746f8ac into CesiumGS:master Jun 1, 2020
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.

4 participants