new Cesium.PostProcessStage(options)

运行一个后处理阶段,要么是场景所渲染的纹理,要么是前一个后处理阶段的输出.
Name Type Description
options object 具有下列属性的天体:
Name Type Default Description
fragmentShader string 碎片遮蔽器 默认的 NT 0 桑普勒2D NT 1 制服为 NT 2 colorTexture NT 3 和 NT 4 深Texture NT 5 . 色彩纹理是渲染场景或前一个阶段的输出. 深度纹理是渲染场景的输出. 遮蔽器应包含一种或两种制服。 还有一个名为 NT 6 vec2 NT 7 的变体,命名为 NT 8 v 文字坐标 NT 9 . 用于样本纹理.
uniforms object optional 一个对象,其属性将用来设置遮阳器制服. 属性可以是常数或函数. 一个恒值也可以是 NT 0 ,数据 NT 1 ,或 NT 2 元素作为纹理使用.
textureScale number 1.0 optional 一个在范围(0.0,1.0]中用来缩放纹理维度的编号. 1.0的尺度将使这个后处理阶段的纹理达到视图的大小.
forcePowerOfTwo boolean false optional Whether or not to force the 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.
sampleMode PostProcessStageSampleMode PostProcessStageSampleMode.NEAREST optional How to sample the input color texture.
pixelFormat PixelFormat PixelFormat.RGBA optional The color pixel format of the output texture.
pixelDatatype PixelDatatype PixelDatatype.UNSIGNED_BYTE optional The pixel data type of the output texture.
clearColor Color Color.BLACK optional The color to clear the output texture to.
scissorRectangle BoundingRectangle optional 用于剪刀测试的矩形.
name string createGuid() optional The unique name of this post-process stage for reference by other stages in a composite. If a name is not supplied, a GUID will be generated.
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

清除输出纹理的颜色 .

enabled : boolean

准备时是否执行此后处理阶段 .

readonly forcePowerOfTwo : number

是否强迫输出的纹理维度是两个的同等权力. 二力是最小维数中二力的下一个力.

readonly fragmentShader : string

执行此后处理阶段时使用的碎片阴影器 .

遮蔽器必须包含一个采样器的统一声明,用于: colorTexture , 深Texture , or both.

The shader must contain a vec2 varying declaration for v_textureCoordinates for sampling 纹理制服.

readonly name : string

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

readonly pixelDatatype : PixelDatatype

输出纹理的像素数据类型.

readonly pixelFormat : PixelFormat

输出纹理的颜色像素格式 .

readonly ready : boolean

确定此进程后阶段是否准备执行 。 一个舞台只有在 NT 0 已经 NT 1 时才执行 and PostProcessStage#enabled are true. A stage will not be ready while it is waiting on textures to load.

readonly sampleMode : PostProcessStageSampleMode

如何取样输入色纹.

readonly scissorRectangle : BoundingRectangle

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

selected : Array

应用后进程所选择的特性 .

在片段阴影中,使用 NT 0 czm select NT 1 确定是否应用后处理 跳到那个碎片。 例如: 如果(czm sselect(v 文字坐标)){ // 应用后处理阶段 } else { out_FragColor = texture(colorTexture, v_textureCoordinates); }

readonly textureScale : number

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.

readonly uniforms : object

用于设定碎片遮蔽器制服的物体.

对象属性值可以是常数,也可以是函数. 函数将调用 后进程阶段执行前的每个框架.

恒定值也可以是图像的 URI ,数据 URI ,或者可以用作纹理的 HTML 元素,如HTMLImageElement或HTMLCanvasElement.

If this post-process stage is part of a PostProcessStageComposite that does not execute in series, the constant value can also be 在复合材料中另一个阶段的名称。 这将设置用于输出纹理的制服 舞台带有这个名称.

Methods

destroy()

Destroys the WebGL resources held by this object. Destroying an object allows for deterministic 释放 WebGL 资源,而不是依赖垃圾收集器来摧毁此对象.

Once an object is destroyed, it should not be used; calling any function other than isDestroyed will result in a DeveloperError 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.
See:

isDestroyed()boolean

如果此对象被销毁, 返回真实; 否则, 错误 .

If this object was destroyed, it should not be used; calling any function other than isDestroyed will result in a DeveloperError exception.

Returns:
true if this object was destroyed; otherwise, false.
See:
Need help? The fastest way to get answers is from the community and team on the Cesium Forum.