Home Reference Source
import {EdgeDetectionMaterial} from 'postprocessing'
public class | source

EdgeDetectionMaterial

Extends:

three~ShaderMaterial → EdgeDetectionMaterial

An edge detection material.

Mainly used for Subpixel Morphological Antialiasing.

Constructor Summary

Public Constructor
public

constructor(texelSize: Vector2, mode: EdgeDetectionMode)

Constructs a new edge detection material.

Member Summary

Public Members
public get

The current depth packing.

public set

Sets the depth packing.

public

Method Summary

Public Methods
public

Sets the edge detection mode.

public

Sets the edge detection sensitivity.

public

Sets the local contrast adaptation factor.

public

setPredicationBuffer(predicationBuffer: Texture)

Sets a custom predication buffer.

public

Sets the predication mode.

public

Sets the predication scale.

public

Sets the predication strength.

public

Sets the predication threshold.

Public Constructors

public constructor(texelSize: Vector2, mode: EdgeDetectionMode) source

Constructs a new edge detection material.

Params:

NameTypeAttributeDescription
texelSize Vector2
  • optional

The screen texel size.

mode EdgeDetectionMode
  • optional
  • default: EdgeDetectionMode.COLOR

The edge detection mode.

TODO:

  • Remove texelSize parameter.

Public Members

public get depthPacking: Number source

The current depth packing.

public set depthPacking: Number source

Sets the depth packing.

public needsUpdate: boolean source

Public Methods

public setEdgeDetectionMode(mode: EdgeDetectionMode) source

Sets the edge detection mode.

Params:

NameTypeAttributeDescription
mode EdgeDetectionMode

The edge detection mode.

public setEdgeDetectionThreshold(threshold: Number) source

Sets the edge detection sensitivity.

A lower value results in more edges being detected at the expense of performance.

For luma- and chroma-based edge detection, 0.1 is a reasonable value and allows to catch most visible edges. 0.05 is a rather overkill value that allows to catch 'em all. Darker scenes may require an even lower threshold.

If depth-based edge detection is used, the threshold will depend on the scene depth.

Params:

NameTypeAttributeDescription
threshold Number

The edge detection sensitivity. Range: [0.0, 0.5].

public setLocalContrastAdaptationFactor(factor: Number) source

Sets the local contrast adaptation factor. Has no effect if the edge detection mode is set to DEPTH.

If there is a neighbor edge that has factor times bigger contrast than the current edge, the edge will be discarded.

This allows to eliminate spurious crossing edges and is based on the fact that if there is too much contrast in a direction, the perceptual contrast in the other neighbors will be hidden.

Params:

NameTypeAttributeDescription
factor Number

The local contrast adaptation factor. Default is 2.0.

public setPredicationBuffer(predicationBuffer: Texture) source

Sets a custom predication buffer.

Params:

NameTypeAttributeDescription
predicationBuffer Texture

The predication buffer.

public setPredicationMode(mode: PredicationMode) source

Sets the predication mode.

Predicated thresholding allows to better preserve texture details and to improve edge detection using an additional buffer such as a light accumulation or depth buffer.

Params:

NameTypeAttributeDescription
mode PredicationMode

The predication mode.

public setPredicationScale(scale: Number) source

Sets the predication scale.

Determines how much the edge detection threshold should be scaled when using predication.

Params:

NameTypeAttributeDescription
scale Number

The scale. Range: [1.0, 5.0].

public setPredicationStrength(strength: Number) source

Sets the predication strength.

Determines how much the edge detection threshold should be decreased locally when using predication.

Params:

NameTypeAttributeDescription
strength Number

The strength. Range: [0.0, 1.0].

public setPredicationThreshold(threshold: Number) source

Sets the predication threshold.

Params:

NameTypeAttributeDescription
threshold Number

The threshold.