Baked Lighting "Engine" - Update 1

Intro

  • A few months ago, I created a full light transport simulation in order to create a baked lighting system. This was designed to completely replace or add onto Roblox’s current lighting engine.
    27e84afade2c59cd3426dc4d77129ccc
  • To summarize, this system is similar to a light rendering algorithm called Lightmapping used in early 2000’s game engines such as Source. Lightmapping is built for static scenes that don’t have multiple moving parts. Though it’s possible to incorporate dynamic lighting as well, the fact that a static scene is only rendered once makes this rendering option excellent for computers with low processing power, while still providing decent quality lighting, such as grid-based diffuse lighting and shadows for local and global light sources.

Demo scene rendered using the engine, can be found in the place file below.

If you would like a full tutorial on how to use this engine, check out the original post here, though keep in mind the place files are now outdated: Custom Baked Lighting “Engine”

New Files
The core module:
Lightmap.lua (23.6 KB)
A demo place file:
DemoLightmapsParallel_SurfaceGui.rbxl (75.7 KB)

Changes

  • I ended up switching to using SurfaceGui’s as “canvases” for rendering shadows. This means that shadow tiles are now ImageLabels, and the calculations necessary to convert a position from 3D to SurfaceGui 2D space are taxing. Unfortunately, this makes the new engine approximately 0.003 seconds slower than the old version, though this isn’t always the case depending on the number of instances being generated. In the old engine, execution time would practically scale exponentially depending on the size of the parts. The current engine with the new optimizations rarely suffers from this setback now. This in turn also removes the ambient occlusion effect present in the old version, as SurfaceGui’s clip ImageLabels outside of the size of a part.
  • This change had to be made in order to come with the benefit of allowing hundreds of more instances to be generated without over-reaching Studio’s max execution time. Meaning that entire maps such as Crossroads or to some degree, even entire Baseplates can now have Lightmaps rendered onto them in less execution time than the old engine.
  • A common issue with edges of shadows appearing brighter even when in shadow is now mostly fixed. This was a result of the size of the Lightmap grid being set incorrectly during rendering.
  • Light source diffuse attenuation has been changed to more accurately include Range. Though this is less accurate to how other engines incorporate light sources, it’s more in tune with Roblox’s light falloff.
46 Likes

This is really cool! I’m sure this will be super helpful to use for big projects!

2 Likes

This needs more recognition. Doesn’t this mean we could optimize Roblox by using Viewports now?

(You should also call the Module Baked Beans (Baked Lighting “Engine”))

1 Like

Can you provide us with any benchmarks?

.Yes I can

Baking Only via the Server
took 0.0421 seconds
https://streamable.com/m63rmq

Running RTX 3060 with Ryzen 7 3700x.

I’m not sure how to do the real time stuff yet so I didn’t test that. Will when I figure it out.

1 Like


My results look a bit different?

This looks really cool! Maybe you could try implementing some type of greedy meshing system but for the image labels

This is most likely because of a “REALISTIC LIGHTING PLUGIN 100% FREE NO VIRUS” thing you have installed that automatically changes the lighting settings.

It’s probably a bad idea, because the amount of instances used for each canvas is astronomically high! But does the number of instances in canvas counts ?

Especially, is it worth it for users with poor computers ? Yes they don’t have to cook the lighting themselves, but they have to cook EACH INSTANCE in canvases.

This is awesome! I can see how this will help improve the ambience of various experiences while keeping it minimal for the developer to implement.

Me who literally has practically no plugins installed

In the latest change I modified the light distance code to take the range of a light into account more accurately.
* Light source diffuse attenuation has been changed to more accurately include Range. Though this is less accurate to how other engines incorporate light sources, it’s more in tune with Roblox’s light falloff.