# PostProcessStageLibrary

Scene/PostProcessStageLibrary.js 33
Contains functions for creating common post-process stages.

### Methods

#### static Cesium.PostProcessStageLibrary.createBlackAndWhiteStage() → PostProcessStage
Scene/PostProcessStageLibrary.js 761

Creates a post-process stage that renders the input texture with black and white gradations.

This stage has one uniform value, `gradations`, which scales the luminance of each pixel.

##### Returns:

A post-process stage that renders the input texture with black and white gradations.

#### static Cesium.PostProcessStageLibrary.createBlurStage() → PostProcessStageComposite
Scene/PostProcessStageLibrary.js 121

Creates a post-process stage that applies a Gaussian blur to the input texture. This stage is usually applied in conjunction with another stage.

This stage has the following uniforms: `delta`, `sigma`, and `stepSize`.

`delta` and `sigma` are used to compute the weights of a Gaussian filter. The equation is `exp((-0.5 * delta * delta) / (sigma * sigma))`. The default value for `delta` is `1.0`. The default value for `sigma` is `2.0`. `stepSize` is the distance to the next texel. The default is `1.0`.

##### Returns:

A post-process stage that applies a Gaussian blur to the input texture.

#### static Cesium.PostProcessStageLibrary.createBrightnessStage() → PostProcessStage
Scene/PostProcessStageLibrary.js 778

Creates a post-process stage that saturates the input texture.

This stage has one uniform value, `brightness`, which scales the saturation of each pixel.

##### Returns:

A post-process stage that saturates the input texture.

#### static Cesium.PostProcessStageLibrary.createDepthOfFieldStage() → PostProcessStageComposite
Scene/PostProcessStageLibrary.js 143

Creates a post-process stage that applies a depth of field effect.

Depth of field simulates camera focus. Objects in the scene that are in focus will be clear whereas objects not in focus will be blurred.

This stage has the following uniforms: `focalDistance`, `delta`, `sigma`, and `stepSize`.

`focalDistance` is the distance in meters from the camera to set the camera focus.

`delta`, `sigma`, and `stepSize` are the same properties as `PostProcessStageLibrary#createBlurStage`. The blur is applied to the areas out of focus.

##### Returns:

A post-process stage that applies a depth of field effect.

#### static Cesium.PostProcessStageLibrary.createEdgeDetectionStage() → PostProcessStage
Scene/PostProcessStageLibrary.js 243

Creates a post-process stage that detects edges.

Writes the color to the output texture with alpha set to 1.0 when it is on an edge.

This stage has the following uniforms: `color` and `length`

- `color` is the color of the highlighted edge. The default is `Color#BLACK`.
- `length` is the length of the edges in pixels. The default is `0.5`.

This stage is not supported in 2D.

##### Returns:

A post-process stage that applies an edge detection effect.

##### Example:

    // multiple silhouette effects
    var yellowEdge = Cesium.PostProcessLibrary.createEdgeDetectionStage();
    yellowEdge.uniforms.color = Cesium.Color.YELLOW;
    yellowEdge.selected = [feature0];

    var greenEdge = Cesium.PostProcessLibrary.createEdgeDetectionStage();
    greenEdge.uniforms.color = Cesium.Color.LIME;
    greenEdge.selected = [feature1];

    // draw edges around feature0 and feature1
    postProcessStages.add(Cesium.PostProcessLibrary.createSilhouetteStage([yellowEdge, greenEdge]);

#### static Cesium.PostProcessStageLibrary.createLensFlareStage() → PostProcessStage
Scene/PostProcessStageLibrary.js 830

Creates a post-process stage that applies an effect simulating light flaring a camera lens.

This stage has the following uniforms: `dirtTexture`, `starTexture`, `intensity`, `distortion`, `ghostDispersal`, `haloWidth`, `dirtAmount`, and `earthRadius`.

- `dirtTexture` is a texture sampled to simulate dirt on the lens.
- `starTexture` is the texture sampled for the star pattern of the flare.
- `intensity` is a scalar multiplied by the result of the lens flare. The default value is `2.0`.
- `distortion` is a scalar value that affects the chromatic effect distortion. The default value is `10.0`.
- `ghostDispersal` is a scalar indicating how far the halo effect is from the center of the texture. The default value is `0.4`.
- `haloWidth` is a scalar representing the width of the halo from the ghost dispersal. The default value is `0.4`.
- `dirtAmount` is a scalar representing the amount of dirt on the lens. The default value is `0.4`.
- `earthRadius` is the maximum radius of the earth. The default value is `Ellipsoid.WGS84.maximumRadius`.

##### Returns:

A post-process stage for applying a lens flare effect.

#### static Cesium.PostProcessStageLibrary.createNightVisionStage() → PostProcessStage
Scene/PostProcessStageLibrary.js 792

Creates a post-process stage that adds a night vision effect to the input texture.

##### Returns:

A post-process stage that adds a night vision effect to the input texture.

#### static Cesium.PostProcessStageLibrary.createOutlineForPrimitivesStage(size, color) → PostProcessStage
Scene/PostProcessStageLibrary.js 910

创建一个后处理阶段，用于渲染MapGISM3D的轮廓

Name | Type | Description
--- | --- | ---
`size` | Number | 轮廓线的大小(单位：像素) 不可以使用uniforms修改值。若要修改轮廓线宽度，需要重新创建此后处理stage。
`color` | Color | 轮廓线的颜色

##### Returns:

##### Example:

    var url = 'http://192.168.82.89:8200/3DData/ModelCache/M3D/2.0/高级住所模型/高级住所模型.mcj';
    var options = {
        renderMode: Cesium.OutlineRenderMode.ALL // 设置此M3D模型的轮廓渲染模式
    };
    viewer.scene.layers.appendM3DLayer(url, options);

    var stages = viewer.scene.postProcessStages;
    var outlineStage = stages.add(Cesium.PostProcessStageLibrary.createOutlineForPrimitivesStage(2, Cesium.Color.LIME));
    // 1. 修改轮廓线颜色
    outlineStage.uniforms.color = Cesium.Color.BLUE;
    // 2. 修改轮廓线宽度
    stages.remove(outlineStage);
    outlineStage = stages.add(Cesium.PostProcessStageLibrary.createOutlineForPrimitivesStage(3, Cesium.Color.LIME));

#### static Cesium.PostProcessStageLibrary.createOutlineStage(size, color) → PostProcessStage
Scene/PostProcessStageLibrary.js 868

创建一个后处理阶段，用于显示指定OID的模型轮廓
目前只支持M3D2.0的数据

Name | Type | Description
--- | --- | ---
`size` | Number | 轮廓线的大小(单位：像素) 不可以使用uniforms修改值。若要修改轮廓线宽度，需要重新创建此后处理stage。
`color` | Color | 轮廓线的颜色

##### Returns:

##### Example:

    var stages = viewer.scene.postProcessStages;
    var outlineStage = stages.add(Cesium.PostProcessStageLibrary.createOutlineStage(2, Cesium.Color.LIME));
    // 1. 传入模型OID
    outlineStage.selected = [56, 57, 58, 59];
    // 2. 修改轮廓线颜色
    outlineStage.uniforms.color = Cesium.Color.BLUE;
    // 3. 修改轮廓线宽度
    // 删除旧的stage
    stages.remove(outlineStage);
    // 重新创建新的stage
    outlineStage = stages.add(Cesium.PostProcessStageLibrary.createOutlineStage(3, Cesium.Color.LIME));

#### static Cesium.PostProcessStageLibrary.createSilhouetteStage(edgeDetectionStages) → PostProcessStageComposite
Scene/PostProcessStageLibrary.js 346

Creates a post-process stage that applies a silhouette effect.

A silhouette effect composites the color from the edge detection pass with input color texture.

This stage has the following uniforms when `edgeDetectionStages` is `undefined`: `color` and `length`

`color` is the color of the highlighted edge. The default is `Color#BLACK`. `length` is the length of the edges in pixels. The default is `0.5`.

Name | Type | Description
--- | --- | ---
`edgeDetectionStages` | Array.<PostProcessStage> | optional An array of edge detection post process stages.

##### Returns:

A post-process stage that applies a silhouette effect.

#### static Cesium.PostProcessStageLibrary.isAmbientOcclusionSupported(scene) → Boolean
Scene/PostProcessStageLibrary.js 652

Whether or not an ambient occlusion stage is supported.

This stage requires the WEBGL_depth_texture extension.

Name | Type | Description
--- | --- | ---
`scene` | Scene | The scene.

##### Returns:

Whether this post process stage is supported.

##### See:

- {Context#depthTexture}
- WEBGL_depth_texture

#### static Cesium.PostProcessStageLibrary.isDepthOfFieldSupported(scene) → Boolean
Scene/PostProcessStageLibrary.js 209

Whether or not a depth of field stage is supported.

This stage requires the WEBGL_depth_texture extension.

Name | Type | Description
--- | --- | ---
`scene` | Scene | The scene.

##### Returns:

Whether this post process stage is supported.

##### See:

- {Context#depthTexture}
- WEBGL_depth_texture

#### static Cesium.PostProcessStageLibrary.isEdgeDetectionSupported(scene) → Boolean
Scene/PostProcessStageLibrary.js 268

Whether or not an edge detection stage is supported.

This stage requires the WEBGL_depth_texture extension.

Name | Type | Description
--- | --- | ---
`scene` | Scene | The scene.

##### Returns:

Whether this post process stage is supported.

##### See:

- {Context#depthTexture}
- WEBGL_depth_texture

#### static Cesium.PostProcessStageLibrary.isSilhouetteSupported(scene) → Boolean
Scene/PostProcessStageLibrary.js 376

Whether or not a silhouette stage is supported.

This stage requires the WEBGL_depth_texture extension.

Name | Type | Description
--- | --- | ---
`scene` | Scene | The scene.

##### Returns:

Whether this post process stage is supported.

##### See:

- {Context#depthTexture}
- WEBGL_depth_texture