package terrain
Constants
AssetVersion
2
HeightEncodingUint16
HeightEncoding
"uint16-normalized"
WeightEncodingUint16
WeightEncoding
"uint16-normalized"
Types
AutoMaterialRule
struct
type AutoMaterialRule struct {
Name string
Layer int
TargetWeight matrix.Float
Constraints TexturePaintConstraints
NoiseStrength matrix.Float
NoiseScale matrix.Float
NoiseSeed int
}
TerrainAutoMaterialRules
BrushFalloff
const ( FalloffLinear BrushFalloff = iota FalloffSmooth FalloffConstant )
BrushMode
const ( BrushRaise BrushMode = iota BrushLower BrushSmooth )
DirtyRegion
struct
DirtyRegion.Expand
DirtyRegion.Intersects
HeightEncoding
HeightField
struct
type HeightField struct {
Resolution int
Heights []matrix.Float
MinHeight matrix.Float
MaxHeight matrix.Float
// Has unexported fields.
}
NewHeightField
func NewHeightField(resolution int, minHeight, maxHeight, initialHeight matrix.Float) (*HeightField, error)
HeightField.AddHeight
HeightField.ClearDirty
HeightField.CopyRegion
HeightField.DirtyRegion
HeightField.Height
HeightField.Paint
HeightField.Sample
HeightField.SetHeight
HeightField.SetRegion
PaintStroke
struct
type PaintStroke struct {
Mode BrushMode
Center matrix.Vec2
Radius matrix.Float
Strength matrix.Float
Falloff BrushFalloff
Spacing matrix.Float
}
SplatLayerChannel
struct
Terrain
struct
type Terrain struct {
Config TerrainConfig
Entity *engine.Entity
Transform *matrix.Transform
HeightField *HeightField
LayerSet *TerrainLayerSet
SplatTextures []TerrainSplatTexture
MeshChunks []TerrainChunk
Material *rendering.Material
ShaderData []rendering.DrawInstance
// Has unexported fields.
}
Load
LoadForEntity
New
NewFromAsset
NewFromAssetForEntity
func NewFromAssetForEntity(host *engine.Host, asset TerrainAsset, entity *engine.Entity) (*Terrain, error)
NewModel
NewModelFromAsset
Terrain.AddLayer
Terrain.ApplyAutoMaterialRules
Terrain.ApplyDirty
Terrain.ApplyHeightRegion
Terrain.ApplyLayerSetState
Terrain.ApplyTextureDirty
Terrain.ApplyTextureWeightRegion
Terrain.ClearBrushPreview
Terrain.ClearLayer
Terrain.Collision
Terrain.CollisionBounds
CollisionBounds returns the local-space bounds used by terrain collision.
Terrain.CopyTextureWeightRegion
Terrain.Destroy
Terrain.EraseLayer
Terrain.FillLayer
Terrain.HeightAtLocal
Terrain.HeightAtWorld
Terrain.LayerCount
Terrain.LayerSetState
Terrain.LayerWeightAt
Terrain.MarkTextureDirty
Terrain.MarkTextureRegionDirty
Terrain.MoveLayer
Terrain.NewCollision
NewCollision creates a Graviton terrain collider backed by the terrain height storage. Height edits are visible to the collider immediately; do not mutate terrain heights concurrently with a physics step.
Terrain.NormalizeWeightsAt
Terrain.Paint
Terrain.PaintLayer
Terrain.PaintLine
Terrain.PaintTextureLayer
Terrain.PaintTextureLine
func (t *Terrain) PaintTextureLine(layer int, from, to matrix.Vec2, stroke TexturePaintStroke) TexturePaintResult
Terrain.RayHit
Terrain.RayHitLocal
Terrain.RefreshTexturePreview
Terrain.RemoveLayer
Terrain.SampleLayerWeightAtLocal
Terrain.SampleTextureLayerAtLocal
Terrain.SetBrushPreview
func (t *Terrain) SetBrushPreview(centerXZ matrix.Vec2, radius, ringWidth matrix.Float, color matrix.Color)
Terrain.SetLayer
Terrain.SplatLayerChannel
Terrain.SplatTextureCount
Terrain.SplatTextureWriteRequest
func (t *Terrain) SplatTextureWriteRequest(texture int, region DirtyRegion) rendering.GPUImageWriteRequest
Terrain.StrokeRegion
Terrain.TextureStrokeRegion
Terrain.VisitPaintLineStamps
func (t *Terrain) VisitPaintLineStamps(from, to matrix.Vec2, stroke PaintStroke, visit func(PaintStroke) bool)
Terrain.VisitTexturePaintLineStamps
func (t *Terrain) VisitTexturePaintLineStamps(from, to matrix.Vec2, stroke TexturePaintStroke, visit func(TexturePaintStroke) bool)
Terrain.WeightDebugRGBA
TerrainAsset
struct
type TerrainAsset struct {
Version int
Config TerrainConfig
Heights []uint16
Layers []TerrainLayer
WeightMapResolution int
Weights []uint16
}
DeserializeAsset
LoadAsset
NewAsset
NewAssetFromHeightField
NewAssetFromTerrain
NewAssetWithLayerSet
func NewAssetWithLayerSet(config TerrainConfig, heights []matrix.Float, layerSet *TerrainLayerSet) (TerrainAsset, error)
TerrainAsset.FloatHeights
TerrainAsset.Height
TerrainAsset.LayerSet
TerrainAsset.Serialize
TerrainAutoMaterialPreset
struct
type TerrainAutoMaterialPreset struct {
GrassLayer int
RockLayer int
SnowLayer int
FlatSlopeMax matrix.Float
CliffSlopeMin matrix.Float
SnowHeightMin matrix.Float
NoiseStrength matrix.Float
NoiseScale matrix.Float
NoiseSeed int
}
TerrainChunk
struct
type TerrainChunk struct {
Key string
StartX int
StartZ int
EndX int
EndZ int
Mesh *rendering.Mesh
Drawing rendering.Drawing
ShaderData rendering.DrawInstance
Indexes []uint32
}
TerrainConfig
struct
type TerrainConfig struct {
Resolution int
PaintResolution int
WorldSize matrix.Vec2
MinHeight matrix.Float
MaxHeight matrix.Float
InitialHeight matrix.Float
ChunkSize int
Material string
Textures []TerrainTexture
ShaderData string
}
TerrainLayer
struct
type TerrainLayer struct {
Name string
TextureContentID string
NormalContentID string
RoughnessContentID string
Filter rendering.TextureFilter
Tiling matrix.Vec2
Offset matrix.Vec2
Rotation matrix.Float
Tint matrix.Color
TextureWorldSize matrix.Vec2
Locked bool
Hidden bool
Solo bool
TriplanarCliffs bool
TriplanarSlope matrix.Float
}
TerrainLayer describes one paintable material layer on a terrain.
TextureContentID is the albedo texture currently consumed by the terrain material. NormalContentID and RoughnessContentID are stored for authoring and future material expansion. Locked layers preserve their current contribution during painting, while Hidden and Solo only affect preview packing.
NewTerrainLayer
TerrainLayerSet
struct
type TerrainLayerSet struct {
Layers []TerrainLayer
WeightMap *TextureWeightMap
// Has unexported fields.
}
TerrainLayerSet owns the ordered TerrainLayer list and the normalized weight map with matching layer indexes.
Mutate layers through this type when possible. Add, remove, move, fill, clear, and paint operations keep the TextureWeightMap shape aligned with Layers and preserve per-texel normalization.
NewTerrainLayerSet
TerrainLayerSet.AddLayer
TerrainLayerSet.ClearLayer
TerrainLayerSet.EffectiveWeightMapForPreview
TerrainLayerSet.EraseLayer
TerrainLayerSet.FillLayer
TerrainLayerSet.LayerCount
TerrainLayerSet.LayerWeightAt
TerrainLayerSet.MoveLayer
TerrainLayerSet.NormalizeWeightsAt
TerrainLayerSet.PaintLayer
TerrainLayerSet.PaintTextureLayer
func (s *TerrainLayerSet) PaintTextureLayer(layer int, stroke TexturePaintStroke) TexturePaintResult
TerrainLayerSet.RemoveLayer
TerrainLayerSet.SetLayer
TerrainLayerSet.SetLayerWeightAt
TerrainLayerSet.WeightDebugRGBA
TerrainLayerSetState
struct
type TerrainLayerSetState struct {
Layers []TerrainLayer
WeightMapResolution int
Weights []matrix.Float
}
TerrainLayerTextureDiagnostic
struct
MissingTerrainLayerTextures
func MissingTerrainLayerTextures(layers []TerrainLayer, textureExists func(string) bool) []TerrainLayerTextureDiagnostic
TerrainRayHit
struct
type TerrainRayHit struct {
Point matrix.Vec3
LocalPoint matrix.Vec3
Normal matrix.Vec3
Distance matrix.Float
}
TerrainShaderData
shader_data_registry.ShaderDataTerrain
TerrainSplatTexture
struct
type TerrainSplatTexture struct {
Key string
Texture *rendering.Texture
LayerStart int
LayerCount int
Pixels []byte
Dirty DirtyRegion
// Has unexported fields.
}
TerrainTexture
struct
TextureBrushMode
const ( TextureBrushPaint TextureBrushMode = iota TextureBrushErase TextureBrushSmoothWeights TextureBrushFill TextureBrushReplace TextureBrushSample )
TextureBrushStamp
struct
TextureBrushStamp.Sample
TexturePaintConstraints
struct
type TexturePaintConstraints struct {
UseSlope bool
SlopeMin matrix.Float
SlopeMax matrix.Float
UseHeight bool
HeightMin matrix.Float
HeightMax matrix.Float
AngleCutoff matrix.Float
NormalFacing matrix.Vec3
}
TexturePaintResult
struct
type TexturePaintResult struct {
Dirty DirtyRegion
Sampled bool
SampledLayer int
SampledWeight matrix.Float
}
TexturePaintStroke
struct
type TexturePaintStroke struct {
Mode TextureBrushMode
Center matrix.Vec2
Radius matrix.Float
Strength matrix.Float
Falloff BrushFalloff
Opacity matrix.Float
TargetWeight matrix.Float
Spacing matrix.Float
ReplaceLayer int
PreserveOtherLayers bool
Constraints TexturePaintConstraints
NoiseStrength matrix.Float
NoiseScale matrix.Float
NoiseSeed int
Jitter matrix.Float
Stamp *TextureBrushStamp
StampScale matrix.Float
StampRotation matrix.Float
}
TextureWeightMap
struct
type TextureWeightMap struct {
Resolution int
Layers int
Weights []matrix.Float
// Has unexported fields.
}
TextureWeightMap stores terrain texture blend weights in cell-major order.
The backing layout is ((x + z*Resolution) * Layers) + layer. Every texel is expected to normalize across all layers. Use SetWeightAt followed by NormalizeWeightsAt for direct edits, or prefer PaintTextureLayer for editor brush behavior with falloff, locks, smoothing, replace, sampling, and fill modes.
NewTextureWeightMap
TextureWeightMap.AddLayer
TextureWeightMap.ClearLayer
TextureWeightMap.ClearLayerWithLocks
TextureWeightMap.CopyRegion
TextureWeightMap.EraseLayer
TextureWeightMap.FillLayer
TextureWeightMap.FillLayerWithLocks
TextureWeightMap.MoveLayer
TextureWeightMap.NormalizeAll
TextureWeightMap.NormalizeWeightsAt
TextureWeightMap.PaintLayer
TextureWeightMap.PaintTextureLayer
func (m *TextureWeightMap) PaintTextureLayer(layer int, stroke TexturePaintStroke) TexturePaintResult
TextureWeightMap.PaintTextureLayerWithLocks
func (m *TextureWeightMap) PaintTextureLayerWithLocks(layer int, stroke TexturePaintStroke, locked []bool) TexturePaintResult