Upgraded from 1.31 to 1.57 and sun lighting is ruining my visualizations

My visualization system creates a lot of BoxGeometry and updates their matricies every day. But I also use CZML that animates on a sub-day level, so I run my animations with multiplier 14400, that is four steps per day.

In Cesium 1.31, I used to get uniform and unchanging lighting on my BoxGeometry, which is exactly what I wanted. But now with Cesium 1.57 the sun is zooming overhead changing the lighting radically, and since I run time accelerated, it effectively makes everything flash like hell.

Here’s a sample of that things looked like with Cesium 1.31:

And here’s what it looks like in Cesium 1.57:

One change I made helped. For example, I did:

_viewer.scene.globe.enableLighting = false;

So at least I don’t have the globe texture flashing like made.

But setting my BoxGeometry material to flat made them, of course, flat, so they lost their 3D cues.

I guess what I want is a point light source, like a geostationary satellite with a gigantic flashlight on it. I would calculate the normal for my data’s bounding rectangle and put that light source at some high altitude on that normal, and be happy. But I’d also want to turn off the sun.

I totally get that Cesium is being accurate about lighting using the sun. I definitely appreciate that. But for my application, and I suspect many geospatial other data visualizations, it is not ideal and a more cartoonish, less astronomically-accurate lighting model would be better.

Is there something I’m missing? Is there a way to solve this in Cesium 1.57? Otherwise I will sadly have to stay with 1.31, or whatever version of Cesium before this sun-lighting stuff got added.

Thanks,

Bryan Ressler

Institute for Disease Modeling

Incidentally I determined that this lighting behavior changed starting in version 1.52. So I could theoretically point my package.json at 1.51 in the short term, but I hope there’s a fix or workaround that lets me stay at the head revision.

-Bryan

Gah animated gifs don’t seem to animate, so here’s a couple videos attached.

-Bryan

AnimCesium131.mp4 (294 KB)

AnimCesium157.mp4 (395 KB)

Hey Bryan,

I understand your frustration here. The sun being the only light source in CesiumJS has been an issue for me as well in other projects. There is a little snippet in this issue (https://github.com/AnalyticalGraphicsInc/cesium/issues/6553) that can compute the sun’s position such that it will light up any location on Earth, but it sounds like your issue is that the timeline is moving to show the dynamic nature of the simulation, but since that moves the sun as well, this causes the undesirable lighting effects.

The biggest change with 1.53 was adding image-based lighting (https://github.com/AnalyticalGraphicsInc/cesium/blob/master/CHANGES.md#153—2019-01-02). You can adjust the brightness of the sun with this property on 3D models:

https://cesiumjs.org/Cesium/Build/Documentation/Model.html?classFilter=Model#luminanceAtZenith

And I think you can turn it off completely by setting the lighting factor here to Cartesian2(0,0):

https://cesiumjs.org/Cesium/Build/Documentation/Model.html?classFilter=Model#imageBasedLightingFactor

Let me know if that helps (or if these objects aren’t models but are some other datatype there might be another way to tweak these parameters).

Also, this looks like a super cool app! I did a bunch of mathematical modelling with SIR models in my undergrad, but we rarely got to apply a spatial component to it. Do you use CesiumJS a modelling tool in itself or mostly just as a way to present results created with R/Python ?

I’m pretty sure the lighting difference is due to adding HDR rendering in 1.52. As a workaround set:

viewer.scene.highDynamicRange = false;

``

The problematic lines are these in phong.glsl: https://github.com/AnalyticalGraphicsInc/cesium/blob/master/Source/Shaders/Builtin/Functions/phong.glsl#L49-L52

Previously just the specular highlight changed with the sun’s direction, this change made the diffuse color change with the sun’s direction as well.

Thank you Sean! That totally solved my problem. The magic combination is:

_viewer.scene.globe.enableLighting = false;
_viewer.scene.highDynamicRange = false;

``

Thanks Omar. I did find the set-the-date hack for arranging to have the sun over your scene, but since I actually use Cesium’s clock for my animation I can’t use that hack.

Using Sean’s HDR fix below (in combination with globe.enableLighting = false) seems to get me fixed up. But I may end up adjusting the sun’s brightness just to make things look the same as they did in 1.31, so thank you for that mechanism.

Thanks for the props on the app, which is called Vis-Tools. It’s open source, here on github. The modeling itself is crazy Monte Carlo stuff that is all written in C++, which is called EMOD (also open source, here on github). A lot of our modeling generates spatial outputs, so geospatial visualization is an important part of our work. CesiumJS worked fantastically well for me in Vis-Tools.

Glad it’s all solved now! I did also do some MCMC experiments my last year in undergrad - it’s very cool to see this application and hear CesiumJS has been a helpful tool in this process. I’d love to see this showcased on our showcases page (https://cesiumjs.org/demos/) or maybe even a guest blog post if you’re up for that! It’d be really interesting to hear how you’re using it in your research & work. Would you be interested in that?

Yes I’d definitely be interested a showcase and/or guest blog post, and I’d be happy to talk about how I’ve used Cesium and the various pain points. In general, it has been a godsend and I’m so glad i used it!