主要内容

Terrain Generator

R2026b

Generate terrain elevation heightmap for marine environment simulation

Since R2026b

  • Terrain Generator block

Libraries:
Aerospace Blockset Maritime Applications Library / Environment

Description

Add-On Required: This feature requires the Aerospace Blockset Maritime Applications Library add-on.

The Terrain Generator block uses noise functions to generate heightmaps for marine terrains such as:

  • Diamond-square — Create fractal terrain heightmap with pronounced ridges and valleys.

  • Perlin noise — Create heightmap with smooth, continuous terrain with gradual elevation changes.

To fine tune the overall terrain appearance, change the block frequency, number of octaves, amplitude, and roughness scaling factor. The terrain appearance is static, unlike wave spectrums, which vary with time.

You can use the block in scenario simulation, where the Terrain Generator block initializes a terrain map for visualization.

Ports

Output

expand all

Generated terrain elevation data, returned as a N-by-M matrix in the units specified in Units.

Data Types: double

Parameters

expand all

To edit block parameters interactively, use the Property Inspector. From the Simulink® Toolstrip, on the Simulation tab, in the Prepare gallery, select Property Inspector.

Parameter and port units, specified as Metric (MKS) or English.

Programmatic Use

To set the block parameter value programmatically, use the set_param function.

To get the block parameter value programmatically, use the get_param function.

Parameter: units
Values: Metric (MKS) (default) | English

Example: set_param(gcb,"units","Metric (MKS)")

Number of grid rows and columns of the heightmap, specified as a 2-element array of positive integers [nrows ncols], in the units specified in Units.

Dependencies

When the Terrain source parameter is set to Diamond-square, the grid rows and columns must be equal and of the form 2m+1.

Programmatic Use

To set the block parameter value programmatically, use the set_param function.

To get the block parameter value programmatically, use the get_param function.

Parameter: gridSize
Values: [513 513] (default) | 2-element array
Data Types: double

Example: set_param(gcb,"terrainSize","[513 513]")

"Distance between each grid point, specified as a finite positive scalar in the units specified in Units.

Programmatic Use

To set the block parameter value programmatically, use the set_param function.

To get the block parameter value programmatically, use the get_param function.

Parameter: resolution
Values: 1 (default) | real scalar
Data Types: double

Example: set_param(gcb,"resolution","1")

Minimum and maximum elevation values for the generated marine terrain relative to a reference level (typically mean sea level), specified as a finite 2-element vector in the units specified in Units.

Programmatic Use

To set the block parameter value programmatically, use the set_param function.

To get the block parameter value programmatically, use the get_param function.

Parameter: elevationRange
Values: [0 200] (default) | finite 2-element vector
Data Types: double

Example: set_param(gcb,"elevationRange","[0 200]")

Terrain generation source, specified as one of these values:

  • Diamond-square — Create fractal terrain heightmap with pronounced ridges and valleys.

  • Perlin noise — Create heightmap with smooth, continuous terrain with gradual elevation changes.

Programmatic Use

To set the block parameter value programmatically, use the set_param function.

To get the block parameter value programmatically, use the get_param function.

Parameter: terrainSource
Values: Diamond-square (default) | Perlin noise

Example: set_param(gcb,"terrainSource","Diamond-square")

Random number generator seed to initialize the random number generator for procedural terrain generation, specified as a scalar positive integer or 0.

Programmatic Use

To set the block parameter value programmatically, use the set_param function.

To get the block parameter value programmatically, use the get_param function.

Parameter: seed
Values: 1 (default) | scalar positive integer or 0
Data Types: double

Example: set_param(gcb,"seed","1")

Terrain roughness scaling factor, specified as a finite positive scalar in the range 0.0 to 1.0, inclusive, to control how rapidly terrain detail increases across successive noise layers when generating the terrain heightmap. Lower values produce rougher terrain with more pronounced features; higher values produce smoother terrain.

Dependencies

To enable this parameter, set Terrain source to Diamond-square.

Programmatic Use

To set the block parameter value programmatically, use the set_param function.

To get the block parameter value programmatically, use the get_param function.

Parameter: roughnessFactor
Values: 0.5 (default) | finite positive scalar in the range 0.0 to 1.0, inclusive
Data Types: double

Example: set_param(gcb,"roughnessFactor","0.5")

Number of noise layers (octaves) combined to generate a Perlin noise terrain, specified as a real finite scalar integer.

Dependencies

To enable this parameter, set Terrain source to Perlin noise.

Programmatic Use

To set the block parameter value programmatically, use the set_param function.

To get the block parameter value programmatically, use the get_param function.

Parameter: numOctaves
Values: 4 (default) | real finite scalar integer
Data Types: double

Example: set_param(gcb,"numOctaves","4")

Perlin noise amplitude to control the elevation variation magnitude generated by Perlin noise, specified as a real finite scalar.

Dependencies

To enable this parameter, set Terrain source to Perlin noise.

Programmatic Use

To set the block parameter value programmatically, use the set_param function.

To get the block parameter value programmatically, use the get_param function.

Parameter: amplitude
Values: 1.0 (default) | real finite scalar
Data Types: double

Example: set_param(gcb,"amplitude","1.0")

Base spatial frequency, specified as a finite positive scalar or 0.

  • To generate a smooth terrain with large‑scale features, use lower frequencies.

  • For finer detail terrain, use higher frequencies.

Dependencies

To enable this parameter, set Terrain source to Perlin noise.

Programmatic Use

To set the block parameter value programmatically, use the set_param function.

To get the block parameter value programmatically, use the get_param function.

Parameter: frequency
Values: 0.01 (default) | finite positive scalar or 0
Data Types: double

Example: set_param(gcb,"frequency","0.01")

Amplitude reduction factor, specified as a finite positive scalar in the range 0.0 to 1.0, inclusive.

  • To generate a smooth terrain with limited fine detail, specify a lower persistence value, for example, 0.3 to 0.5.

  • To emphasize roughness and smaller variations in the terrain, specify a higher persistence value, for example, 0.6 to 0.8.

Dependencies

To enable this parameter, set Terrain source to Perlin noise.

Programmatic Use

To set the block parameter value programmatically, use the set_param function.

To get the block parameter value programmatically, use the get_param function.

Parameter: persistence
Values: 0.5 (default) | finite positive scalar in the range 0.0 to 1.0, inclusive
Data Types: double

Example: set_param(gcb,"persistence","0.5")

Frequency growth factor applied to successive Perlin noise octaves, specified as a finite positive scalar or 0.

  • For gradual scale transitions, use lower lacunarity values, for example, 1.5 to 2.0.

  • To emphasize visible size differences between large and small scale transitions, use higher lacunarity values.

Dependencies

To enable this parameter, set Terrain source to Perlin noise.

Programmatic Use

To set the block parameter value programmatically, use the set_param function.

To get the block parameter value programmatically, use the get_param function.

Parameter: lacunarity
Values: 2.0 (default) | finite positive scalar or 0
Data Types: double

Example: set_param(gcb,"lacunarity","2.0")

Version History

Introduced in R2026b