PostProcess class abstract

A way to apply effects to a whole component tree.

This is specially useful for applying effects based on FragmentShaders.

Post processes are created by sub-classing and implementing the postProcess method.

Within the postProcess method, you can use the renderSubtree method to render the component tree. This method will take care of setting up the context for the post process, so children can know if they are being rendered within a post process by using PostProcessingContextFinder.findPostProcessFromContext.

The subtree of a post process is the children of the owner, if it is a PostProcessComponent, or the World if the owner is a CameraComponent. When using a PostProcessSequentialGroup, the subtree also includes the preceding post processes in the group.

Another useful method is rasterizeSubtree, which will render the component tree to an image. This is useful for using such image as a texture in a shader.

Post process can be combined using PostProcessGroup or PostProcessSequentialGroup to build a chain of post processes.

Post processes can be used via CameraComponent.postProcess or PostProcessComponent.

A post process may even render a subtree multiple times if it needs to. In addition, if children check for PostProcessingContextFinder.findPostProcessFromContext, they may even render differently in each render pass. Ideal for mask textures.

See also:

Implementers

Constructors

PostProcess.new({double? pixelRatio})

Properties

hashCode int
The hash code for this object.
no setterinherited
pixelRatio double
The pixel ratio of the screen. This is used to scale the image generated by rasterizeSubtree to the correct size.
getter/setter pair
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
onLoad() FutureOr<void>
Similarly to components, post processes can be loaded asynchronously.
postProcess(Vector2 size, Canvas canvas) → void
There the effects of the post process are applied. This is where you should implement the logic of the post process. Including eventual calls to rasterizeSubtree and renderSubtree.
rasterizeSubtree() Image
One of the two methods that subclasses should invoke to render the what is considered the "subtree" of the post process.
render(Canvas canvas, Vector2 size, ValueSetter<Canvas> renderTree, ValueSetter<PostProcess?> updateContext) → void
This method is called to render the post process, to be called by the "owner" of the post process, like a CameraComponent or a PostProcessComponent.
renderSubtree(Canvas canvas) → void
One of the two methods that subclasses should invoke to render the what is considered the "subtree" of the post process.
toString() String
A string representation of this object.
inherited
update(double dt) → void
This method is called every frame to update the post process.

Operators

operator ==(Object other) bool
The equality operator.
inherited