Dynamic Simulation Zone API
Runtime Methods
dynamicSimulationZoneInstance.ForceUpdateZone(resetSimulation: true)Forces the simulation zone to rebuild its baked data and restart the simulation.
If resetSimulation = true, all simulation textures and particle buffers are cleared and reinitialized.
Also triggers a global update of all zone intersections, ensuring proper blending between neighboring zones.
Use cases:
When terrain or geometry inside the zone has changed
After modifying resolution, size, or intersection layer mask
Editor Baking & Cache Control
These methods control precomputation (baking) and cache management for dynamic water simulation zones. They are used both inside the Editor and by external procedural world-generation tools (such as MicroVerse https://youtu.be/QTRV11amGlE, or custom pipeline scripts) to automatically pre-bake water flow data during world creation.
KWS_EditorDynamicWavesSimulationZones.StartBaking(KWS_DynamicWavesSimulationZone: zoneInstance)Begins the precomputation (baking) process for the specified simulation zone. Existing cache data will be overwritten. During baking, the simulation runs in accelerated preview mode (about 20× faster than real-time).
KWS_EditorDynamicWavesSimulationZones.StopBaking(KWS_DynamicWavesSimulationZone: zoneInstance)Stops the baking process and saves all generated data to disk. Creates a set of baked assets (depth, flow, foam, etc.) in the configured cache folder. See the simulation data textures
KWS_EditorDynamicWavesSimulationZones.SetSaveFolderPath(assetRelativePath: path)Sets the folder path where baked simulation assets are saved. Must be inside the Unity Assets/ directory.
Example: KWS_EditorDynamicWavesSimulationZones.SetSaveFolderPath("Assets/KWS2/Cache");
Deletes all cached simulation data for the selected zone. Used when a terrain or water setup changes and needs to be fully re-baked.
Effects:
Removes all
.kwsTexture,.asset, and related filesClears cached references from the simulation zone
Calls
AssetDatabase.Refresh()in Editor mode
Typical use cases:
Rebuilding cached water zones after world regeneration
Cleaning up temporary simulation data created by procedural tools
Simulation Data Access
Returns the current simulation data texture (RGBA16 format unsigned normalized [0-1]). Each channel stores the following encoded values:
R: Velocity X, encoded from [-10, 10] range
G: Velocity Z, encoded from [-10, 10] range
B: Water Height Offset relative to terrain, encoded from [-2, 20] range
A: Terrain World Height, normalized by distance from water to zone top
Use the following logic to decode:
Velocity.xy = (data.rg - 0.5) * 20.0
Height = data.b * 22.0 - 2.0
Depth = data.a * abs(WaterPosY - (ZonePosY + ZoneSizeY * 0.5))
Returns the secondary data texture (wetmap / foam / SDF mask). Used for blending with terrain and generating foam or wetness visuals.
Returns the additional simulation data texture in RGBA8 format (unorm). Each channel contains the following data:
R: Wetmap - surface wetness mask (used for darkening wet surfaces over time)
G: Shoreline Mask Fade - normalized Signed Distance Field (SDF) mask for shore fading
B: Foam Mask - intensity of generated foam in the water
A: Low res ortho scene depth
float worldHeight = lerp(zonePos.y - zoneSize.y, zonePos.y + zoneSize.y, data.w);
Returns the simulation’s normal map, XYZ range [-1, 1]
Returns the color data texture if the “colored dynamic waves” option is active
Returns the texture that accumulates data from effectors interacting with the water surface
Returns the depth texture for dynamic obstacle meshes interacting with the water surface
Returns the static baked depth texture generated from the orthographic top-down pass during zone initializing or baking. Used by the simulation to know where water can flow over terrain or objects.
Returns the Signed Distance Field (SDF) version of the intersection depth texture. Used to create smooth transitions for shoreline ocean waves fading.
Returns true if the zone is currently baking intersection/depth data (e.g., when using the “Start Cache” or “Stop & Save” workflow).
Last updated