Log inGet started
Package

screenSpaceGI.package

Newest version

This package holds more than this page lists. See all of its files in its world.

README.md

screenSpaceGI system

Indirect diffuse light gathered from the scene that was just drawn.

Baked lightmaps and probe volumes carry indirect light for the geometry that was present when they were baked. Anything else receives none: a character walking past a brightly lit red wall picks up no red, an object moved at runtime neither receives nor contributes bounce, and a scene assembled at runtime has no indirect light beyond a flat ambient term.

This supplies that bounce from what is actually on screen. It needs no acceleration structure and no bake, which is what makes it reachable on native, WASM and Android alike.

Using it

local id = entity.spawn("screen_space_gi").id
entity(id).component.add("ScreenSpaceGI", {
    intensity = 1.0,   -- how much of the gathered bounce reaches the image
    radius = 2.0,      -- how far a surface gathers, in WORLD units
    quality = "auto",  -- auto | low | medium | high | ultra: cost and smoothness
})

Every field is live. Setting intensity to 0 turns it off without losing the rest. For runtime control (a quality slider, a cutscene) drive the module:

local screenSpaceGI = require("@builtin::systems.screenSpaceGI.screenSpaceGI")

screenSpaceGI.set({ intensity = 1.0, radius = 2.0 })
screenSpaceGI.get()
screenSpaceGI.active()
screenSpaceGI.clear()

How it renders

The light is the indirect gather of the ambient occlusion pass (guides { path = "systems/ambientOcclusion" }): one horizon search over this frame's depth finds which part of each surface's hemisphere is closed and what closes it, and the light each occluder sent toward the camera in the view's previous render reaches the surface through the part it closes. The gather is carried across each view's renders, lifted into the scene's indirect channel, and read by every PBR surface's diffuse term at its own pixel, on the forward and deferred paths alike. That light takes the place of the surroundings' light the occlusion took from the closed part, so turning the bounce on adds the colour of what is near a surface without counting the ambient, the probes or the environment twice.

The same gather is the AmbientOcclusion component's indirect field and the ao module's indirect setting; this package states it as a strength, a reach and a quality of its own, and runs the occlusion beneath it while it is on. A scene states the bounce through one of the two components: both drive the one pass, and two of them overwrite each other's reach and level.

Only what is on screen and within radius sends light: a wall behind the camera tints nothing, and a room's far wall reaches the floor only at a reach the size of the room. intensity = 1 is the light the visible surfaces really exchange; a stylised look may want more. The half-resolution levels (low, medium) read grainy at a strong intensity, high and ultra smooth.

Working with baked lighting

A baked lightmap already carries the static bounce for the geometry it was baked from, and the gathered light replaces only the share of the indirect term the occlusion takes from a closed part of the hemisphere. A baked scene therefore does not double its bounce, and intensity below 1 is the control for a scene whose look wants less of the dynamic part.

Files

screenSpaceGI.package/
  ScreenSpaceGI.component/   -- the scene's bounced light, authored and persisted
  screenSpaceGI.module/      -- .set / .get / .clear / .active