logo

rendering · rendering

AmbientOcclusion

Free

Install with the CLI:

bjs download AmbientOcclusion

AmbientOcclusion

The dark in the corners.

JSON
"Sky": {
  "components": {
    "EnvironmentTexture": { "preset": "studio" },
    "AmbientOcclusion": { "radius": 1.5, "strength": 1.0 }
  }
}

A shadow map tells you where the sun cannot reach. Ambient occlusion tells you where the sky cannot reach: under a ledge, in the crease where a wall meets the floor, between two crates. It is a small effect and it is the one that makes a hundred separate kit pieces read as one built thing, because every join gets the soft dark line a real join has.

The engine work lives in an adapter plugin that ships inside @babylonjsmarket/arcade. A project made with bjs create already installs it: registerArcadePlugins(adapter) in src/main.ts covers every built-in plugin. If you boot the game from your own code, make the same call:

TypeScript
import { registerArcadePlugins } from '@babylonjsmarket/arcade/babylon';
registerArcadePlugins(adapter);

Without it the component is inert.

Knobs

FieldDefaultWhat it does
activetrueMaster switch.
radius1.5How far, in world units, a surface looks for things that occlude it. Match it to the scale of your joins: a cell-sized kit wants one or two units.
strength1.0How dark it gets.
base0.1Floor of the darkening. Raise it if corners go black.
samples16Depth samples per pixel. 8 is fast and grainy, 32 is smooth. Rebuilds the pipeline.
maxZ120Beyond this distance the effect fades, so the far town does not go muddy.
minZAspect0.2Keeps the radius from shrinking to nothing at distance.
expensiveBlurtrueEdge-aware blur. Slower, no halos.
ratio0.5Occlusion pass at half the frame's resolution. Rebuilds the pipeline.

Every field is live.

Pairs with

An EnvironmentTexture: occlusion darkens the ambient light, and there has to be ambient light to darken. ToneMapping keeps the result from crushing.

More like this

BilliardBall
BlackHole
CaptureZone
DirectionalLight
EnvironmentTexture
Flash
GravityLens
Hand
HemisphericLight
LensFlare
Mesh
MeshPrimitive
MotionTrail
NebulaSky
Renderable
RoadTreadmill
Shadow
ShipDamageFX
Skybox
SmokeScreen
SpaceDust
SpaceRock
SpaceShooterFX
ToneMapping
WhiteHole
Wormhole

Was this page helpful?

We read every note — tell us what's working and what isn't.

↑↓ NavigateEnter SelectEsc CloseCtrl+K Open Search