在场景渲染的纹理或前一个后处理阶段的输出上运行后处理阶段。
Name | Type | Description | ||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object |
对象,具有以下属性:
|
Throws:
-
DeveloperError : 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 : 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
将输出纹理清除为的颜色。
准备就绪时是否执行此后处理阶段。
是否强制输出纹理尺寸均为 2 的幂。2 的幂将是最小维度中 2 的次幂。
执行此后处理阶段时要使用的片段着色器。
着色器必须包含 colorTexture
、depthTexture
、
或两者兼而有之。
着色器必须包含 vec2
varying 声明,用于采样的 v_textureCoordinates
纹理均匀。
此后处理阶段的唯一名称,供
PostProcessStageComposite
中的其他阶段引用。
readonly pixelDatatype : PixelDatatype
输出纹理的 pixel 数据类型。
readonly pixelFormat : PixelFormat
输出纹理的颜色像素格式。
readonly sampleMode : PostProcessStageSampleMode
如何对输入颜色纹理进行采样。
readonly scissorRectangle : BoundingRectangle
用于 scissor 测试的
BoundingRectangle
。默认边界矩形将禁用 scissor 测试。
为应用后处理而选择的功能。
在片段着色器中,使用 czm_selected
来确定是否应用后期处理
stage 添加到该 fragment 中。例如:
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
。