๐๏ธ Landscape Integration - Automatic Terrain Sculpting
One of NextGen 2.0's most powerful features is its deep integration with Unreal Engine's Landscape system. This post covers how water bodies interact with terrain through islands, exclusion volumes, and brush effects.
The Water Brush Systemโ
NextGen 2.0 uses a sophisticated brush system to modify landscapes automatically when water bodies are placed.
Brush Actor Interfaceโ
All actors that can modify terrain implement IOceanologyWaterBrushActorInterface:
class IOceanologyWaterBrushActorInterface
{
// Does this actor modify landscape heightmap?
virtual bool AffectsLandscape() const;
// Does this actor contribute to water mesh?
virtual bool AffectsWaterMesh() const;
// Can this actor ever affect the water mesh?
virtual bool CanEverAffectWaterMesh() const;
// Can this actor ever affect water info texture?
virtual bool CanEverAffectWaterInfo() const;
};
Brush Capabilities by Actor Typeโ
| Actor | Affects Landscape | Affects Water Mesh | Affects Water Info |
|---|---|---|---|
| Ocean | Yes (optional) | Yes | Yes |
| Lake | Yes (optional) | Yes | Yes |
| River | Yes (optional) | Yes | Yes |
| Island | Yes | No | No |
| Exclusion Volume | No | Yes (removes) | Yes |
| Custom Water | No | No | No |
Island Systemโ
Islands create landmasses within water bodies, carving out the water mesh and optionally modifying terrain.
Island Actor Featuresโ
- Spline-defined shape: Draw island boundaries with splines
- Terrain modification: Raises landscape within bounds
- Water mesh exclusion: Automatically removes water inside
- Weightmap painting: Applies landscape layers
Island Propertiesโ
// Curve settings for terrain shaping
FOceanologyWaterCurveSettings OceanologyWaterCurveSettings;
// Heightmap modification parameters
FOceanologyWaterBodyHeightmapSettings WaterHeightmapSettings;
// Per-layer weightmap settings
TMap<FName, FOceanologyWaterBodyWeightmapSettings> WaterWeightmapSettings;
Creating an Islandโ
- Add an Oceanology Island actor to your level
- Edit spline points to define the island boundary
- Configure heightmap settings for terrain elevation
- Set up weightmap settings for landscape layers
- The water mesh automatically excludes the island area
Island-Water Interactionโ
Islands automatically notify overlapping water bodies when they change:
void UpdateOverlappingOceanologyWaterComponents();
This ensures the water mesh updates in real-time as you edit island shapes.
Exclusion Volumesโ
Exclusion volumes remove water from specific areas without modifying terrain.
Use Casesโ
- Swimming pools with no water on deck
- Underwater caves and tunnels
- Dock areas with no water underneath
- Interior spaces that overlap water zones
Exclusion Modesโ
enum class EOceanologyWaterExclusionMode
{
// Only exclude water bodies in the WaterBodies list
// If list is empty, no exclusion
AddWaterBodiesListToExclusion,
// Exclude all EXCEPT water bodies in the list
// If list is empty, exclude all overlapping
RemoveWaterBodiesListFromExclusion,
};
Exclusion Volume Propertiesโ
| Property | Description |
|---|---|
ExclusionMode | How to interpret the water bodies list |
WaterBodies | List of specific water bodies to include/exclude |
Setting Up Exclusionโ
- Add a Oceanology Water Exclusion Volume actor
- Scale the volume to cover the exclusion area
- Choose the exclusion mode
- Optionally specify which water bodies to affect
Exclusion in Queriesโ
Water body queries respect exclusion volumes:
// Query flag to ignore exclusion volumes
EOceanologyWaterBodyQueryFlags::IgnoreExclusionVolumes
// Result indicates if point is in exclusion zone
FOceanologyWaterBodyQueryResult::bIsInExclusionVolume
Brush Effectsโ
Water bodies can apply sophisticated effects to the landscape through brush settings.
Blurring Effectโ
Softens terrain transitions around water:
struct FOceanologyWaterBrushEffectBlurring
{
bool bBlurShape = true; // Enable blur
int32 Radius = 2; // Blur kernel radius
};
Curl Noise Effectโ
Adds organic variation to water edges:
struct FOceanologyWaterBrushEffectCurlNoise
{
float Curl1Amount = 0; // Primary noise strength
float Curl2Amount = 0; // Secondary noise strength
float Curl1Tiling = 16.0; // Primary noise scale
float Curl2Tiling = 3.0; // Secondary noise scale
};
Curve Channel Effectโ
Uses curves to shape terrain along water bodies:
struct FOceanologyWaterBrushEffectCurves
{
bool bUseCurveChannel = true;
UCurveFloat* ElevationCurveAsset; // Custom elevation curve
float ChannelEdgeOffset = 0.0;
float ChannelDepth = 0.0;
float CurveRampWidth = 512.0;
};
Displacement Effectโ
Applies texture-based displacement:
struct FOceanologyWaterBrushEffectDisplacement
{
float DisplacementHeight = 0;
float DisplacementTiling = 0;
UTexture2D* Texture; // Displacement map
float Midpoint = -128.0; // Neutral height
FLinearColor Channel; // Which channel to read
float WeightmapInfluence = 0; // Affect weightmaps too
};
Smooth Blending Effectโ
Controls edge smoothing:
struct FOceanologyWaterBrushEffectSmoothBlending
{
float InnerSmoothDistance = 0.01;
float OuterSmoothDistance = 0.01;
};
Terracing Effectโ
Creates stepped terrain (great for rice paddies, etc.):
struct FOceanologyWaterBrushEffectTerracing
{
float TerraceAlpha = 0.0; // Terrace strength
float TerraceSpacing = 256.0; // Height between terraces
float TerraceSmoothness = 0.0; // Edge softness
float MaskLength = 0.0; // Fade distance
float MaskStartOffset = 0.0; // Fade start
};
Falloff Settingsโ
Water bodies use falloff to blend with surrounding terrain.
Falloff Modesโ
enum class EOceanologyWaterBrushFalloffMode : uint8
{
Angle, // Falloff based on slope angle
Width, // Falloff based on distance
};
Falloff Propertiesโ
| Property | Mode | Description |
|---|---|---|
FalloffAngle | Angle | Slope angle for falloff |
FalloffWidth | Width | Distance for falloff (min 0.1) |
EdgeOffset | Both | Offset from water edge |
ZOffset | Both | Vertical offset |
Heightmap Settingsโ
Control how water bodies modify terrain elevation:
struct FOceanologyWaterBodyHeightmapSettings
{
// Blend mode for heightmap modification
EWaterBrushBlendType BlendMode;
// Whether to invert the effect
bool bInvertShape;
// Effect priority when multiple bodies overlap
int32 Priority;
// Additional brush effects
FOceanologyWaterBrushEffects Effects;
// Falloff configuration
FOceanologyWaterFalloffSettings FalloffSettings;
};
Weightmap Settingsโ
Control landscape layer painting:
struct FOceanologyWaterBodyWeightmapSettings
{
// Target landscape layer
FName LayerName;
// Paint strength (0-1)
float ModulationStrength;
// Whether to paint this layer
bool bAffectWeightmap;
// Falloff for layer painting
FOceanologyWaterFalloffSettings FalloffSettings;
};
Per-Layer Configurationโ
Each water body can affect multiple landscape layers:
// In water component
TMap<FName, FOceanologyWaterBodyWeightmapSettings> LayerWeightmapSettings;
Common setups:
- Beach layer: Sand around ocean edges
- Riverbed layer: Mud/gravel along rivers
- Wetland layer: Marsh terrain around lakes
Water Terrain Componentโ
The UOceanologyWaterTerrainComponent manages landscape modification:
Featuresโ
- Automatic terrain carving
- Runtime terrain updates
- Landscape edit layer support
- Brush cache management
Integration with World Partitionโ
NextGen 2.0's terrain system works with World Partition:
// Water Subsystem tracks terrain actors
TMultiMap<AActor*, UOceanologyWaterTerrainComponent> WaterTerrainActors;
Jump Flood SDF for Terrainโ
The Jump Flood algorithm generates signed distance fields used for terrain modification.
How It Worksโ
- Edge Detection: Find water body boundaries
- Jump Flood Propagation: O(log n) distance computation
- Blur Pass: Smooth the distance field
- Gradient Calculation: Compute direction to nearest edge
SDF in Terrain Modificationโ
// From OceanologyComputeSDFandGradient.ush
float3 ComputeSDFandGradient(
Texture2D TexJumpFlood,
float2 UVs,
int WaterZoneIndex,
out float2 OutGradient,
out float OutGradientX,
out float OutGradientY,
out float OutSDF
);
The SDF enables:
- Smooth falloff from water edges
- Consistent terrain blending
- Breaking wave shore detection
- Foam distribution
Editor Workflowโ
Setting Up Terrain Integrationโ
- Enable landscape affecting on water bodies that should modify terrain
- Configure heightmap settings for each water body type
- Set up weightmap layers for landscape materials
- Adjust brush effects for desired terrain look
- Place islands to create landmasses
Best Practicesโ
- Use consistent falloff: Keep falloff settings similar across water bodies
- Layer priorities: Set priorities to handle overlapping bodies
- Test incrementally: Apply brush changes in small batches
- Backup landscapes: Terrain changes are destructive
- Use edit layers: Unreal 5.1+ edit layers allow non-destructive editing