Home Artists Posts Import Register

Content

Upgraded the lighting system. The work can be divided into 3 parts: a new light partitioning system, volumetric lighting, and editing lighting in the map editor.  Because of the extensive changes, I am going to release a small patch soonTM and see how well everyone can run those new features and go from there.

The following is very technical and you can skip unless you are interested in more details.

1) Light partitioning system

In the simplest lighting system, the lighting equation is executed for every pixel on screen. While this approach works for lights that covers the entire scene, it is very wasteful on lights with a small area of effect. For example, the following 2 pictures have the same lighting cost despite the large differences in the 2 lights:

This gets really bad when one wishes to add a large amount of lighting to a scene, such as this one below. Each colored light only have a relatively small area of effect but the black areas have to run the lighting equation 8 times, once for each different colored light!

So how to solve this problems? There are a few approaches and the one I implemented is a light partitioning system called clustered rendering. In HRT, it was a different technique called deferred lighting but it has a few flaws so I decided on a different approach.

How this works is to divide the scene into a bunch of tiles or clusters. For example, maybe you can divide the above picture into a grid with X rows and Y columns. And then on each tile, calculate which light can potentially have lighting effect, to avoid needless calculations on where lights have guaranteed no effect.

This is not exactly how the game's clustering work but it is a similar idea.

Here is a debug view of how light clustering (currently) works. The solid color are where the lighting equation is run for the same colored light source. Notice how most areas only run the light equation once or even zero times, some run twice (overlapped color areas) and a couple 3+ areas. Much better than the 8x per pixel case in the simple implementation!

2) Volumetric lighting

This is a new lighting effect that renders light shafts, fog, and light beams. Here is an on and off comparison:

On:

Off:

It is a moderately costly effect and I am a little worried that entry-level or integrated gpus might have problem with it, so will need to implement a toggle to disable it in the future. But it looks pretty good.

On/off on a more complex scene:

I have another example example on twitter: https://twitter.com/Enlit3D/status/1746596976085631417

3) Lighting edit in the map editor

This is what the top video is all about. Basically, editing lighting directly in-game. This is important because every piece of 3D software does the lighting calculation a little differently, so an editor using the same in-game rendering system is required to have exact matching visuals in editor and when running the game.

Probably will make another post explaining all the parameters and their effects. Maybe even add a "Modding Resources" collection for aspiring modders. But that's it for this post.

Files

In-game editor

Comments

Walter Madison

This is really cool, and I am beyond impressed with the work you've done on creating your own gaming engine (not to mention the games within it)! Do you have any plans to release the engine itself at some point, or maybe contribute from it to a project like Godot?

Nahte

dennys parking lot arena when?

Anonymous

I think color room be great for disco stage