Skip to content

Instantly share code, notes, and snippets.

Last active May 6, 2023 18:52
Show Gist options
  • Save techiepriyansh/074ff2631a96f73121d59d40ba8edd18 to your computer and use it in GitHub Desktop.
Save techiepriyansh/074ff2631a96f73121d59d40ba8edd18 to your computer and use it in GitHub Desktop.
GSoC'22 @ GodotEngine Final Project Report


GSoC'22 Project Report

Project Description

Godot 4.0 comes with a brand new lightmapper which runs on GPU. My project aimed to improve the 4.0 GPU lightmapper by porting some of the essential features from the 3.x CPU lightmapper and adding a new debug draw mode for visualizing the texel density of lightmaps.

My Contributions

1. Multi-image atlases

Previously every LightmapGI node used to store its lightmap atlas in a single large image. This meant that the larger scenes might refuse to bake because they don't fit within the size limits of an image. I modified the implementation to allow saving the lightmap atlas as multiple images if it doesn't fit inside a single image.

- [PR]: #61861 (merged)

2. Soft shadows

The general idea behind soft shadows is to take into account the light source's size instead of treating the light source as a point. When one also takes the contribution of light rays from parts of the light source other than its centre, there is a gradual transition from shadowed to fully lit instead of an abrupt change.

I added support for soft shadows to the GPU lightmapper by incorporating this idea in the lightmapper's raytracing compute shader.

No soft shadows With soft shadows

- [PR]: #62054 (merged)

3. Debug draw mode for texel density

I implemented a draw mode that previews the texel density of lightmaps (without actually (re)baking them). It will aid users in adjusting the lightmap scale of their objects.

How do you show the texel density visually?
The idea is to overlay a checkerboard pattern with the same square size (in texels) on the textures of all the meshes. Upon rendering, the checkerboard pattern will appear diminished in the regions with high texel density, and magnified in the regions with low texel density.

How do you achieve this?
A PR tried to draw checkerboard on the baked lightmaps by modifying the lightmap data itself. But it required rebaking lightmaps to view the effect of any changes in the lightmap size of objects. The approach I came up with was to overlay the checkerboard pattern analytically through a shader. The checkerboards need to be scaled depending on the lightmap size of the objects they get overlayed over. This requires reading the lightmap size of each object from the shader, which can be conveniently achieved using Godot 4.0's global shader parameters.

UV2 Texel Density Draw Mode

- [PR]: #62987 (open)

  • The PR has been approved by my mentors but is awaiting approval from a few other members.
  • Hopefully, it's merged by the time you're reading this, but if not, you can still try the feature out by building my branch.

Future Work

I will keep updating the texel density PR with the master branch until it's merged. Besides, I would like to take up some experimental tasks like implementing adaptive sampling in the GPU lightmapper.


I loved working on the project. I've always been interested in graphics, and the project was perfect for me to level up in the field. I was able to complete everything I outlined in my proposal. It was only possible with the fantastic support extended by my excellent mentors, Clay John and Joan Fons Sanchez (thank you so much!).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment