Community Challenge: Post-processing effects

It is about time that we announce another community challenge! This time we’d like to challenge you to create some cool looking post-processing effects. Post-processing effects can be used to control the overall look and feel of the game by rendering the game world and applying various effects in sequence to produce the final result.

Share your post-processing effects here (must be open source) and in January we’ll pick three projects and award the authors with Steam Gift Cards.

Examples of post-processing effects

  • Blur - full screen blur effect (Shadertoy)
  • Vignette - fades the image out towards the edges (Shadertoy)
  • Scanlines - simulates the visible scanlines of an old display (Shadertoy)
  • Chromatic aberration - simulate defects and color shifts in real-world cameras (Shadertoy)
  • Color grading - adjust the color palette to achieve a certain mood or scenario such as time of day (Defold tutorial)
  • Grain - emulate the imperfections of analog film
  • Unreal Engine manual on post-processing effects
  • KinoGlitch video glitch effects for Unity (link)

Post-processing example project by @jhonny.goransson (https://github.com/Jhonnyg/my-public-defold-examples/tree/master/postprocessing). Normal vs Blur example:

Crash course in Defold rendering

In Defold the default render script will draw all components (sprites, tilemaps, particle effects etc) directly to the screen by copying the pixels from the atlas/tilesource texture to the screen using the default materials. From the default render script:

-- render sprites, tilemaps, particle effects etc
render.enable_state(graphics.STATE_BLEND)
render.draw(predicates.tile, camera_world.frustum)
render.draw(predicates.particle, camera_world.frustum)
render.disable_state(graphics.STATE_DEPTH_TEST)

When applying post-processing effects an additional step is introduced where the components are first drawn to an off-screen buffer (a render target) before drawing the entire off-screen buffer to the screen using a mesh (quad) which covers the screen and a custom material which applies the post-processing effect. Example:

-- step 1: render sprites, tilemaps, particle effects etc to a render target named 'my_render_target'
render.set_render_target(my_render_target)
render.enable_state(graphics.STATE_BLEND)
render.draw(predicates.tile, camera_world.frustum)
render.draw(predicates.particle, camera_world.frustum)
render.disable_state(graphics.STATE_DEPTH_TEST)
render.set_render_target(render.RENDER_TARGET_DEFAULT)

-- step 2: render 'my_render_target'  using 'my_material' to a model quad with a material with tag 'my_predicate'
render.enable_texture(0, my_render_target, graphics.BUFFER_TYPE_COLOR0_BIT)
render.enable_material(my_material)
render.draw(my_predicate)
render.disable_material()
render.disable_texture0)

Tutorials and sample projects

Here’s a collection of tutorials and sample projects to get you started:

23 Likes

I would love if this would be extended a bit, because I was very busy lately and there were also Holidays, which instead of ensuring some more time postponed everything :sweat_smile: I am preparing few shaders and maybe few other people have the same as me? :wink:

Yes, sure, let’s extend it to Friday. Did anyone else try this challenge?

I had half forgotten this at times. Could have used a pin job. :pushpin:

I didn’t have any good ideas nor much time but I did manage to make something and more or less learned how post-processing and render targets work along way. This was very helpful: Mastering Render Targets.

After figuring out how to use Lumiere (very nice btw). I ported this cool rain thing from shadertoy to work with it.

HTML5: community-challenges 1.0

I also tried to port rain shader example over but after a lot of trial and error I gave up. :man_shrugging:

7 Likes

Just linking this simple GUI shader example as my entry here:

Will add more post-processing useful for games later on :smiley:

2 Likes

I might not be able to complete it until Friday, but yes, I’m preparing my pixel art post-processing effect.

11 Likes

Still working on it. I’m trying to simplify things as much as I can.

10 Likes

Demo: defold-pixelart-shader 1.0
Demo: defold-pixelart-shader-example 1.0

Source:

Note: There is a known issue with the HTML5 build. Hopefully, it will be resolved in the next version (1.9.7).

14 Likes

Thanks for these examples.
The defold-pixelart-shader-example contains a model called character,
Which is a gltf file with multi materials.
In the demo above, all the colours are visible on the model (on the bridge).
Only the first colour works for me; otherwise everything works nicely and looks the same as the demo.
I am running Ubuntu 22.
Any idea what might fix this for me?

The only change I had to make was to remove the App Manifest from game.project
Do I need this to make multi mats work?

With it included Defold crashes (1.9.6 and 1.9.7 beta) . The beta gives an error message:

graphics_vulkan_surface.cpp:(.text+0xa): undefined reference to `dmPlatform::VulkanCreateWindowSurface(VkInstance_T*, dmPlatform::dmWindow*, VkSurfaceKHR_T**)'
...

I have no idea how to fix this error or where to go to get info on it:-)
Thanks.

Thank you for sharing your shader effects! Not that many joined this community challenge, but those who did submitted some nice looking stuff!

Pixel Art Shader

by @selimanac

HTML5: defold-pixelart-shader-example 1.1
HTML5: defold-pixelart-shader 1.0
Source: GitHub - selimanac/defold-pixelart-shader

Rain effect

by @NaakkaDev

HTML5: community-challenges 1.0
Source: GitHub - NaakkaDev/defold-community-challenges: All my Defold community challenge participations

GUI shine effect

by @Pawel

Video: GUI: Animated light effect on logo
Source: GitHub - paweljarosz/defold_gui_shine_effect: A very simple example of a GUI shader for Defold - a shining stripe effect


I will send Steam gift cards to all of you. @selimanac please ping me in a PM to arrange the gift card transfer.

5 Likes

The app manifest file is used to set the graphics backend to Vulkan. However, I’m not sure if Vulkan is supported on Linux by Defold. If it is supported, you might need to install Vulkan drivers or simply update the drivers.
Perhaps @jhonny.goransson can provide more insight on this.

You can simply change the graphics backend in the app manifest file from Vulkan to OpenGL.

It should work with both OpenGL and Vulkan; it shouldn’t matter. I don’t know why, but it stopped working for me as well. I’m going to look into it—this might be related to the latest Defold update.

1 Like

@iotaHum I simply removed and re-added the textures, and it worked for me. Could you please give it a try? I have no idea why it happened.

Screenshot 2025-01-24 at 10.43.45

Removing the manifest was easier than changing all the Vulcan references in the Linux block.

sure, but you can easily change it from properties panel:

OK, this is interesting. After deleting the tex0 files it (1.9.6) will not let me add them back again.

I switched to 1.9.7 beta and get the error:
ERROR:PLATFORM: GLFW Error: Context profiles are only defined for OpenGL version 3.2 and above

I don’t know what this relates to, maybe another red herring.

This did not fix it, I guess because the lib ref in the x86_64-linux section refer to Vulcan. So I removed the app manifest from game.project

If it is not working, I highly recommend reporting the issue from Help->Report Issue

You might have an old driver. I recommend updating the driver.
Additionally, you can change the OpenGL version in the game.project file. If this is not going to help you can report the issue from Help->Report Issue

1 Like