Estella 0.113.0
A fast 2D and 3D game engine powered by WebAssembly and ECS
Loading...
Searching...
No Matches
TiledLights.hpp File Reference

Which screen tiles a light can reach — the half of tiled forward lighting that is decided on the CPU. More...

#include "../../core/Types.hpp"
#include <glm/glm.hpp>
#include <algorithm>
#include <cmath>
Include dependency graph for TiledLights.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

namespace  esengine

Functions

void esengine::markLightTiles (const glm::mat4 &viewProjection, const glm::vec3 &center, f32 radius, u32 index, u32(*masks)[4])

Variables

constexpr u32 esengine::TILE_COLUMNS = 16
constexpr u32 esengine::TILE_ROWS = 12
constexpr u32 esengine::MAX_TILED_LIGHTS = 96
 Lights a frame can carry through tiles, past the sixteen the loop reads directly. Three words of mask: the fourth is spare.

Detailed Description

Which screen tiles a light can reach — the half of tiled forward lighting that is decided on the CPU.

The lighting UBO holds sixteen lights a fragment loops over, which a street at night overruns on its own. The rest of a frame's point and spot lights (up to MAX_TILED_LIGHTS) ride in the same block with a bitmask per screen tile: bit i of tile t says light i can reach a pixel in that tile. A fragment finds its tile from where it lands on the screen and shades only the lights whose bit is set, so the cost follows the lights near a pixel and not the lights in the scene.

The grid is in NORMALIZED DEVICE coordinates — x and y in [-1, 1], y up — which both backends and every camera share: a fragment recovers them from the projection it was drawn through, so there is no viewport size, no framebuffer origin and no sub-rect of a shared surface for the two sides to disagree about.

Definition in file TiledLights.hpp.