{
"$type": "site.standard.document",
"bskyPostRef": {
"cid": "bafyreih3tnupsi32n4scsfcfodo5m4iv4ypfyiqdsoixhe246mhvk3huny",
"uri": "at://did:plc:dxjzgxe7cvirxkwfjr2tjspt/app.bsky.feed.post/3mnhfkewkd3u2"
},
"path": "/t/blocks/42465?page=11#post_215",
"publishedAt": "2026-06-04T08:18:55.000Z",
"site": "https://hub.jmonkeyengine.org",
"tags": [
"here"
],
"textContent": "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.\n\nHere is the detailed pipeline:\n\n 1. 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 a`Vector4f` where `xyz` is a light _color_ (white, or tinted for water) and `w`\nis that packed level byte.\n 2. 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.\n 3. Because a solid neighbour contributes light 0, a corner touching solid\ngeometry gets a lower average (darker corner). That darkening _is_ the ambient-occlusion effect.\n 4. These four colors are pushed into the mesh’s color buffer.\n 5. 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\ndarkened corner interpolates correctly (the classic Minecraft AO-seam fix).\n 6. The shader turns the vertex color into final brightness.\n\n\n\nHope it helps !",
"title": "Blocks"
}