在场景渲染的纹理或上一个后处理阶段的输出上运行一个后处理阶段。
| Name | Type | Description | ||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object |
An object with the following properties:
|
Throws:
-
DeveloperError : options.textureScale 必须大于 0.0 且小于或等于 1.0。
-
DeveloperError : options.pixelFormat 必须是颜色格式。
-
DeveloperError : 当 options.pixelDatatype 为 FLOAT 时,此 WebGL 实现必须支持浮点纹理。请检查 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
用于清除输出纹理的颜色。
准备好时是否执行此后处理阶段。
是否强制输出纹理尺寸同时为 2 的幂。该幂将是尺寸最小值向上取到的下一个 2 的幂。
执行此后处理阶段时要使用的片元着色器。
着色器必须包含 colorTexture、depthTexture 之一或两者的采样器 uniform 声明。
着色器必须包含用于采样纹理 uniforms 的 v_textureCoordinates 的 vec2 varying 声明。
此后处理阶段的唯一名称,供
PostProcessStageComposite 中的其他阶段引用。
readonly pixelDatatype : PixelDatatype
输出纹理的像素数据类型。
readonly pixelFormat : PixelFormat
输出纹理的颜色像素格式。
readonly sampleMode : PostProcessStageSampleMode
如何对输入颜色纹理进行采样。
readonly scissorRectangle : BoundingRectangle
用于剪刀测试的
BoundingRectangle。默认的包围矩形将禁用剪刀测试。
为应用后处理而选中的要素。
在片元着色器中,使用 czm_selected 来判断是否对该片元应用后处理
阶段。例如:
if (czm_selected(v_textureCoordinates)) {
// 应用后处理阶段
} else {
out_FragColor = texture(colorTexture, v_textureCoordinates);
}
一个范围在 (0.0, 1.0] 内的数值,用于缩放输出纹理尺寸。缩放为 1.0 时,此后期处理阶段将渲染到与视口大小相同的纹理。
一个对象,其属性用于设置片元着色器的 uniforms。
对象的属性值可以是常量或函数。该函数会在 后处理阶段执行前的每一帧被调用。
常量值也可以是图像的 URI、data URI,或可用作纹理的 HTML 元素,例如 HTMLImageElement 或 HTMLCanvasElement。
如果此后处理阶段是 PostProcessStageComposite 的一部分且不按串行执行,则该常量值也可以
是该组合中另一个阶段的名称。这会将 uniform 设置为具有该名称阶段的输出纹理。
Methods
销毁此对象持有的 WebGL 资源。销毁对象可以实现 WebGL 资源的确定性
释放,而不是依赖垃圾回收器来销毁此对象。
对象一旦被销毁就不应再使用;除
isDestroyed 之外的任何函数调用都将导致 DeveloperError 异常。因此,
应将返回值(undefined)赋给该对象,如示例所示。
Throws:
-
DeveloperError : 此对象已被销毁,即已调用 destroy()。
如果此对象已被销毁则返回 true;否则返回 false。
如果此对象已被销毁,就不应再使用;除
isDestroyed 之外的任何函数调用都将导致 DeveloperError 异常。
Returns:
如果此对象已被销毁则为
true,否则为 false。
