Skip to content

Biomes and Vegetation on Voxel Terrain in Babylon.js · Part 8 of 12 in the series

Part 8: Leaves

Give the trees their leaves: sprays painted on a canvas, set as cards along limbs and branches, tilted and rolled so that some always face you, with normals that point out of the crown, shade deep inside it, and light that shines through.

Quest objectives

  • Paint sprays of leaves and needles on a canvas, one layer per kind
  • Set cards along the limbs and branches, tilted and rolled at random
  • Keep the sprays of a spruce and an acacia flat, and those of an oak free
  • Shade a crown as one round thing, with normals that point out of it
  • Cut the leaves out in the shader and let light through them

The trees of part 7 are skeletons. A real oak carries a few hundred thousand leaves, and no mesh can afford them one by one. What a tree in a game carries instead are sprays: flat cards, each with the picture of a whole twig full of leaves on it. A hundred or so of them, set along the limbs and branches, read as a crown. This part paints the sprays, sets the cards, and lights them so that the crown looks round rather than like a stack of paper.

Leaves in the texture array

The sprays live in the same texture array as the barks, so that one mesh and one material draw a whole tree. Five layers join the four barks: broad leaves for the oak, smaller and lighter ones for the birch, the needles of a spruce and of a pine, and the feathery leaves of an acacia. In src/trees.ts, replace TREE_LAYERS:

src/trees.ts
/** The layers of the trees' texture array: the barks first, then the sprays of leaves. */
export const TREE_LAYERS = [
  'oak bark',
  'birch bark',
  'conifer bark',
  'cactus skin',
  'broad leaves',
  'birch leaves',
  'spruce needles',
  'pine needles',
  'acacia leaves',
] as const;

A species says which spray it carries, how long one is in meters, and how flat its sprays lie. An oak's go any way they like. A spruce's lie nearly level along its limbs, and an acacia's make the flat top of its umbrella. In the interface Species, replace the last field and the closing brace:

src/trees.ts
bark: Layer;
  /** The sprays of leaves, and how long one is in meters. None for a cactus. */
  leaves: Layer | null;
  spray: number;
  /** How flat the sprays lie: 0 lets them tilt and roll any way, 1 keeps them level. */
  flat: number;
}

And the species get their leaves. A cactus has none. Replace SPECIES:

src/trees.ts
export const SPECIES: Species[] = [
  {
    name: 'oak', height: [9, 13], girth: 0.036, taper: 0.3, leader: false, bare: 0.28, spread: 0.42, outline: OUTLINES.dome,
    limbs: 7, branches: 3, rise: 0.55, droop: 0.1, bark: 'oak bark', leaves: 'broad leaves', spray: 2.7, flat: 0,
  },
  {
    name: 'birch', height: [9, 13], girth: 0.02, taper: 0.12, leader: true, bare: 0.3, spread: 0.2, outline: OUTLINES.egg,
    limbs: 11, branches: 2, rise: 1, droop: -0.3, bark: 'birch bark', leaves: 'birch leaves', spray: 1.9, flat: 0.2,
  },
  {
    name: 'spruce', height: [13, 19], girth: 0.022, taper: 0.06, leader: true, bare: 0.12, spread: 0.18, outline: OUTLINES.cone,
    limbs: 24, branches: 1, rise: 0.1, droop: -0.35, bark: 'conifer bark', leaves: 'spruce needles', spray: 2.4, flat: 0.8,
  },
  {
    name: 'pine', height: [11, 15], girth: 0.026, taper: 0.2, leader: true, bare: 0.55, spread: 0.3, outline: OUTLINES.umbrella,
    limbs: 8, branches: 3, rise: 0.35, droop: 0.15, bark: 'conifer bark', leaves: 'pine needles', spray: 2, flat: 0.3,
  },
  {
    name: 'acacia', height: [6, 8.5], girth: 0.036, taper: 0.35, leader: false, bare: 0.5, spread: 0.6, outline: OUTLINES.umbrella,
    limbs: 6, branches: 3, rise: 0.8, droop: 0.05, bark: 'oak bark', leaves: 'acacia leaves', spray: 2.3, flat: 0.85,
  },
  {
    name: 'cactus', height: [3, 5.5], girth: 0.075, taper: 0.8, leader: true, bare: 0.3, spread: 0.24, outline: () => 1,
    limbs: 2, branches: 0, rise: 1.6, droop: 1.3, bark: 'cactus skin', leaves: null, spray: 0, flat: 0,
  },
];

Where the sprays grow

A spray is a square card. It starts at a point of the wood, at, runs size meters along its stem, and is as wide along side. A grown tree lists its sprays next to its limbs. After the interface Limb, add Spray, and replace Tree:

src/trees.ts
/** A spray of leaves: a card from `at`, `size` meters along `stem` and as wide along `side`. */
export interface Spray {
  at: Vec;
  stem: Vec;
  side: Vec;
  size: number;
}

/** A grown tree, before it is a mesh. */
export interface Tree {
  species: Species;
  height: number;
  limbs: Limb[];
  sprays: Spray[];
}

A spray grows the way its limb goes: its stem points along the limb, so the painted twig carries on where the wood ends. If every card lay in the same plane, though, a tree seen from the side would show nothing but their edges. So each card is tilted, up or down from its limb's direction and a little sideways, and rolled about its own stem. From wherever you look, some sprays show you their face. The species' flat takes this freedom away again: at 1, a spray tilts only with the droop of the limbs, and rolls a quarter as much.

In growTree(), start a list after the one of the limbs: const sprays: Spray[] = [];. Then, after the trunk is pushed to the limbs, add the function that grows a spray:

src/trees.ts
/**
 * A spray of leaves at a point of a limb, growing on the way the limb goes. `scale`
 * makes it smaller, where the crown is narrow.
 */
const leaf = (limb: Limb, t: number, scale: number) => {
  if (!species.leaves) return;
  const { point, direction } = along(limb, t);
  // Out along the limb, tilted at random, and rolled about its own stem: seen from any
  // side, some sprays always show their face. A flat spray tilts and rolls less.
  const free = 1 - species.flat;
  const tilt = between(-0.25, 0.45) * free + species.droop * species.flat * 0.5;
  const stem = normalize(add(add(direction, UP, tilt), [between(-0.3, 0.3), 0, between(-0.3, 0.3)]));
  const level = normalize(cross(stem, UP));
  const roll = between(-1.2, 1.2) * (0.25 + 0.75 * free);
  const side = normalize(add(level, cross(stem, level), Math.tan(roll) * 0.5));
  const size = species.spray * scale * between(0.8, 1.2);
  sprays.push({ at: add(point, stem, -size * 0.12), stem, side, size });
};
  • stem is the limb's direction, plus some of UP for the tilt and a random push to the side.

  • level lies across the stem and level with the ground. Adding some of the direction that is square to both rolls the card.

  • The card starts a little behind its point on the limb, an eighth of its size back along the stem, so that it overlaps the wood it grows from.

Every limb carries three sprays along its outer part, and every branch three more. Where the crown is narrow, at the tip of a spruce or the bottom of an oak's dome, they are smaller: down to half their size where the outline is 0. After limbs.push(limb);, add:

src/trees.ts
// Where the crown is narrow, the sprays are small.
const scale = 0.5 + 0.5 * species.outline(share);
for (const t of [1, 0.8, 0.6]) leaf(limb, t, scale);

After limbs.push(branch);, the branch gets its sprays: for (const t of [1, 0.7, 0.4]) leaf(branch, t, scale);. An oak with its 7 limbs and 21 branches carries 84 sprays that way. A trunk that runs up to the top gets one more at its tip, and the tree hands out its sprays with its limbs. Replace the last line of growTree():

src/trees.ts
// A leader carries leaves up to its tip.
if (species.leader) leaf(trunk, 1, 0.5);
return { species, height, limbs, sprays };

A crown, not a stack of cards

Light a card by its own normal, and it is bright or dark all over, and next to it hangs one that is the opposite: the crown flickers like a heap of confetti. The trick that makes it one round thing is to give the cards the normals of a ball. Each corner's normal points from the middle of the crown to the corner, and a little up. The side of the crown that faces the sun is bright, the far side dark, and in between the light falls off smoothly, whichever way the single cards lie.

The same ball gives the shade, the fourth number of paint. What is deep inside the crown is in the shade of what is around it: the shade falls from 1 at the crown's rim to 0.65 at its middle, for the leaves and for the wood in there. A cactus has no crown and stays at 1.

The comment on TreeMesh can drop its last words: the shade is no longer always 1. Replace meshTree():

src/trees.ts
/** Makes the mesh of a grown tree: a tube around every limb, and a card for every spray. */
export function meshTree(tree: Tree): TreeModel {
  const { species, height } = tree;
  const positions: number[] = [];
  const normals: number[] = [];
  const paints: number[] = [];
  const indices: number[] = [];
  const bark = TREE_LAYERS.indexOf(species.bark);

  // The crown, as a ball: what is deep inside it is in the shade of what is around it.
  const crownY = height * (species.bare + 1) * 0.5;
  const crownRadius = Math.max(species.spread * height, height * (1 - species.bare) * 0.5);
  const shadeAt = (point: Vec) => {
    if (!species.leaves) return 1;
    const inside = 1 - Math.min(Math.hypot(point[0], point[1] - crownY, point[2]) / crownRadius, 1);
    return 1 - 0.35 * inside;
  };
  const vertex = (point: Vec, normal: Vec, u: number, v: number, layer: number) => {
    positions.push(...point);
    normals.push(...normal);
    paints.push(u, v, layer, shadeAt(point));
    return positions.length / 3 - 1;
  };

  for (const limb of tree.limbs) {
    const sides = SIDES[limb.level];
    const last = limb.points.length - 1;
    let side: Vec = [1, 0, 0];
    let length = 0;
    const rings: number[] = [];
    for (let p = 0; p <= last; p += 1) {
      // The ring around this point lies across the limb's way here. Its first corner
      // stays as near as it can to the first corner of the ring before, so that the
      // tube doesn't twist.
      const way = normalize(subtract(limb.points[Math.min(p + 1, last)], limb.points[Math.max(p - 1, 0)]));
      side = normalize(subtract(side, [way[0] * dot(side, way), way[1] * dot(side, way), way[2] * dot(side, way)]));
      const other = cross(way, side);
      if (p > 0) length += Math.hypot(...subtract(limb.points[p], limb.points[p - 1]));
      rings.push(positions.length / 3);
      // One corner more than sides: the first and the last are at the same place, at
      // both ends of the bark's texture.
      for (let s = 0; s <= sides; s += 1) {
        const angle = (s / sides) * Math.PI * 2;
        const out = add([side[0] * Math.cos(angle), side[1] * Math.cos(angle), side[2] * Math.cos(angle)], other, Math.sin(angle));
        vertex(add(limb.points[p], out, limb.radii[p]), out, (s / sides) * 2, length / BARK_TILE, bark);
      }
    }
    for (let p = 0; p < last; p += 1) {
      for (let s = 0; s < sides; s += 1) {
        const [a, b] = [rings[p] + s, rings[p + 1] + s];
        indices.push(a, b, a + 1, a + 1, b, b + 1);
      }
    }
    // A thick end is closed with a round tip: a cactus has no twigs to end in.
    if (limb.radii[last] > 0.03) {
      const way = normalize(subtract(limb.points[last], limb.points[last - 1]));
      const tip = vertex(add(limb.points[last], way, limb.radii[last] * 0.7), way, 1, length / BARK_TILE, bark);
      for (let s = 0; s < sides; s += 1) indices.push(rings[last] + s, tip, rings[last] + s + 1);
    }
  }

  // The sprays: a card each. Their normals point out of the crown, not out of the card,
  // so that the light shades the crown as one round thing.
  const leaves = species.leaves ? TREE_LAYERS.indexOf(species.leaves) : 0;
  for (const { at, stem, side, size } of tree.sprays) {
    const first = positions.length / 3;
    for (const [u, v] of [[0, 0], [1, 0], [1, 1], [0, 1]]) {
      const point = add(add(at, side, (u - 0.5) * size), stem, v * size);
      const outward = normalize(add(normalize([point[0], point[1] - crownY, point[2]]), UP, 0.4));
      vertex(point, outward, u, v, leaves);
    }
    indices.push(first, first + 1, first + 2, first, first + 2, first + 3);
  }

  return {
    species,
    height,
    girth: tree.limbs[0].radii[0],
    mesh: {
      positions: new Float32Array(positions),
      normals: new Float32Array(normals),
      indices: new Uint32Array(indices),
      paints: new Float32Array(paints),
    },
  };
}

The tubes are as they were. New are shadeAt(), which vertex() asks for every vertex, and the loop over the sprays at the end: four corners and two triangles per card.

Painting the sprays

The sprays are painted like the small plants of part 6: on a canvas, with the helpers of src/plants.ts, growing up from the middle of the bottom edge. paintSprite() hands out the bytes, and has already given the see-through pixels the spray's average color, so that the leaves get no dark rims.

  • cloud() paints the broad leaves and the birch's: a few hundred leaves in an oval around a twig, each pointing more or less away from where the twig starts. The dark tones are painted first and end up underneath, which gives the spray some depth.

  • The spruce's spray is flat, as on the tree: twigs to both sides of a stem, shorter toward the tip, each a row of short strokes across it.

  • The pine has five twigs that end in tufts of long needles.

  • The acacia has nine thin twigs that fan out wide, with pairs of tiny leaflets along them.

The types sort the layers' names into barks and leaves by how they end. Replace src/treeTextures.ts:

src/treeTextures.ts
import { dot, leaf, paintSprite, pick, type Context, type Painter } from './plants.ts';
import { hex, layeredNoise, mix, shade, tilingNoise, type Rgb } from './textures.ts';
import { TREE_LAYERS } from './trees.ts';

/** Pixels along each side of a tree's texture. */
export const TREE_TEXTURE = 256;

type Bark = Extract<(typeof TREE_LAYERS)[number], `${string} bark` | `${string} skin`>;
type Leaves = Exclude<(typeof TREE_LAYERS)[number], Bark>;

/**
 * How to paint each bark, from u around the trunk and v up it, both from 0 to 1. The
 * texture goes twice around a trunk, and covers two meters of its height.
 */
const BARKS: Record<Bark, (u: number, v: number) => Rgb> = (() => {
  const furrows = tilingNoise(20, 3);
  const patches = layeredNoise(4, 8, 16);
  const marks = tilingNoise(5, 48);
  const plates = tilingNoise(9, 6);
  const fine = tilingNoise(64);
  return {
    // Furrows that run up the trunk: the noise is seven times finer around than up.
    'oak bark': (u, v) => shade(mix(hex('#3a2c21'), hex('#7d6549'), furrows(u, v) * 0.9 + 0.5), patches(u, v) * 0.3),
    // White, with dark marks that run around the trunk.
    'birch bark': (u, v) => {
      const color = shade(hex('#e2decf'), patches(u, v) * 0.12);
      const mark = marks(u, v);
      return mark > 0.45 ? mix(color, hex('#2b2826'), (mark - 0.45) * 8) : color;
    },
    // Reddish plates with dark gaps between them.
    'conifer bark': (u, v) => {
      const color = mix(hex('#5d3d2a'), hex('#96643f'), patches(u, v) + 0.5);
      return Math.abs(plates(u, v)) < 0.06 ? shade(color, -0.5) : shade(color, fine(u, v) * 0.2);
    },
    // Eight ribs around the trunk, light on their crests, with pale spines along them.
    'cactus skin': (u, v) => {
      const rib = Math.cos(u * Math.PI * 8);
      return rib > 0.8 && fine(u, v) > 0.25 ? hex('#ebe4b8') : shade(hex('#4c8a3a'), rib * 0.25);
    },
  };
})();

function line(ctx: Context, x0: number, y0: number, x1: number, y1: number, width: number, color: string): void {
  ctx.beginPath();
  ctx.moveTo(x0, y0);
  ctx.lineTo(x1, y1);
  ctx.lineWidth = width;
  ctx.lineCap = 'round';
  ctx.strokeStyle = color;
  ctx.stroke();
}

/**
 * A cloud of leaves around a twig: `count` leaves of about `size`, in an oval that is
 * `width` and `height` from its middle to its rim. `colors` go from the darkest tones,
 * painted first and so underneath, to the lightest.
 */
function cloud(ctx: Context, random: () => number, count: number, width: number, height: number, size: number, colors: string[][]): void {
  line(ctx, 0, 0, 0, 0.5 + height * 0.6, 0.02, '#5b4632');
  for (let i = 0; i < count; i += 1) {
    const angle = random() * Math.PI * 2;
    const reach = Math.sqrt(random());
    const x = Math.cos(angle) * reach * width;
    const y = 0.5 + Math.sin(angle) * reach * height;
    const tones = colors[Math.floor((i / count) * colors.length)];
    // Each leaf points more or less away from where the twig starts.
    leaf(ctx, x, y, Math.atan2(x, y - 0.1) + (random() - 0.5) * 3, size * (0.8 + random() * 0.4), size * 0.4, pick(random, tones));
  }
}

/** How to paint each spray of leaves: a twig from the middle of the bottom edge, as it grows off a branch. */
const SPRAYS: Record<Leaves, Painter> = {
  'broad leaves': (ctx, random) =>
    cloud(ctx, random, 330, 0.46, 0.46, 0.085, [['#2f5c22', '#386a28'], ['#447c2d', '#508c33'], ['#5e9c3a', '#6eae44']]),
  'birch leaves': (ctx, random) =>
    cloud(ctx, random, 200, 0.38, 0.46, 0.06, [['#4d7d2c', '#5a8d33'], ['#6fa23c', '#82b446'], ['#96c452', '#a9d05e']]),
  // A flat spray of a spruce: twigs to both sides of the stem, each thick with needles.
  'spruce needles': (ctx, random) => {
    const needles = (x0: number, y0: number, x1: number, y1: number) => {
      const steps = Math.ceil(Math.hypot(x1 - x0, y1 - y0) / 0.02);
      const [nx, ny] = [-(y1 - y0), x1 - x0].map((c) => (c / Math.hypot(x1 - x0, y1 - y0)) * 0.035);
      for (let i = 0; i <= steps; i += 1) {
        const [x, y] = [x0 + ((x1 - x0) * i) / steps, y0 + ((y1 - y0) * i) / steps];
        const color = pick(random, ['#24543f', '#2f6649', '#3b7653', '#4a885e']);
        line(ctx, x - nx, y - ny + 0.02, x + nx, y + ny + 0.02, 0.012, color);
      }
    };
    needles(0, 0, 0, 0.96);
    for (let i = 0; i < 9; i += 1) {
      const y = 0.05 + i * 0.1;
      const length = 0.46 * (1 - i / 11);
      for (const way of [-1, 1]) needles(0, y, way * length * (0.9 + random() * 0.2), y + length * 0.6);
    }
  },
  // Twigs that end in tufts of long needles.
  'pine needles': (ctx, random) => {
    for (const [x, y] of [[0, 0.72], [-0.28, 0.55], [0.27, 0.5], [-0.14, 0.3], [0.16, 0.26]]) {
      line(ctx, 0, 0, x, y, 0.022, '#6b4a33');
      for (let i = 0; i < 46; i += 1) {
        const angle = Math.atan2(x, y) + (random() - 0.5) * 3.4;
        const length = 0.17 + random() * 0.09;
        line(ctx, x, y, x + Math.sin(angle) * length, y + Math.cos(angle) * length, 0.012, pick(random, ['#2d5e3e', '#3a7147', '#488352', '#57945c']));
      }
    }
  },
  // Feathery leaves on twigs that fan out wide: a flat-topped spray.
  'acacia leaves': (ctx, random) => {
    for (let i = 0; i < 9; i += 1) {
      const angle = (i - 4) * 0.3 + (random() - 0.5) * 0.15;
      const length = 0.75 + random() * 0.2;
      const color = pick(random, ['#5f8433', '#6f953b', '#80a646']);
      line(ctx, 0, 0, Math.sin(angle) * length, Math.cos(angle) * length, 0.012, '#6d5a3a');
      for (let step = 3; step <= 16; step += 1) {
        const t = step / 16;
        const [x, y] = [Math.sin(angle) * length * t, Math.cos(angle) * length * t];
        leaf(ctx, x, y, angle + 1.1, 0.075, 0.02, color);
        leaf(ctx, x, y, angle - 1.1, 0.075, 0.02, color);
      }
    }
    dot(ctx, 0, 0, 0.015, '#6d5a3a');
  },
};

/** Paints every layer of the trees' texture array: RGBA bytes, one layer after the other. */
export function paintTreeLayers(): Uint8Array {
  const pixels = TREE_TEXTURE * TREE_TEXTURE;
  const data = new Uint8Array(pixels * 4 * TREE_LAYERS.length);
  TREE_LAYERS.forEach((name, layer) => {
    if (name in SPRAYS) {
      data.set(paintSprite(TREE_TEXTURE, SPRAYS[name as Leaves], layer + 20), layer * pixels * 4);
      return;
    }
    const paint = BARKS[name as Bark];
    for (let y = 0; y < TREE_TEXTURE; y += 1) {
      for (let x = 0; x < TREE_TEXTURE; x += 1) {
        const [r, g, b] = paint(x / TREE_TEXTURE, y / TREE_TEXTURE);
        data.set([r, g, b, 255], (layer * pixels + y * TREE_TEXTURE + x) * 4);
      }
    }
  });
  return data;
}

Cutting out and lighting

The fragment shader throws away the pixels between the leaves, as the plants' shader does. Bark is opaque, so the test never bites there. Leaves also get their own light. A leaf is thin: lit from behind, it glows. So a quarter of the sun's light counts for the side that faces away from it, and the light of the sky is lifted toward what an open place gets, since it finds its way in between the leaves. The shader has to know which layers are leaves: the uniform firstLeaves is the number of the first one. Replace src/tree.fragment.glsl:

src/tree.fragment.glsl
precision highp float;
precision highp sampler2DArray;

varying vec3 vPosition;
varying vec3 vNormal;
varying vec4 vPaint;

uniform sampler2DArray layers;
uniform vec3 cameraPosition;
uniform vec3 sunDirection;
uniform vec3 sunColor;
uniform vec3 skyColor;
uniform vec3 groundColor;
uniform vec3 fogColor;
uniform vec2 fogRange;
// The number of the first layer that holds leaves: the ones before it are bark.
uniform float firstLeaves;

void main() {
  float layer = floor(vPaint.z + 0.5);
  vec4 texel = texture(layers, vec3(vPaint.xy, layer));
  // Between the leaves of a spray there is nothing.
  if (texel.a < 0.4) discard;

  vec3 normal = normalize(vNormal);
  float sun = max(dot(normal, -sunDirection), 0.0);
  vec3 ambient = mix(groundColor, skyColor, normal.y * 0.5 + 0.5);
  // Leaves let some of the light through: their far side is not all dark.
  if (layer >= firstLeaves) {
    sun = sun * 0.75 + max(dot(normal, sunDirection), 0.0) * 0.25;
    ambient = mix(ambient, skyColor, 0.5) * 1.2;
  }
  vec3 lit = texel.rgb * vPaint.w * (ambient + sunColor * sun);

  float fog = smoothstep(fogRange.x, fogRange.y, distance(vPosition, cameraPosition));
  gl_FragColor = vec4(mix(lit, fogColor, fog), 1.0);
}

The material names the uniform and sets it: the first layer whose name says leaves or needles. In src/treeMaterial.ts, replace createTreeMaterial():

src/treeMaterial.ts
/** The trees' material: bark and leaves from one texture array, lit by the sun and the sky. */
export function createTreeMaterial(scene: Scene, options: FogOptions): ShaderMaterial {
  const layers = new RawTexture2DArray(
    paintTreeLayers(),
    TREE_TEXTURE,
    TREE_TEXTURE,
    TREE_LAYERS.length,
    Constants.TEXTUREFORMAT_RGBA,
    scene,
    true,
    false,
    Texture.TRILINEAR_SAMPLINGMODE,
  );
  // The bark goes around and up the trunk without an end.
  layers.wrapU = Texture.WRAP_ADDRESSMODE;
  layers.wrapV = Texture.WRAP_ADDRESSMODE;
  const material = new ShaderMaterial(
    'trees',
    scene,
    { vertexSource, fragmentSource },
    {
      attributes: ['position', 'normal', 'paint', 'place', 'look'],
      uniforms: ['world', 'viewProjection', ...LIGHT_UNIFORMS, 'firstLeaves'],
      samplers: ['layers'],
    },
  );
  material.setTexture('layers', layers);
  setLight(material, options);
  material.setFloat('firstLeaves', TREE_LAYERS.findIndex((name) => name.includes('leaves') || name.includes('needles')));
  // A spray of leaves is seen from both sides.
  material.backFaceCulling = false;
  return material;
}

That the material draws both sides of every triangle was a promise in part 7. Now it is needed: a spray is seen from above and from below.

Try it

Turn left at the start and walk into the nursery again. The oaks have domes now, the birches thin, light crowns, the spruces tiers of flat boughs, and the acacias their umbrellas. The cacti are as bare as before. Stand under an oak and look up: you see the single cards, tilted every way. Then step back until they merge into a crown, and walk around it: the side toward the sun stays bright, whichever cards happen to face you. In src/trees.ts, set the oak's flat to 1 and reload to see why its sprays need their freedom, and try a spray of 1.5 for a tree that has had a dry summer.

Spruces and pines from close. The spruce's sprays lie nearly flat along its limbs, in tiers. The pines carry tufts of needles on a few limbs high up a bare trunk.
Trees in leaf. Click, then turn left and walk into the nursery. Stand under a crown and look up, then step back. WASD walks, Shift runs, F flies (Q/E down and up).
Open in a new tab

Comments

The comments are GitHub Discussions: sign in with GitHub to write one.

The comments come from GitHub, through giscus. Loading them sends your IP address to giscus.app and GitHub.