diff --git a/terrain/terrain_instance_3d.gd b/terrain/terrain_instance_3d.gd index f844714..62c65fa 100644 --- a/terrain/terrain_instance_3d.gd +++ b/terrain/terrain_instance_3d.gd @@ -15,13 +15,13 @@ enum PaintSlot { PAINT_3, } -var _albedo_maps: Array[Texture2D] = [null, null, null, null] +var _albedo_maps: Array[Texture2D] = [] var _material := ShaderMaterial.new() var _mesh := PlaneMesh.new() -var _normal_maps: Array[Texture2D] = [null, null, null, null] +var _normal_maps: Array[Texture2D] = [] ## ## Range of the height channel value, ranging from [code]0.0[/code] to [code]100.0[/code]. @@ -54,6 +54,11 @@ var size := Vector2i.ONE: size = value func _init() -> void: + var paint_channels := PaintSlot.values().size() + + _albedo_maps.resize(paint_channels) + _normal_maps.resize(paint_channels) + _material.shader = _SHADER _mesh.surface_set_material(0, _material)