Skip to reading
GUI Styling, Shaders & Effects

Change a shader as one complete property

Edition 0.86.4.1 HF1

0.86.4.1 Hotfix 1 edition. Earlier lessons and screenshots retain their original version context; revised references and supplements describe the newer behavior.

Download PDFView PDF page
Code example
extends "res://scripts/runtime/script_base.gd"
Code example
func run(_context: Dictionary = {}) -> Variant:
    var treatment: Dictionary = {
        "preset": "none",
        "layers": [{"preset": "warm", "intensity": 0.45}],
        "pixelSize": 4,
        "colorLevels": 5,
        "edgeStrength": 0.65,
        "distortionAmount": 0.01,
        "distortionSpeed": 0.7,
        "tintColor": "#ffffff00"
    }
    await ChangeGUIElementProperty({
        "guiId": "style_lab",
        "elementId": "preview_art",
        "property": "shader",
        "value": treatment
    })
    return true

The shader is a Dictionary containing the layer list and shared parameters. Replace the shader property with that complete object. Do not assume a dotted key such as shader.layers.0.intensity is a general deep-update command in every GUI action route.

The example applies a mild Warm effect to the illustration while leaving the separate Label clean. The same shared action is available to action lists and visual scripting when the value is supplied as a structured Dictionary.

If the property selector is built from the current element, apply an element shader once in the editor so shader is an authored field. The GDScript call above supplies its exact key directly.

Page 53 of 70Permalink
Go to page