Name | Type | Description | ||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
An object with the following properties:
|
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 the OES_texture_float extension. Check context.floatingPointTexture.
- PostProcessStageComposite
Examples:
// Simple stage to change the color
var fs =
'uniform sampler2D colorTexture;\n' +
'varying vec2 v_textureCoordinates;\n' +
'uniform float scale;\n' +
'uniform vec3 offset;\n' +
'void main() {\n' +
' vec4 color = texture2D(colorTexture, v_textureCoordinates);\n' +
' gl_FragColor = vec4(color.rgb * scale + offset, 1.0);\n' +
'}\n';
scene.postProcessStages.add(new SuperMap3D.PostProcessStage({
fragmentShader : fs,
uniforms : {
scale : 1.1,
offset : function() {
return new SuperMap3D.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.
var fs =
'uniform sampler2D colorTexture;\n' +
'varying vec2 v_textureCoordinates;\n' +
'uniform vec4 highlight;\n' +
'void main() {\n' +
' vec4 color = texture2D(colorTexture, v_textureCoordinates);\n' +
' if (czm_selected()) {\n' +
' vec3 highlighted = highlight.a * highlight.rgb + (1.0 - highlight.a) * color.rgb;\n' +
' gl_FragColor = vec4(highlighted, 1.0);\n' +
' } else { \n' +
' gl_FragColor = color;\n' +
' }\n' +
'}\n';
var stage = scene.postProcessStages.add(new SuperMap3D.PostProcessStage({
fragmentShader : fs,
uniforms : {
highlight : function() {
return new SuperMap3D.Color(1.0, 0.0, 0.0, 0.5);
}
}
}));
stage.selected = [cesium3DTileFeature];
See:
Members
-
readonlyclearColor : Color
-
The color to clear the output texture to.
-
Whether or not to execute this post-process stage when ready.
-
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 shader must contain a sampler uniform declaration for
colorTexture
,depthTexture
, or both.The shader must contain a
vec2
varying declaration forv_textureCoordinates
for sampling the texture uniforms. -
The unique name of this post-process stage for reference by other stages in a
PostProcessStageComposite
. -
The pixel data type of the output texture.
-
readonlypixelFormat : PixelFormat
-
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
andPostProcessStage#enabled
aretrue
. A stage will not be ready while it is waiting on textures to load. -
How to sample the input color texture.
-
readonlyscissorRectangle : BoundingRectangle
-
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.
In the fragment shader, use
czm_selected
to determine whether or not to apply the post-process stage to that fragment. For example:if (czm_selected(v_textureCoordinates)) { // apply post-process stage } else { gl_FragColor = texture2D(colorTexture, v_textureCordinates); }
-
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.
-
An object whose properties are used to set the uniforms of the fragment shader.
The object property values can be either a constant or a function. The function will be called each frame before the post-process stage is executed.
A constant value can also be a URI to an image, a data URI, or an HTML element that can be used as a texture, such as HTMLImageElement or HTMLCanvasElement.
If this post-process stage is part of a
PostProcessStageComposite
that does not execute in series, the constant value can also be the name of another stage in a composite. This will set the uniform to the output texture the stage with that name.
Methods
-
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.
Once an object is destroyed, it should not be used; calling any function other than
isDestroyed
will result in aDeveloperError
exception. Therefore, assign the return value (undefined
) to the object as done in the example.Throws:
-
DeveloperError : This object was destroyed, i.e., destroy() was called.
-
-
Returns true if this object was destroyed; otherwise, false.
If this object was destroyed, it should not be used; calling any function other than
isDestroyed
will result in aDeveloperError
exception.Returns:
true
if this object was destroyed; otherwise,false
.