Skip to main content

Post Processing Solution

Summary

This sample demonstrates how to implement and control post-processing effects in Scene Composer using scripts. It enables toggling effects on and off at runtime and allows property adjustments through UI controls like toggle buttons and sliders.

Purpose

The goal of this sample is to showcase the simplicity and flexibility of applying post-processing effects via scripts. It provides a practical example of how to enable/disable multiple effects at runtime and animate their properties interactively using UI elements.

Description

TheKey most important nodeselements of thethis sample areinclude the cameras in Scene3D_FX (both the 3Dmain and 2DFXreflection scenes.cameras) and in Scene2D_FX (UI camera). These cameras have post-processing scripts attached. They areattached, taken from the Construction Kit as Script Components.

When the sample is started in the Player, the

The scripting system for the Player has tocan be enabled.enabled Then,via the buttonsState ofMachine using the 2DEnable sceneScripting allowSystem tobehavior switchor toggled on/off through the CGI Player Panel using the Toggle Scripting System option.

The Scene2D_UI handles switching between 3D2D and 2D3D scenesviews and toprovides enabletoggle orbuttons disablefor eachenabling/disabling effect.individual Topost-processing approacheffects. this behavior, additional scripts have been added to the solution. In general it works in the way that theEach camera has a further script attached(e.g., Camera.lua for 3D and Camera2D.lua for 2D) that stores its ID in a global table. OtherGroup nodes named after effects (e.g., BloomDummy, FXAADummy) have attached scripts (attachedEnableCameraScript.lua, to other nodes) access this table to be able to enable the post-processing scripts. The cubes also have scripts attached,2DEnableCameraScript.lua) that control the rotationactivation of those effects. Post-processing scripts are toggled by enabling or disabling the rendering of these dummy nodes using the Enable Rendering Action behavior.

Several post-processing properties are animated and can be modified at runtime using sliders in the UI. Additionally, there's a Material Control section where users can adjust the PBR shader properties of the cubes3D model—such as Base Color (R, G, B), Glossiness, and theirthe colorintensity orof opacity.the Baked Ambient Occlusion texture—using the same slider mechanism.

For a moredeeper detailed descriptionunderstanding of what the scriptsscript do pleasefunctionalities, refer to the comments inwithin theeach scriptsscript themselves.file.

drawing-7-1695261727.png

Example of post-processing a 2D scene

drawing-7-1695261791.png

Example of post-processing a 3D scene

The script system of the Player can be started by typing "start script" into the Player's command window or by enabling Player > Scripting System in the CGI Panel's menu bar.
To stop the script system type "stop script" or by enabling Player > Scripting System in the CGI Panel's menu bar or by disabling Player > Scripting System in the CGI Panel's menu bar.

drawing-5-1734081139.png
drawing-7-1734332559.png