Kiwi Grass Docs
View product

Authoring

Persistent bakes

Generate, validate, migrate, and load project-owned persistent grass data.

Kiwi Grass 26.10.0Unity 6000.0+URP

Persistent bakes let Kiwi Grass load placement data from disk instead of regenerating all blades on startup.

Workflow

  1. Add TerrainGrassRenderer to a Terrain.
  2. Assign the TerrainLayer, material, and optional profiles.
  3. Leave Tools > Kiwi Studios > Kiwi Grass > Automatic Edit Mode Preview enabled for live Edit Mode generation. This global editor toggle is enabled by default.
  4. When the current settings are ready for players, expand Persistent Bake and select Bake Persistent Asset, or use Actions > Persistent Bake > Bake Current Settings.
  5. Keep Load Bake Automatically enabled to reuse the saved data in Edit Mode and Play Mode.

Preview generation without a loaded bake never creates or rewrites persistent files. The explicit bake is a one-shot operation: it creates and assigns the metadata asset when needed, regenerates once, writes the result, and then returns to preview-only behavior. Supported terrain edits to an already loaded saved bake update its changed chunks. Layout and placement-setting changes require another explicit bake.

The bake writes two user assets:

  • TerrainGrassBakeAsset.asset
  • TerrainGrassBakeAsset.kiwigrassbake

Both are created under Assets/ThirdParty/KiwiStudios/Grass/Bakes by default. Change the project-wide location from Tools > Kiwi Studios > Kiwi Grass > Persistent Bakes > Choose Storage Folder, or from Actions > Persistent Bake > Storage on the renderer. Storage must remain inside a subfolder of Assets; existing assigned bake assets are not moved when the setting changes.

Validation states

The inspector caches fast header and metadata validation for the assigned asset. Tools/Kiwi Studios/Kiwi Grass/Validate Bake Assets and build validation force a complete streamed checksum check. A player build fails with an actionable message when a required bake is missing, stale, corrupt, or incompatible; valid external payloads are added to StreamingAssets automatically.

  • valid bake
  • missing bake
  • stale bake
  • corrupt bake
  • unsupported format
  • missing binary payload
  • terrain mismatch
  • settings mismatch
  • gpu stride mismatch

Layout and placement changes make a bake stale. Rendering-only changes such as wind, material, lighting, render distance, LOD distance, fog, and shadow tuning do not invalidate the placement payload.

Runtime behavior

When Load Bake Automatically is enabled and the bake validates, the renderer restores the Edit Mode preview and uploads the same blade data in Play Mode while allocating draw resources from the current quality settings. Version 1 payloads read their legacy 48-byte blade records and transcode them once into the packed upload path. Version 2, 3 and 4 payloads store a 28-byte blade record and stream it into native memory without expanding every blade to the 48-byte CPU form. Its normal, LOD and color word is the GPU word itself, so loading copies it unchanged. Bakes saved by packages that used the earlier 32-byte record report a blade stride mismatch and must be rebaked. Every supported format Burst-transcodes into the 24-byte runtime GPU buffer and releases the temporary native array after transfer. With both domain and scene reload disabled, an already-ready preview survives the Edit Mode to Play Mode transition and is not loaded or generated again. If the bake is invalid in Play Mode and Runtime Bake Fallback is enabled, normal regeneration is used. If fallback is disabled, the renderer stays not-ready and reports the validation error.

Persistent writes happen only in the editor. Runtime players never write bake assets. Packing, full writes, unchanged-file comparisons, checksums, and validation use bounded streaming buffers instead of duplicating the complete payload in managed memory. The metadata asset stores paths rather than a TextAsset reference, so the binary payload does not stay resident in Unity object memory. Platforms with file-backed StreamingAssets load it directly; URI-backed platforms download it to temporary storage first and then use the same bounded file reader. A newly saved one-species bake upgrades version 1 data to format 2; enabling two or more species regenerates and writes format 3.

The writer, editor validator, local loader, and streamed loader fingerprint the same living-layer set and assigned control map. Changing the map's prebaked placement revision correctly makes the bake stale; an unchanged artist-controlled format-2 bake loads directly instead of falling back to runtime generation.

Format 2 stores one 32-byte species header around species-agnostic blade and chunk ranges. Format 3 repeats that validated header for two to four contiguous species sections. Each header records a stable species ID, profile fingerprint, material identity, chunk range, active blade count, and reserved blade capacity. Formats 1 and 2 map to primary species ID 1. Format 3 rejects zero or duplicate IDs, gaps, overlaps, invalid ranges, mismatched totals, and profile or material identity that does not match the payload fingerprint. Reordering advanced composition entries does not change species identity or invalidate an otherwise unchanged field.

Chunk streaming

After saving a valid bake, enable Nearby Chunk Streaming in the renderer's Bake tab. Streaming is off by default. The renderer loads the chunks needed by its camera consumers and nearby prefetch range, retaining the previous published set while the replacement prepares. Its directory preserves global chunk and species identity. Camera removal, origin changes, an empty camera set, and reload use the same saved payload.

CPU and GPU limits reserve source data, directory, cache, staging, command arrays, and blade/precision payloads across pending and retired owners. They are payload limits; native allocator overhead, managed objects, other rendering resources, and graphics-driver memory are separate costs. The inspector reports process graphics memory as a diagnostic. Increase a reported insufficient budget or reduce render/prefetch range, then use Retry Chunk Streaming.

Terrain edits to a loaded streaming bake prepare bounded private dirty batches. The saved bake remains marked pending until the complete set can atomically update its payload and metadata in Edit Mode. If an update is interrupted, its original saved payload remains intact and validation requires a new full bake. Unused blade reservations retain their previous words. The new presentation revision becomes visible with the completed geometry set. Runtime changes use private temporary snapshots and leave the saved assets unchanged. Layout changes require a new bake. Preparation budgets are cooperative: native allocation, publication, and Editor asset import can still exceed a requested step budget.

Terrain transforms

Blade roots are stored in terrain-local coordinates. The shader reconstructs world roots from the terrain world offset, and runtime chunk bounds shift when the Terrain position changes. Persistent bakes currently reject non-identity terrain rotation and non-unit terrain scale.

Still stuck?

Bring the renderer status with you.

Include the Kiwi Grass version, Unity and URP versions, operating system, graphics API, renderer status, Player log, and a minimal reproduction.

Email supportJoin Discord

Kiwi Grass 26.10.0

Search documentation