Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Global illumination in 2D

edited September 2017 in Code Sharing Posts: 105

If you happen to be working on a 2D top-down game and want some global illumination on top of that, say no more! Actually, if you find something to be terribly wrong or confusing in the code then please tell me!

This project bakes diffuse global illumination for your scene where you define the resolution of the lightmap. It supports as many lightbounces as you like from sky, sun and emissive objects. The algorithm is based on path tracing and accelerated with a distance field in order to reduce waiting times and avoid crashing the program.

The code includes a tab called "ReadMe", read it!
Potential questions that you might have:
Q: Why does the lighting sometimes look bugged when I have calculated 1 bounce of light?
A: Calculate 1-2 more bounces and it will disappear!

Q: In my game the lighting is really dark, why?
A: Two words, gamma correction! Essentially our screens does not display light in a linear form, so when displaying colors we need to compensate.

Instead of:
gl_FragColor=vec4(Color,1.);
do
gl_FragColor=vec4(pow(Color,vec3(0.45)),1.);
This is correct!

Code:
https://github.com/firelava135/GIDF2D/blob/master/Code.txt

Here is an example:

Sign In or Register to comment.