I have searched the forum and found many infomation about that:
I. It's possible: https://cesiumjs.org/forum/#!msg/cesium-dev/gSc0w3ZfsM4/lzquFvpFAwAJ
II. Maybe I need to dig into the source code of cesium shader/material pipeline to make a custom shader work. I'm not sure about this.
III. I found something directly related to shader in `MaterialAppearance`(`vertexShaderSource` and `fragmentShaderSource`), but I failed to find shader code in the example or the *Cesium Sandcastle Material Appearance Demo* in https://cesiumjs.org/Cesium/Build/Documentation/MaterialAppearance.html
2. A minimal code example. If you've found a bug, this helps us reproduce and repair it.
(none)
3. Context. Why do you need to do this? We might know a better way to accomplish your goal.
I need to write custom shaders for custom water, particle-based cloud or mist wich can be placed at any position.
The final scene is like this: http://map.baidu.com/scenic3d/index.html?id=qinghuiyuan
But the dark areas around the center light part will be replaced with water (acts as the ocean).
result illustration: https://i.imgur.com/wB7HXaV.jpg
4. The Cesium version you're using, your operating system and browser.
Cesium version: 1.35
operating system: win10 x64
browser: Google Chrome 63.0.3239.132
I'm not sure if any of the existing classes will really meet your needs. In the end you might have to create new primitive types that control their WebGL resources directly.
In the end you might have to create new primitive types that control their WebGL resources directly.
With Cesium, there's a few options for custom rendering. From most common (and easiest) to less common:
- Create geometries for your data from Cesium's large geometry collection (tutorial). This doesn't require any WebGL.
- Create custom geometries, basically vertex and index buffers, and appearances, basically shaders and render state (partial draft tutorial). Mix and match your own with Cesium's collection. This can require writing GLSL shaders, but the other WebGL features are abstracted.
- Implement a Cesium primitive, which has full access to the Cesium renderer - including vertex arrays, buffers, textures, render state, shader programs, framebuffers, etc. A simple example is the EllipsoidPrimitive.
Even the last option above doesn't use WebGL directly, except for writing GLSL shaders. Modern engines, including Cesium, abstract the graphics API, which makes it easier to use and generally faster since it allows the engine to centralize optimizations like minimizing GL state changes. Porting your OpenGL code to use the Cesium renderer should be pretty easy. If your case is simple enough, creating or using existing geometries and appearances will be the easiest approach.If you can tell us more about how your currently using OpenGL, I can provide more concrete advice.Patrick