veget_set - ryzom/ryzomcore GitHub Wiki


title: Adding microvegetation sets description: How to create and tune vegetation descriptor files for landscape tilesets published: true date: 2023-03-16T23:02:26.951Z tags: editor: markdown dateCreated: 2022-03-13T07:10:05.361Z

Microvegetation (grass, small plants, bushes) is spawned procedurally on landscape tiles based on vegetation descriptor files (.vegetdesc). Each tileset can reference one vegetation descriptor, which defines a list of CVegetable entries — each specifying a shape, density, scale, rotation, color, and rendering properties.

Create texture and shape

One texture is shared by all vegetation shapes in a vegetation set. A simple quad or triangle shape (.veget file) is created for each vegetation component. The vegetation texture is UV-mapped to the shape before exporting.

Shape properties set in the exporter (3ds Max Node Properties) control the rendering mode:

Property Effect
Lighted Per-vertex dynamic lighting (requires normals). More expensive vertex shader.
PreComputeLighting Lighting is baked per instance at spawn time, cheaper than dynamic. Only used if Lighted is also set.
DoubleSided Renders both faces. Doubles fillrate cost.
AlphaBlend Alpha blending with Z-sorting for smooth appearance/disappearance. Only valid if (!Lighted || PreComputeLighting) && DoubleSided.
BestSidedPreComputeLighting Uses max(normal, -normal) for precomputed lighting. Only valid with PreComputeLighting.
BendCenterMode Controls wind bending pivot: BendCenterNull (bend from origin) or BendCenterZ (bend from ground plane, good for comb-like vegetation).

Bend weight per vertex is read from vertex color R channel if vertex colors are present, otherwise from the vertex Z position.

Assembly

Assemble the vegetation set using the Object Viewer's vegetable editor. The result is saved as a .vegetdesc file and assigned to a tileset via the Choose Veget button in tile_edit.exe.

Distance of creation

Each vegetable has a distance type controlling at what range it is created. There are 5 distance categories:

DistType Range
0 10 m
1 20 m
2 30 m
3 40 m
4 50 m

Farther distances create more instances and cost more performance. Choose according to the vegetation size — small grass can use a short distance, while larger bushes may need a longer one. Alpha-blended vegetation fades out smoothly over a 10 m blend transition before the distance cutoff.

Density tuning

Density is defined as the number of instances per square meter, using a CNoiseValue with AbsValue and RandValue parameters. The generated density at any point is AbsValue + random(0, RandValue).

The trick is to use a negative AbsValue to create clustered "blocks" of vegetation with gaps between them:

  • Example: AbsValue = -10, RandValue = 20 produces a range of -10 to +10. Since negative density is clamped to 0, half the area has nothing, and the other half has density 1 to 10.
  • MaxDensity clamps the upper bound. For example, to get 50% chance of blocks with exactly 10 instances/m²: set AbsValue = -1000, RandValue = 2000, MaxDensity = 10. The noise frequency controls the "size of blocks".

Surface angle filtering

Density can be modulated by surface normal angle, so vegetation only appears on appropriate terrain:

AngleType Effect
AngleGround Maximum density when surface faces up (normal = Z). Density falls to 0 at the specified minimum angle. Default.
AngleCeiling Maximum density when surface faces down (normal = -Z). For cave ceilings.
AngleWall Maximum density at a specified angle range. For cliff-face vegetation.

Render pass performance

The engine uses 5 render passes for vegetation, listed from cheapest to most expensive:

Pass Flags Notes
Unlit !Lighted, !DoubleSided Cheapest. Good for small grass.
Unlit 2-Sided !Lighted, DoubleSided ~2x fillrate of single-sided.
Lighted Lighted, !DoubleSided Dynamic per-vertex lighting. More expensive vertex shader.
Lighted 2-Sided Lighted, DoubleSided Most expensive non-blended pass.
Unlit 2-Sided ZSort AlphaBlend, DoubleSided Alpha blended with Z-sorting. ~2x fillrate cost but enables smooth fade-in/out with distance.

Performance tips:

  • Avoid Lighted without PreComputeLighting (Lighted = true, PreComputeLighting = false). It uses a more expensive vertex shader for dynamic lighting, which is rarely worth it for small vegetation.
  • Alpha Blend costs roughly twice as much fillrate as opaque rendering, but enables smooth appearance transitions and distance fade. This can allow you to use a shorter distance of creation.
  • Avoid DoubleSided if you don't need it — it doubles fillrate.
  • Use the Num vegetable tri counter in the Object Viewer's vegetable dialog to monitor triangle counts as you tune your setup.

Add to tile bank

Assign the .vegetdesc file to a tileset using the Choose Veget button in the tile bank manager. Each tileset can have one vegetation descriptor. See tile bank — vegetation for details.

Credits

Authors

  • Lionel Berenguier

Source

⚠️ **GitHub.com Fallback** ⚠️