Uncategorized

A high performance lighting system for 2D games

Topic will be started with the custom lighting system that allows for a lot 2D light sources even on low spec hardware. It was made in Unity but this approach should work in any game engine that lets you create procedural meshes.

Procedural Meshes to the rescue!
The basic idea is to use a procedural mesh to “stamp” the lighting data into a light buffer that is then sampled in shaders. This is not that different from how deffered lighting works, however this solution only needs to work in 2D so author can get this done in one draw call for all my lights at once by using a procedural mesh to draw the light.

The lasers in the example were rendered with a procedural mesh so it already had a texture lying around which can be used to store the light falloff in.

The laser sheet...

Uncategorized

Procedural Level Generation in Unity (part 1 of 2)

In Part 1 of this article we discussed why we chose to use procedural level generation. Were also described how to generate a procedural level’s layout and connect multiple smaller level chunks together to form a fully coherent level. In part 2 of this article we discuss how we overcome lighting and NavMesh problems in Unity, and how tospawn NPCs based on a tempo.

Lighting
With procedurally generated path, it is likely that the same chunk will be loaded multiple times for each level. The duplicate meshes within those chunks are stored in memory separately, but the lightmaps can be shared by adding code to our level loader to amalgamate all the lightmaps by scene name. Lightmap indexes are then reassigned as they load, saving memory instead of duplicating lightmaps for those chunks.

In ord...