how to custom shader in 3d-tiles?

1. A concise explanation of the problem you’re experiencing.

I want to make a function of flattened model , But I don ’ t know how to customize the shader .

2. A minimal code example. If you’ve found a bug, this helps us reproduce and repair it.

3. Context. Why do you need to do this? We might know a better way to accomplish your goal.

4. The Cesium version you’re using, your operating system and browser.

i use 1.40

Hi,

Can you show us an example or image of what you’re looking to accomplish? I’m not sure exactly from just the description.

Thanks,

Gabby

If you are using the b3dm tile format you can embed glTF 1.0 models with custom shaders. Are you wondering how to write a shader that does that effect, or just curious if it is possible?

like this:
http://www.wish3d.com/Examples-inside/Flat.html
在 2017年12月22日星期五 UTC+8上午12:38:36,Gabby Getz写道:

Yeah that flat shading can be accomplished with custom shaders. For example:

Fragment Shader:

precision highp float;
uniform sampler2D u_emission;
varying vec2 v_texcoord_0;
void main(void) {
gl_FragColor = texture2D(u_emission, v_texcoord_0);
}

``

Vertex Shader:

precision highp float;
uniform mat4 u_modelViewProjectionMatrix;
attribute vec3 a_position;
attribute vec2 a_texcoord_0;
varying vec2 v_texcoord_0;
void main(void) {
gl_Position = u_modelViewProjectionMatrix * vec4(a_position, 1.0);
v_texcoord_0 = a_texcoord_0;
}

``

These have to be embedded in the glTF model and the model’s materials/techniques/attributes need to be set up correctly to use these shaders.

If you don’t want to work with shaders at all you can use the KHR_materials_common extension with constant shading: https://github.com/KhronosGroup/glTF/tree/master/extensions/Khronos/KHR_materials_common#constant.

There is also an upcoming extension for glTF 2.0 that supports this: https://github.com/KhronosGroup/glTF/pull/1163.