How to place a light source on the central body from camera position

Is there an easy way to put a light source (I think what I need is a point light) on the central body (the planet) which is located at the position of the camera. I tried terrainprovider but it uses only sun as a light source (I think?) and the planet is always lightened from one side and shaded from the other. I read about ellipsoidappearance, vertex and fragment shaders, and Centralbody.enablelighting (is that deprecated in latest versions?) but I’m not very familiar and I don’t know what’s the right way to do this. Any help is appreciated.

I just need slight shadows at the edges of the planet, independently of the viewing angle.

I’m willing to pay to whoever helps me achieve this. This is the lighting that I want (see the pic). The planet should always be lit this way, regardlessly of how it’s rotated. If you’re interested, write either here or on my email svetoslav80 at gmail соm

Hey Svetoslav, I have similar lighting requirement, though slightly different angle. Did you solve this? Anything you care share here?

Nope, I was trying to manipulate the time of the day so that the position of the sun changes, using the code:

var date = new Date();
date.setUTCFullYear(2011, 6, 4); // July 4, 2011 @ 12:00 UTC
date.setUTCHours(3, 0, 0, 0);
viewer.scene.globe.enableLighting = true;
viewer.clock.currentTime = JulianDate.fromDate(date);
viewer.clock.multiplier = 1;
viewer.clock.shouldAnimate = true;

But whatever hour of the day I set, it seems the position of the sun is the same, or at least the shadow on the body doesn’t move … I have no idea why.

Ah, it worked as I turned viewer animation on, but it’s not what I need because sun motion is limited.

I’m excited to see this has been implemented in recent versions, here’s an example in sandcastle: , I’m going to look into the code

I’m not sure about an official way to do this, but if you are ok with a hacky solution and don’t mind editing the source code, this should work:

After this line: put the code:

Cartesian3.clone(, uniformState._sunDirectionWC);

Cartesian3.clone(Cartesian3.UNIT_Z, uniformState._sunDirectionEC);

A sample Sandcastle demo for seeing the results:

var viewer = new Cesium.Viewer(‘cesiumContainer’);

var cesiumTerrainProviderMeshes = new Cesium.CesiumTerrainProvider({

url : ‘’,

requestWaterMask : true,

requestVertexNormals : true


viewer.terrainProvider = cesiumTerrainProviderMeshes;

viewer.scene.globe.enableLighting = true;

Sean Lilley Thank you so much. This works. requestWaterMask : true seems to spoils the colors but I removed it and now I have a real 3d planet. Thank you again.

Sean, is there a quick way to apply a similar hack for EllipsoidTerrainProvider instead of STK world terrain, as the last seems to jag the terrain at one particular area on the globe?

Yeah, it’s possible to add specular to the base but without the water mask. In GlobeFS.glsl place code like this after line 175 (tweak to your liking). You will need to run “npm run build” after editing the shader:

// Add specular highlights
vec3 positionToEyeEC = -v_positionEC;
float positionToEyeECLength = length(positionToEyeEC);
// The double normalize below works around a bug in Firefox on Android devices.
vec3 normalizedpositionToEyeEC = normalize(normalize(positionToEyeEC));
float specularIntensity = czm_getSpecular(czm_sunDirectionEC, normalizedpositionToEyeEC, normalEC, 4.0);
float surfaceReflectance = 0.5;
float specular = specularIntensity * surfaceReflectance;
finalColor += specular;


The new Sandcastle is just:

var viewer = new Cesium.Viewer(‘cesiumContainer’);

viewer.scene.globe.enableLighting = true;


I wanted to position the sun/light at the camera too. Have you come across a way to do this without having to edit and compile the source ?

One of the main Cesium developers doesn’t know an official way to do this. No chance that I know something more than him. But it’s really easy to edit / compile the source. Is there a particular reason you don’t want to do this?

I fear botching it up since I’m not a coder by profession. :slight_smile: