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
Types
Properties
The color to clear the output texture to.
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.
The fragment shader to use when execute this post-process stage.
The unique name of this post-process stage for reference by other stages in a PostProcessStageComposite.
The pixel data type of the output texture.
The color pixel format of the output texture.
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.
How to sample the input color texture.
The BoundingRectangle to use for the scissor test. A default bounding rectangle will disable the scissor test.
The features selected for applying the post-process.
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.