Log inGet started
World

Amagiri: Hollow Bell

Branchmain
Commitb5d6c56f4d

README.md

vprops

The things standing in Amagiri, as geometry.

A mesh builder and the shapes to put in it. Nothing here knows about Amagiri — it is boxes, cylinders, beams, roofs, torii, lanterns, houses and grass, and valley decides where they go.

local P = require("valley.vprops")

local b = P.builder()
b:at(x, y, z, yaw, pitch, roll)     -- place everything emitted from now on
P.torii(b, 5.0, 5.0, 1.4)           -- span, height, how deep it stands
P.lantern(b, 1.0)
b:box(0, 1.5, 0, 2, 1.5, 3)

local mesh = renderer.mesh.create(P.geometry(b, "my_props"))

Why a builder

A prop emitted into a shared mesh costs a few dozen quads and no entity. Every torii, house, post and lantern in the valley wearing one material becomes one mesh and one draw, so the whole place is a dozen entities rather than a thousand. The builder carries a transform, so a shape is written once in its own local space and placed anywhere.

Shapes

quad · tri · box · cylinder (tapering, optional caps) · beam (a four-sided prism between two arbitrary points — a branch, a rafter, a span of an arch) · gableRoof · hipRoof · torii · lantern · houseBody / houseFrame / houseRoof (three parts, so walls, frame and roof can each go into the mesh of the material they are made of) · deadTree · boulder · grassTuft.

grassTuft writes uv.y from 0 at the root to 1 at the tip, which is what @builtin::shaders.grass_material bends a blade by, and emits each blade on both faces so a back-face-culled material still shows it from every side.

One rule the shapes follow

No two surfaces sit at the same depth. A cap rests into the box below it, an eave board sinks into the wall head, consecutive steps interpenetrate, and the back face of a grass blade is pushed a millimetre off the front. Two faces at one depth look perfect in every still and shimmer for everyone who walks past them.