hex-world
    Preparing search index...

    Function attachScatterTexture

    • Give a stock three.js material fine procedural mottling, so a flat-shaded low-poly plant stops reading as plastic beside textured ground.

      Opt-in per material like every other attach in this library, and for the usual reason — a rock wants a different grain from a canopy, and some props want none. Unlike attachSnow and attachWindSway this one needs no data and no driver: it is inert-or-on from the moment it is attached, and there is nothing to push per frame.

      Composition. The mottle lands before SEASON_COLOR_SLOT, which puts it under both of the seasonal effects however they were attached: the foliage tint recolours the already-mottled surface (so the variation carries through autumn instead of being flattened by it), and snow covers it, which is what snow does to a texture.

      Safe on a material that already has an onBeforeCompile (the existing hook still runs), and idempotent.

      Parameters

      Returns void

      const broadleaf = new THREE.MeshLambertMaterial({ vertexColors: true });
      attachScatterTexture(broadleaf);
      attachSeasonalTint(broadleaf, { summer: BROADLEAF_CANOPY_COLOR });
      attachSnow(broadleaf);
      // A bush's facets are already small — go finer, and lighter.
      attachScatterTexture(bush, { scale: 11, strength: 0.14 });