# Inverted colors / night mode

**URL:** <https://community.cesium.com/t/inverted-colors-night-mode/1621>\
**Category:** CesiumJS\
**Created:** [October 28, 2014, 1:24pm UTC](https://community.cesium.com/t/inverted-colors-night-mode/1621 "2014-10-28T13:24:16Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Guillaume\_Beraudo](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/guillaume_beraudo/32/2985_2.png) [@Guillaume\_Beraudo](https://community.cesium.com/u/Guillaume_Beraudo)\
**Post date:** [October 28, 2014, 1:24pm UTC](https://community.cesium.com/t/inverted-colors-night-mode/1621/1 "2014-10-28T13:24:16Z")

</div>

Hello,

Are there plans / thoughts to allow rendering the globe with all colors  
inverted in order to create a 'night mode' effect?

Is the postprocessing hook branch usable? Is it going to be merged in  
master? Is it expected that mixing primitives and filters result in a black  
screen? (See Sandcastle example below).

If post processing filters are not usable, does that mean modifying  
- GlobeFS.glsl to handle imagery textures;  
- Appearance and Material fragments with colors like  
&nbsp;&nbsp;PerInstanceFlatColorAppearanceFS.glsl;  
- Label glyphs regeneration;  
- Something for Billboard images/canvas.

Is there interest for such a feature?

Sandcastle example:

var viewer = new Cesium.Viewer('cesiumContainer');  
var scene = viewer.scene;  
var primitives = scene.primitives;

// Create a simple polygon  
var polygon = primitives.add(new Cesium.Polygon({  
&nbsp;&nbsp;&nbsp;&nbsp;positions : Cesium.Cartesian3.fromDegreesArray([  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-72.0, 40.0,  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-70.0, 35.0,  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-75.0, 30.0,  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-70.0, 30.0,  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-68.0, 40.0])  
}));

function setFilter(scene, filter, uniforms) {  
&nbsp;&nbsp;&nbsp;&nbsp;scene.customPostProcess = new Cesium.CustomPostProcess(filter, uniforms);  
}

// Comment to make it work  
setFilter(scene, Cesium.\_shaders.PassThrough);

---

<div class="post-metadata">

**Author:** ![patrick](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/patrick/32/2045_2.png) [@patrick](https://community.cesium.com/u/patrick)\
**Post date:** [October 29, 2014, 2:10am UTC](https://community.cesium.com/t/inverted-colors-night-mode/1621/2 "2014-10-29T02:10:42Z")

</div>

Hi Guillaume,

Have you seen the NASA night lights imagery, e.g., that is referenced in the [imagery tutorial](https://cesiumjs.org/2013/01/04/Cesium-Imagery-Layers-Tutorial/)? You may be able to use this with disabled lighting and perhaps a small tweak to the fragment shaders for lighting.

It will be at least a few months before I expect we’ll be able to focus on the postprocessing branch to get it into master. In the meantime, I can’t speak to the exact state of it, but I know at least Doarama is using it.

Patrick

---

<div class="post-metadata">

**Author:** ![Chris\_Cooper](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/chris_cooper/32/3554_2.png) [@Chris\_Cooper](https://community.cesium.com/u/Chris_Cooper)\
**Post date:** [October 29, 2014, 3:36am UTC](https://community.cesium.com/t/inverted-colors-night-mode/1621/3 "2014-10-29T03:36:05Z")

</div>

Hi Guillaume,

The postprocess-hook branch has been updated to Cesium 1.2. It sounds like you’ve already found the Sandcastle demo. I’ve just made a change to it so it should now work with the polygon.

[https://github.com/AnalyticalGraphicsInc/cesium/commit/6b4232f04c94ebe0e2986056588e130817638a6b](https://github.com/AnalyticalGraphicsInc/cesium/commit/6b4232f04c94ebe0e2986056588e130817638a6b)

Chris

---

<div class="post-metadata">

**Author:** ![Guillaume\_Beraudo](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/guillaume_beraudo/32/2985_2.png) [@Guillaume\_Beraudo](https://community.cesium.com/u/Guillaume_Beraudo)\
**Post date:** [October 29, 2014, 9:08am UTC](https://community.cesium.com/t/inverted-colors-night-mode/1621/4 "2014-10-29T09:08:10Z")

</div>

Hi Patrick and Chris,

Thank you for your replies.

Disabling OIT indeed fixed the issue.

Post processing filters look very promising and is the perfect match for  
a global 'inverted colors' effect.

Guillaume

---

<div class="post-metadata">

**Author:** ![AJEvans](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/ajevans/32/24427_2.png) [@AJEvans](https://community.cesium.com/u/AJEvans)\
**Post date:** [June 27, 2024, 9:45am UTC](https://community.cesium.com/t/inverted-colors-night-mode/1621/5 "2024-06-27T09:45:49Z")

</div>

I have no idea if it’s the best solution, but I achieved what I had in mind by directly setting the css filter of the canvas using jQuery…

$canvasElement.css(“filter”, “invert(100%) hue-rotate(180deg)”);

(filter settings after: [javascript - change openlayers map color (dark and light style) - Stack Overflow](https://stackoverflow.com/questions/59819792/change-openlayers-map-color-dark-and-light-style))  
It does scupper atmospheric effects, but works otherwise. Hope that helps someone out there.
