The Camera that owns this filter.
Optionaledge1: number | number[]
The first edge of the threshold. This may be an array of the RGBA channels, or a single number to apply to all 4 channels. Default 0.5.
Optionaledge2: number | number[]
The second edge of the threshold. This may be an array of the RGBA channels, or a single number to apply to all 4 channels. Default 0.5.
Optionalinvert: boolean | boolean[]
Whether each channel is inverted. This may be an array of the RGBA channels, or a single boolean to apply to all 4 channels. Default false.
Toggle this boolean to enable or disable this filter, without removing it from and re-adding it to the Camera's filter list.
ReadonlyallowIf true, this filter will be permitted to draw to the base texture.
This can be unwanted if, for example, the filter doesn't actually
draw anything.
This is an internal flag used by the renderer. You should not modify this value directly.
A reference to the Camera that owns this filter.
The padding currently being used by this filter.
This is read during rendering via getPadding, and may be updated by subclass implementations.
It is necessary for filters being used in an external list.
You should not modify this value directly.
The first edge of the threshold. This contains the lowest value for each channel.
The second edge of the threshold. This contains the highest value for each channel. If it is the same as the first edge, the threshold is a single value.
Whether this filter controller will be destroyed when the FilterList that owns it is destroyed. If you enable this, you must ensure that you clean up the filter controller at an appropriate time. This allows you to reuse a controller for multiple objects; this is not recommended unless you know what you're doing. It tends to work best with external filters.
Whether each channel is inverted. When a channel is inverted, its output is flipped so that values that would normally output 0 instead output 1, and vice versa. This applies per-channel to the RGBA components of the threshold result.
Padding override. This is on by default. If this is set,
the filter will use this padding instead of calculating it.
Prefer using setPaddingOverride instead of modifying this directly.
The ID of the RenderNode that this filter uses.
Destroys this Controller and nulls any references it holds.
Returns the raw padding required for this filter.
This is typically not what you want to call; use getPaddingCeil instead.
Values from this method are not rounded, which can cause quality loss.
Override this method when creating a Filter that requires extra room, e.g. a blur or glow effect.undefined
The padding required by this filter.
Returns the rounded padding required for this filter.
Most filters don't need extra padding, but some may sample beyond the texture boundaries, such as a blur or glow effect.
The bounds are encoded as a Rectangle. To enlarge the bounds, the top and left values should be negative, and the bottom and right values should be positive.
This method calls getPadding() to get the raw padding values,
and uses Math.ceil() to set the values of paddingOverride
and currentPadding.undefined
The rounded padding required by this filter.
Sets the active state of this filter.
A disabled filter will not be used.
true to enable this filter, or false to disable it.
This filter instance.
Set the edges of the threshold. If the second edge is not provided, it will be set to the first edge.
This ensures that the first edge is not greater than the second edge. It may swap channels between edges to ensure this.
Optionaledge1: number | number[]
The first edge of the threshold. This may be an array of the RGBA channels, or a single number to apply to all 4 channels. Default 0.5.
Optionaledge2: number | number[]
The second edge of the threshold. This may be an array of the RGBA channels, or a single number to apply to all 4 channels. Default 0.5.
This Threshold instance.
Sets the invert state for each channel of the threshold filter.
When a channel is inverted, its output is flipped: pixels that would
output 0 instead output 1, and vice versa. This can be used to create
negative or reversed threshold effects per channel.
If invert is not provided, all channels default to false.
Optionalinvert: boolean | boolean[]
Whether each channel is inverted. This may be an array of the RGBA channels, or a single boolean to apply to all 4 channels. Default false.
This Threshold instance.
Sets the padding override.
If this is set, the filter will use this padding instead of calculating it.
Call setPaddingOverride(null) to clear the override.
Call setPaddingOverride() to set the padding to 0.
Optionalleft: number | null
The left padding. Default 0.
Optionaltop: number
The top padding. Default 0.
Optionalright: number
The right padding. Default 0.
Optionalbottom: number
The bottom padding. Default 0.
The Threshold Filter Controller.
This controller manages a threshold filter. Input values are compared to a threshold value or range. Values below the threshold are set to 0, and values above the threshold are set to 1. Values within the range are linearly interpolated between 0 and 1.
This is useful for creating effects such as sharp edges from gradients, or for creating binary effects.
The threshold is stored as a range, with two edges. Each edge has a value for each channel, between 0 and 1. If the two edges are the same, the threshold has no interpolation, and will output either 0 or 1. Each channel can also be inverted.
A Threshold effect is added to a Camera via the FilterList component: