A user defined GLSL shader used with
Model as well
as Cesium3DTileset.
如果使用纹理制服,必须进行额外的资源管理:
-
update1 函数必须称为每个帧. 当 a custom shader is passed to aModelor aCesium3DTileset, this step is handled automaticaly -
CustomShader#destroymust be called when the custom shader is 不再需要适当清理 NT 0 资源. 申请 负责使用这种方法.
See the Custom Shader Guide for more detailed documentation.
| Name | Type | Description | ||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object |
具有以下选项的对象
|
Example:
const customShader = new CustomShader({
uniforms: {
u_colorIndex: {
type: Cesium.UniformType.FLOAT,
value: 1.0
},
u_normalMap: {
type: Cesium.UniformType.SAMPLER_2D,
value: new Cesium.TextureUniform({
url: "http://example.com/normal.png"
})
}
},
varyings: {
v_selectedColor: Cesium.VaryingType.VEC3
},
vertexShaderText: `
void vertexMain(VertexInput vsInput, inout czm_modelVertexOutput vsOutput) {
v_selectedColor = mix(vsInput.attributes.color_0, vsInput.attributes.color_1, u_colorIndex);
vsOutput.positionMC += 0.1 * vsInput.attributes.normal;
}
`,
fragmentShaderText: `
void fragmentMain(FragmentInput fsInput, inout czm_modelMaterial material) {
material.normal = texture(u_normalMap, fsInput.attributes.texCoord_0);
material.diffuse = v_selectedColor;
}
`
});
Experimental
This feature is using part of the 3D Tiles spec that is not final and is subject to change without Cesium's standard deprecation policy.
Members
碎片遮蔽器的用户定义 NT% 0 代码
readonly lightingModel : LightingModel
使用自定义阴影器时使用的照明模型.
This is used by
CustomShaderPipelineStage
readonly mode : CustomShaderMode
确定自定义阴影与总体互动的值
fragment shader. This is used by
CustomShaderPipelineStage
readonly translucencyMode : CustomShaderTranslucencyMode
透明模式,它决定如何应用自定义阴影。 如果数值是
NT 0 或 NT 1 ,自定义阴影
将覆盖模型材料中的设置。 如果值为 NT 0 ,
根据原始物质的设置,自定义的遮阳器将变成不透明或半透明.
-
Default Value:
CustomShaderTranslucencyMode.INHERIT
readonly uniforms : Object.<string, UniformSpecifier>
用户申报的其他制服.
readonly varyings : Object.<string, VaryingType>
用户宣布的其他差异.
This is used by
CustomShaderPipelineStage
顶点遮蔽器的用户定义的 NT% 0 代码
Methods
Destroys the WebGL resources held by this object. Destroying an object allows for deterministic
释放 WebGL 资源,而不是依赖垃圾收集器来摧毁此对象.
Once an object is destroyed, it should not be used; calling any function other than
Once an object is destroyed, it should not be used; calling any function other than
isDestroyed will result in a DeveloperError exception. Therefore,
assign the return value (undefined) to the object as done in the example.
Throws:
-
DeveloperError : This object was destroyed, i.e., destroy() was called.
Example:
customShader = customShader && customShader.destroy();
See:
如果此对象被销毁, 返回真实; 否则, 错误 .
If this object was destroyed, it should not be used; calling any function other than
If this object was destroyed, it should not be used; calling any function other than
isDestroyed will result in a DeveloperError exception.
Returns:
如果此天体被销毁, 则属真; 否则, 属假 .
See:
更新阴影中宣布的制服值
| Name | Type | Description |
|---|---|---|
uniformName |
string | 校服名称 GLSL . 这一定跟建筑师的制服相符 |
value |
boolean | number | Cartesian2 | Cartesian3 | Cartesian4 | Matrix2 | Matrix3 | Matrix4 | string | Resource | TextureUniform | 制服的新价值. |