Vixen
02b45cc4
csharp
public readonly record struct GrassType

One kind of grass: what a .vxgrass asset holds.

Read the guide page for this →

Remarks

[docs/plan/31 § D8]'s derived counterpart to FoliageType, and it is smaller because most of that does not apply. Grass is scattered from a rule and never persisted: nothing about a blade of grass is in any file, so there is no identity to keep, no collision to allocate and no undo record to hold. What a level says is "this type, on this layer", and a million blades follow.

⚠ Density is the candidate density and never the placed one. It fixes the grid a cell is scattered over — which on the device is the dispatch extent and therefore cannot depend on anything sampled — and what the painted weight decides is what fraction of those candidates survive. A density that varied with the weight would mean a dispatch whose size depends on a texture read, which is not a thing.

⚠ The layer is a name, for LayerFilter's reason. Removing the second of six terrain layers shifts the rest down, and a type holding the index would silently start growing on different ground.

Fields and properties (16)

  • public string Name

    What the type is called.

  • public string Mesh

    The mesh this scatters, by asset name.

  • public string Layer

    Which terrain layer's weight it reads, or empty to grow anywhere.

  • public float MinWeight

    The weight below which nothing grows, 0…1.

  • public float MaxWeight

    And the weight at which the field is at full density.

  • public float Density

    How many candidates a square metre is scattered with.

  • public float Jitter

    How far a candidate may wander from its grid slot, 0…1 of half a step.

  • public float MinScale

    The smallest uniform scale a blade is given.

  • public float MaxScale

    And the largest.

  • public bool RandomYaw

    Whether each blade is turned to a random heading.

  • public float AlignToNormal

    How much a blade turns to face the surface normal, 0…1.

  • public float MaxSlope

    The steepest ground it grows on, as a slope in radians from flat.

  • public float StartCullDistance

    How far away blades start fading out, in metres.

  • public float EndCullDistance

    And where they are gone.

  • public GrassWind Wind

    How it moves.

  • public bool NeedsSurfaceWeight

    Whether a candidate has to ask what is painted underneath it.

Methods (6)

  • public static GrassType Of(string name)

    A type with the settings a new one starts from.

  • public FoliageType ToFoliageType()

    The same rule, as a palette entry a volume can hold.

  • public float DensityAt(float weight)

    What fraction of this type's candidates a painted weight keeps, 0…1.

  • public int GridOf(float cellSize)

    How many candidates a cell is scattered over, along one axis.

  • public int CandidatesFor(float cellSize)

    How many candidates one cell generates.

  • public string? Validate()

    Why this type cannot be used, or if it can.

Used by (15)

  • GrassDispatchVixen.Rendering.Terrain
  • GrassDispatchTestsVixen.Rendering.Terrain.Tests
  • GrassDrawVixen.Rendering.Terrain
  • GrassDrawPassTestsVixen.Rendering.Terrain.Tests
  • GrassRendererVixen.Rendering.Terrain
  • GrassRendererTestsVixen.Rendering.Terrain.Tests
  • GrassScatterVixen.Foliage
  • GrassScatterParityTestsVixen.Rendering.Terrain.Tests
  • GrassScatterTestsVixen.Foliage.Tests
  • TerrainSurfaceTestsVixen.Rendering.Terrain.Tests
  • TypeRegistrationVixen.Foliage
  • Vixen_Foliage_GrassTypeSerializerVixen.Foliage
  • TerrainAssetImporterVixen.Editor.Assets
  • TerrainModuleVixen.Editor.Terrain
  • TerrainSessionTestsVixen.Editor.App.Tests