Light baking + Normals = amazing GI approximation!

hey , long time ! whats happening under the hood here ?

Iā€™m working on this rendering engine built simply through the node editor because itā€™s useful for me to better prototype the game using upbge 0.2.5b (I havenā€™t tried range atm yet).
My goal was to have many (static) light sources simultaneously visible without moving from the node editor as I want to have everything visible in the 3D view port to work comfortably on the level design.
I took the liberty of posting something about it here because the basic working mechanism of the light is very similar to what you were talking about here.
Iā€™m using 2 textures on which I render the light sources.
For the position it is sufficient to save the Z coordinate only.
For the direction of light X and Y (Z is reconstructed)
The method used to calculate the light of the area lamps is something I improvised quickly, but today I reviewed it and the result is what you see in the video:

Iā€™m quite satisfied but maybe Iā€™ll work on it a little more.
This same method used for area lamps is also used to calculate the light of point lamps considered as spherical area lamps.
To avoid using more than 2 textures, the calculation method Iā€™ve implemented presents some simplifications which lead to the direction of the light of the pointLamps not being exactly the same as that of a real pointLamp, but this does not seem to be very noticeable so, atm, I donā€™t intend to use a third texture to save additional parameters so as not to affect the fps, which still remain very high, allowing me to exploit the resources for other thingsā€¦

One downside is that you canā€™t have overlapping lights. In this case to have a possible overlap I should duplicate the effect using 2 other textures:
1 possible overlap: 4 textures
2 possible overlays: 6 textures
3 possible overlays: 8 textures etcā€¦

(For now Iā€™ll do without overlap, then proceeding with the level design Iā€™ll evaluate whether it will be appropriate to enable one or more overlapsā€¦)

2 Likes

its storing the data in UV correct?

I was thinking ā€œtransform uvā€ could be used potentially to move lamps in game,

Still need to test.

Parameters are stored per texture pixels.
The uv for sampling is calculated as a function of the fragment_worldPos

looks nice. And if you are able to replicate perfectly lamps just with material textures, just wow.

MattFrnndz gave an answer for the Z, for the X,Y we use a simple normal texture (which is very easy and convenient)

Donā€™t hesitate to grab ideas displayed in the thread and share your findings :slight_smile: