PostProcessStage

Runs a post-process stage on either the texture rendered by the scene or the output of a previous post-process stage.

// 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 PostProcessStage({
fragmentShader : fs,
uniforms : {
scale : 1.1,
offset : function() {
return new 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 PostProcessStage({
fragmentShader : fs,
uniforms : {
highlight : function() {
return new Color(1.0, 0.0, 0.0, 0.5);
}
}
}));
stage.selected = [cesium3DTileFeature];

See also

Constructors

Link copied to clipboard

Types

Link copied to clipboard

Properties

Link copied to clipboard

The color to clear the output texture to.

Link copied to clipboard

Whether or not to execute this post-process stage when ready.

Link copied to clipboard

Whether or not to force the output texture dimensions to be both equal powers of two. The power of two will be the next power of two of the minimum of the dimensions.

Link copied to clipboard

The fragment shader to use when execute this post-process stage.

Link copied to clipboard

The unique name of this post-process stage for reference by other stages in a PostProcessStageComposite.

Link copied to clipboard

The pixel data type of the output texture.

Link copied to clipboard

The color pixel format of the output texture.

Link copied to clipboard

Determines if this post-process stage is ready to be executed. A stage is only executed when both ready and PostProcessStage.enabled are true. A stage will not be ready while it is waiting on textures to load.

Link copied to clipboard

How to sample the input color texture.

Link copied to clipboard

The BoundingRectangle to use for the scissor test. A default bounding rectangle will disable the scissor test.

Link copied to clipboard

The features selected for applying the post-process.

Link copied to clipboard

A number in the range (0.0, 1.0] used to scale the output texture dimensions. A scale of 1.0 will render this post-process stage to a texture the size of the viewport.

Link copied to clipboard

An object whose properties are used to set the uniforms of the fragment shader.

Functions

Link copied to clipboard
fun destroy()

Destroys the WebGL resources held by this object. Destroying an object allows for deterministic release of WebGL resources, instead of relying on the garbage collector to destroy this object.

Link copied to clipboard

Returns true if this object was destroyed; otherwise, false.