BRDF-Based Deferred Lighting Example

Hi everyone!

In my free time, I’ve been working on graphics effects: writing shaders, experimenting with rendering, and everything related to it. Recently, I put all my work together into a single project - a deferred renderer in Defold. You can use it as a foundation for your own scenes and experiments.

Features implemented:
– G-Buffer with albedo, normals, and depth
– SSAO with smoothing and position reconstruction from depth
– Point light shadows (cubemaps packed into an atlas). The number of lights is limited by atlas size — currently up to 10. It can be significantly increased to x4, with simple settings in the code
– Volumetric lighting — that soft “light in the air” effect
– Simplified PBR (diffuse lighting + a bit of BRDF)
– Tonemapping for proper HDR-to-LDR display (not perfect yet)
– Free camera (WASD + mouse), multiple light sources, and a basic set of objects

Rendering process:

  1. Write data to the G-Buffer

  2. Calculate SSAO

  3. Add shadows

  4. Perform lighting

  5. Display the result on screen

It’s easy to plug in your own models and textures (albedo, normals, roughness), configure materials, and add them into the scene.

The code is open and straightforward: modules, shaders, materials, and rendering utilities.
The project is available for everyone — feel free to try it out, improve it, and use it in your own projects!

24 Likes

That looks amazing, well done!

There are not a lot of resources for advanced rendering in Defold, so this is very useful.

3 Likes

Well done!!! It looks great! And thank you for sharing this with the community.

2 Likes