Blocks
jMonkeyEngine Hub
June 4, 2026
Ialon code is publicly available here. It doesn’t compute classic geometric AO but uses Minecraft-style smooth lighting baked into per-vertex colors at mesh-generation time, where neighbouring solid blocks (which carry light level 0) automatically darken the corners next to them, producing the soft-shadow / AO look.
Here is the detailed pipeline:
- Light is stored per block, in a light map. Each block has a packed light byte (
Chunk.lightMap): the high nibble is sunlight (0-15), the low nibble is torchlight (0-15). Solid/opaque blocks end up with light 0.getLightLevel(...)(Chunk.java:553) returns aVector4fwherexyzis a light color (white, or tinted for water) andwis that packed level byte. - Each face vertex averages the light of its surrounding neighbours. For a visible cube face,
Cube.softShadow(...)(Cube.java:93) drives the effect: it fetches the 8 neighbouring blocks’ lights around that face. For each of the 4 face corners it averages the two adjacent side neighbours, the diagonal corner neighbour, and the face’s own light. - Because a solid neighbour contributes light 0, a corner touching solid geometry gets a lower average (darker corner). That darkening is the ambient-occlusion effect.
- These four colors are pushed into the mesh’s color buffer.
- Anti-artifact triangle flip : a quad split into two triangles interpolates AO unevenly along its diagonal. A couple of methods must choose a triangle winding so that the darkened corner interpolates correctly (the classic Minecraft AO-seam fix).
- The shader turns the vertex color into final brightness.
Hope it helps !
Discussion in the ATmosphere