Log inGet started
World

Painted Valley

Branchmain
Branchesmain
Commit12ad3f264b

README.md

paintedValley/meadow

The meadow of Painted Valley (blendi/painted-valley on Patch, MIT): ground, grass, flowers, the field's memory of being trodden, the brushwork texture (tStrokes) every part paints with, the stones and the seed fluff. Ported from lib/ground.js, lib/blades.js, lib/flowers.js, lib/state.js (bend / scan / pushers), lib/index.js (createField wiring, field.update), valley/strokes.js, valley/dressing.js and main.js's tread / setWind / options (size 256, density 1, height 0.5, seed 3).

Files

  • meadow.module/ entry paintedValley.meadow.meadow: init.luau (build / update / destroy, bend, setPusher, setWind, reset, solid, heightAt, tread), blades.luau (rings, tiles), flowers.luau, ground.luau, state.luau, strokes.luau, dressing.luau (stones, fluff).
  • meadowCommon.shaderModule: stateUv / stateAt (tState), whiteAt (tWhite), pusherAt, vertex-stage openAtV / cloudAtV.
  • blades.shader, flowers.shader, ground.shader, stones.shader, fluff.shader; state.computeShader.
  • textures/: ambientCG Ground048 / Ground103 colour + NormalGL (CC0), stored linear (rgba8, 8x aniso).
  • dev/meadowDev.module: a stand-in driver for testing the meadow alone in a scene of its own. Not used by the valley.

How it is drawn

  • Blades and flowers: one mesh per ring holds one TILE of blades; each vertex's (side, t, sub) and aCell are encoded in its position inside the tile. drawInstanced places the ring's tiles (follow() rewrites the transforms when the camera crosses a tile, for culling). The tile's number rides on the instance's x scale (1 + (k+1)/1024); the vertex_clip hook takes the tile corner from the camera itself (uniforms.camera_pos), so the ring follows on the very frame and both motion-vector evaluations build the same blade. The hook is the original vertex shader line for line; its fragment sum (albedo * meadowLight(vLight.x) * mix(0.84, 1, up), fog) is finished in the hook and carried in the vertex colour (vLight.x is per blade, the rest linear). Flowers: leafLight is evaluated per vertex.
  • Ground: the original warped grid, vertex() hook snaps it to the camera's height texel; fragment is ground.js.
  • State: tState is the original RGBA8 2048^2 texture (0.125 m texels over 256 m at (0,0)); bends are queued and applied with the scan band each frame by state.computeShader (stateA -> stateB with bends + scan, stateB -> stateA copy).
  • Strokes: the canvas drawing of strokes.js re-done on the CPU (same mulberry(8128) sequence, coverage AA, source-over, 'lighter' stones), rows flipped as three's flipY uploaded them, mipmapped, 16x aniso; core.setTexture("tStrokes").
  • Stones: exact createStones placement (169 stones, 67 solid; checked against the original JS), icosahedron(1,3) shaped as stoneGeometry; per-instance lanes carry origin/size/turn/lean/tall so the fragment rebuilds the original's mat3(m) normal and vObj.

Differences from the original (and why)

  • Fire / cut terms dropped (the valley never burns or is mown): tFire = 0, cut height 255. The ground reads st.b as the constant 1 instead of sampling tState (a material may declare 9 texture slots; the ground needs all 9).
  • Ground pictures: one linear texture array; the colour slices are decoded from sRGB in the shader after filtering (three filtered in linear light). Mips are made in gamma space.
  • Lighting of blades/flowers computed per vertex (see above). Flower petals are Gouraud-lit (a few pixels each).
  • Seed fluff: drawInstanced populations are not drawn in the transparent pass on this engine build, so the fluff is drawn opaque with its alpha as a per-pixel dither that TAA averages (original: alpha blended, depthWrite false).
  • The openAt dapple under trees reads tNoiseHi (as the core's valleyShade does) instead of the 8-bit tNoise.
  • density < 1 (setDensity) is not implemented: the valley's "high" quality draws every blade.
  • Material keys carry a build number (pv_meadow_*_N): re-creating a material under a live key kept the old program.