| 名称 Name | 类型 Type | 说明 Description | ||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object |
具有以下属性的对象: An object with the following properties:
|
抛出: Throws:
-
DeveloperError :options.textureScale 必须大于 0.0 且小于或等于 1.0。 : options.textureScale must be greater than 0.0 and less than or equal to 1.0.
-
DeveloperError : options.pixelFormat must be a color format.
-
DeveloperError :当 options.pixelDatatype 为 FLOAT 时,此 WebGL 实现必须支持浮点纹理。检查 context.floatingPointTexture。 : When options.pixelDatatype is FLOAT, this WebGL implementation must support floating point textures. Check context.floatingPointTexture.
示例: Examples:
// Simple stage to change the color
const fs =`
uniform sampler2D colorTexture;
in vec2 v_textureCoordinates;
uniform float scale;
uniform vec3 offset;
void main() {
vec4 color = texture(colorTexture, v_textureCoordinates);
out_FragColor = vec4(color.rgb * scale + offset, 1.0);
}`;
scene.postProcessStages.add(new Cesium.PostProcessStage({
fragmentShader : fs,
uniforms : {
scale : 1.1,
offset : function() {
return new Cesium.Cartesian3(0.1, 0.2, 0.3);
}
}
}));
// Simple stage to change the color of what is selected.
// If czm_selected returns true, the current fragment belongs to geometry in the selected array.
const fs =`
uniform sampler2D colorTexture;
in vec2 v_textureCoordinates;
uniform vec4 highlight;
void main() {
vec4 color = texture(colorTexture, v_textureCoordinates);
if (czm_selected()) {
vec3 highlighted = highlight.a * highlight.rgb + (1.0 - highlight.a) * color.rgb;
out_FragColor = vec4(highlighted, 1.0);
} else {
out_FragColor = color;
}
}`;
const stage = scene.postProcessStages.add(new Cesium.PostProcessStage({
fragmentShader : fs,
uniforms : {
highlight : function() {
return new Cesium.Color(1.0, 0.0, 0.0, 0.5);
}
}
}));
stage.selected = [cesium3DTileFeature];
另见: See:
成员 Members
readonly clearColor : Color
着色器必须包含采样器统一声明 The shader must contain a sampler uniform declaration for colorTexture, depthTexture,或两者兼而有之。 , or both.
着色器必须包含一个 The shader must contain a vec2 不同的声明 varying declaration for v_textureCoordinates 用于采样纹理制服。 for sampling the texture uniforms.
PostProcessStageComposite.
readonly pixelDatatype : PixelDatatype
readonly pixelFormat : PixelFormat
ready
and PostProcessStage#enabled are true。舞台在等待纹理加载时不会准备好。 . A stage will not be ready while it is waiting on textures to load.
readonly sampleMode : PostProcessStageSampleMode
readonly scissorRectangle : BoundingRectangle
BoundingRectangle 用于剪刀测试。默认边界矩形将禁用剪刀测试。 to use for the scissor test. A default bounding rectangle will disable the scissor test.
在片段着色器中,使用 In the fragment shader, use czm_selected 确定是否对该片段应用后处理阶段。例如: to determine whether or not to apply the post-process stage to that fragment. For example:
if (czm_selected(v_textureCoordinates)) {
// apply post-process stage
} else {
out_FragColor = texture(colorTexture, v_textureCoordinates);
}
对象属性值可以是常量或函数。在执行后处理阶段之前,每帧都会调用该函数。 The object property values can be either a constant or a function. The function will be called each frame before the post-process stage is executed.
常量值还可以是图像的 URI、数据 URI 或可用作纹理的 HTML 元素,例如 HTMLImageElement 或 HTMLCanvasElement。 A constant value can also be a URI to an image, a data URI, or an HTML element that can be used as a texture, such as HTMLImageElement or HTMLCanvasElement.
如果此后处理阶段是 If this post-process stage is part of a PostProcessStageComposite 如果不串行执行,则常量值也可以是组合中另一个阶段的名称。这会将统一设置为具有该名称的舞台的输出纹理。 that does not execute in series, the constant value can also be the name of another stage in a composite. This will set the uniform to the output texture the stage with that name.
方法 Methods
一旦对象被销毁,就不应再使用;调用除 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.
另见: See:
如果该对象被破坏,则不应使用它;调用除 If this object was destroyed, it should not be used; calling any function other than
isDestroyed 将导致 will result in a DeveloperError exception.
返回: Returns:
true 如果该物体被摧毁;否则, if this object was destroyed; otherwise, false.
