Jump to content

Leadwerks 5 beta update adds post-processing effects system


Josh

1,549 views

 Share

A new update is available that adds post-processing effects in Leadwerks 5 beta.

Image1.thumb.jpg.fe35f421f05c5fc7a5f4f753905d4b69.jpg

To use a post-processing effect, you load it from a JSON file and apply it to a camera like so:

auto fx = LoadPostEffect("Shaders/PostEffects/SSAO.json");
camera->AddPostEffect(fx);

You can add as many effects as you want, and they will be executed in sequence.

The JSON structure looks like this for a simple effect:

{
    "postEffect":
    {
        "subpasses":
        [
            {
                "shader":
                {
                    "vertex": "Shaders/PostEffects/PostEffect.vert.spv",
                    "fragment": "Shaders/PostEffects/SSAO.frag.spv"
                }
            }          
        ]
    }
}

Multiple subpasses are supported for custom blurring and chains of shaders. This Gaussian blur effect uses several intermediate buffers to blur and downsample the image:

{
    "postEffect":
    {
        "buffers":
        [
            {
                "size": [0.5, 0.5]
            },
            {
                "size": [0.25, 0.25]
            },
            {
                "size": [0.125, 0.125]
            }
        ],
        "subpasses":
        [
            {
                "target": 0,                
                "shader":
                {
                    "vertex": "Shaders/PostEffects/PostEffect.vert.spv",
                    "fragment": "Shaders/PostEffects/blurx.frag.spv"
                }
            },
            {
                "target": 1,
                "shader":
                {
                    "vertex": "Shaders/PostEffects/PostEffect.vert.spv",
                    "fragment": "Shaders/PostEffects/blury.frag.spv"
                }
            },
            {
                "target": 2,                
                "shader":
                {
                    "vertex": "Shaders/PostEffects/PostEffect.vert.spv",
                    "fragment": "Shaders/PostEffects/blurx.frag.spv"
                }
            },
            {             
                "shader":
                {
                    "vertex": "Shaders/PostEffects/PostEffect.vert.spv",
                    "fragment": "Shaders/PostEffects/blury.frag.spv"
                }
            }
        ]
    }
}

A new file is located in "Config/settings.json". This file contains information for the engine when it initializes. You can specify a default set of post-processing effects that will automatically be loaded whenever a camera is created. If you don't want any post-processing effects you can either change this file, or call Camera::ClearPostEffects() after creating a camera.

Customizable properties are not yet supported but I plan to add these so you can modify the look of an effect on-the-fly.

Fixed physics bug reported by @wadaltmon

Other changes:

  • EnablePhysics is renamed to SetPhysicsMode.
  • EnableGravity is renamed to SetGravityMode.
  • EnableSweptCollision is renamed to SetSweptCollision.
  • COLLISION_CHARACTER is renamed to COLLISION_PLAYER
  • Like 6
 Share

0 Comments


Recommended Comments

There are no comments to display.

Guest
Add a comment...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...