The Camera that owns this filter.
Optionalmask: string | GameObjectThe source of the mask. This can be a unique string-based key of the texture to use for the mask, which must exist in the Texture Manager. Or it can be a GameObject, in which case the mask will render the GameObject to a DynamicTexture and use that. Default '__WHITE'.
Optionalinvert: booleanWhether to invert the mask. Default false.
OptionalviewCamera: Cameras.Scene2D.CameraThe Camera to use when rendering the mask with a GameObject. If not specified, uses the scene's main camera.
OptionalviewTransform: "local" | "world"The transform to use when rendering the mask with a GameObject. 'local' uses the GameObject's own properties. 'world' uses the GameObject's parentContainer value to compute a world position. Default 'world'.
Toggle this boolean to enable or disable this filter, without removing and adding it from the Game Object.
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.
Whether the mask should automatically update.
This only applies when the mask is a GameObject.
If false, the mask will not change even if the GameObject changes.
A reference to the Camera that owns this filter.
The padding currently being used by this filter.
This is set and used during rendering using getPadding.
It is necessary for filters being used in an external list.
You should not modify this value directly.
The underlying texture used for the mask.
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 to invert the mask. An inverted mask switches what it hides and what it shows.
The GameObject used for the mask. This is only set if the mask is a GameObject.
Whether the mask needs updating, once.
This only applies when the mask is a GameObject.
If true, the mask will be updated before the next render.
This is automatically set to true when the mask is a GameObject,
but it turns off after the mask is updated.
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.
The Camera to use when rendering the mask. If not specified, uses the currently rendering camera, or failing that, an internal Camera.
The transform type to use when rendering the mask with a GameObject.
'local' uses the GameObject's own properties.
'world' uses the GameObject's parentContainer value to compute a world position.
This only applies when the mask is a GameObject.
Destroys this Controller and nulls any references it holds.
Returns the padding required for this filter,
and sets currentPadding to the result.
Most filters don't need extra padding,
but some might sample beyond the texture size, such as a blur.
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.
Sets the active state of this filter.
A disabled filter will not be used.
true to enable this filter, or false to disable it.
Sets the GameObject used for the mask.
The GameObject to use for the mask.
Sets the padding override.
If this is set, the filter will use this padding instead of calculating them.
it Call setPaddingOverride(null) to clear the override.
Call setPaddingOverride() to set the padding to 0.
Optionalleft: numberThe top padding. Default 0.
Optionaltop: numberThe top padding. Default 0.
Optionalright: numberThe right padding. Default 0.
Optionalbottom: numberThe bottom padding. Default 0.
Sets the texture used for the mask.
Optionaltexture: stringThe unique string-based key of the texture to use for displacement, which must exist in the Texture Manager. Default '__WHITE'.
Updates the DynamicTexture for the mask.
The DynamicTexture is created or resized if necessary.
This is called automatically during rendering
when the mask is a GameObject
and the needsUpdate or autoUpdate flags are set.
It should not be called directly.
The width of the DynamicTexture.
The height of the DynamicTexture
The Mask Filter Controller.
This filter controller manages a mask effect.
A mask uses a texture to hide parts of an input. It multiplies the color and alpha of the input by the alpha of the mask in the corresponding texel.
Masks can be inverted, which switches what they hide and what they show.
Masks can use either a texture or a GameObject. If a GameObject is used, the mask will render the GameObject to a DynamicTexture and use that. The mask will automatically update when the GameObject changes, unless the
autoUpdateflag is set tofalse.When the mask filter is used as an internal filter, the mask will match the object/view being filtered. This is useful for creating effects that follow the object, such as effects intended to match an animated sprite.
When the mask filter is used as an external filter, the mask will match the context of the camera. This is useful for creating effects that cover the entire view.
An optional
viewCameracan be specified when creating the mask. If not used, mask objects will be viewed through the current camera, or through a default camera if no other option is set. For example, when rendering to a DynamicTexture outside the normal rendering flow.A Mask effect is added to a Camera via the FilterList component: