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