central body vertex shader

Hi,

Just wondering whether I can switch in an alternate central body vertex shader at runtime?

These lines seem to be getting called e.g. when I change from 3d to 2d view etc. But what is the ‘CentralBodyVS’ it refers to? I tried setting Cesium._shaders.CentralBodyVS to an alternate string, but that doesn’t seem to work.

Thanks,
Chris

Hey Chris,

The CentralBodyVS instance you see in the code you highlighted is loaded via AMD from a .js file created at build time from a .glsl file. As far as I know (@shunter will correct me if I’m wrong) there’s no way to swap in a new version at runtime, without changing the Cesium code itself. Tell me a little about what you’re trying to do and maybe I can make a recommendation.

Kevin

Ok thanks Kevin.

I want to be able to e.g. use the default Cesium shader(s) in most cases, then switch in another shader if the user hits a button. I was trying to do this rather than run a larger/heavier patched Cesium shader all the time. Conceptually similar to the way the shader currently gets built differently depending on the view requirements, rather than having one massive shader with switches in it. I might look at whether I can add a hook in near those lines I highlighted to allow substituting an alternate string.

Thanks,
Chris

Ok, makes sense. If you’re going to change Cesium code, you should take a look at CentralBodySurfaceShaderSet.js:
https://github.com/AnalyticalGraphicsInc/cesium/blob/b13/Source/Scene/CentralBodySurfaceShaderSet.js

It should be fairly straightforward to extend it to keep two sets of cached shaders, one for the standard shader (which uses the this.baseVertexShaderString supplied by the CentralBody) and one for your custom shader (supplied as a separate property). Then another property could indicate the current mode, selecting which set to use.

Kevin