Skip to content

Commit

Permalink
Add VoxelTerrain samples
Browse files Browse the repository at this point in the history
  • Loading branch information
acs committed Oct 1, 2020
1 parent 8521ddd commit 1a84360
Show file tree
Hide file tree
Showing 11 changed files with 324 additions and 1 deletion.
62 changes: 62 additions & 0 deletions VoxelTerrain/BasicTerrain.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
[gd_scene load_steps=9 format=2]

[sub_resource type="VoxelGeneratorFlat" id=1]

[sub_resource type="Voxel" id=2]
voxel_name = "air"
transparent = true

[sub_resource type="Voxel" id=3]
voxel_name = "solid"
geometry_type = 1
collision_aabbs = [ AABB( 0, 0, 0, 1, 1, 1 ) ]
cube_geometry/padding_y = null
cube_tiles/left = Vector2( 0, 0 )
cube_tiles/right = Vector2( 0, 0 )
cube_tiles/bottom = Vector2( 0, 0 )
cube_tiles/top = Vector2( 0, 0 )
cube_tiles/back = Vector2( 0, 0 )
cube_tiles/front = Vector2( 0, 0 )

[sub_resource type="VoxelLibrary" id=4]
voxels/0 = SubResource( 2 )
voxels/1 = SubResource( 3 )

[sub_resource type="SpatialMaterial" id=5]
albedo_color = Color( 0.32549, 0.788235, 0.180392, 1 )

[sub_resource type="PhysicsMaterial" id=8]
bounce = 1.0

[sub_resource type="SphereMesh" id=6]
radius = 5.0
height = 10.0

[sub_resource type="SphereShape" id=7]
radius = 5.0

[node name="BasicTerrain" type="Spatial"]

[node name="VoxelTerrain" type="VoxelTerrain" parent="."]
stream = SubResource( 1 )
voxel_library = SubResource( 4 )
max_view_distance = 48
material/0 = SubResource( 5 )

[node name="Camera" type="Camera" parent="."]
transform = Transform( 1, 0, 0, 0, 0.866025, 0.5, 0, -0.5, 0.866025, 0, 20, 30 )

[node name="RigidBody" type="RigidBody" parent="."]
physics_material_override = SubResource( 8 )

[node name="MeshInstance" type="MeshInstance" parent="RigidBody"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 20, 0 )
mesh = SubResource( 6 )
material/0 = null

[node name="CollisionShape" type="CollisionShape" parent="RigidBody"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 20, 0 )
shape = SubResource( 7 )

[node name="VoxelViewer" type="VoxelViewer" parent="."]
requires_collisions = true
37 changes: 37 additions & 0 deletions VoxelTerrain/NoiseImageTerrain.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
[gd_scene load_steps=6 format=2]

[ext_resource path="res://noise_distorted.png" type="Image" id=1]

[sub_resource type="VoxelGeneratorImage" id=1]
image = ExtResource( 1 )

[sub_resource type="Voxel" id=2]
voxel_name = "air"
transparent = true

[sub_resource type="Voxel" id=3]
voxel_name = "solid"
geometry_type = 1
collision_aabbs = [ AABB( 0, 0, 0, 1, 1, 1 ) ]
cube_geometry/padding_y = null
cube_tiles/left = Vector2( 0, 0 )
cube_tiles/right = Vector2( 0, 0 )
cube_tiles/bottom = Vector2( 0, 0 )
cube_tiles/top = Vector2( 0, 0 )
cube_tiles/back = Vector2( 0, 0 )
cube_tiles/front = Vector2( 0, 0 )

[sub_resource type="VoxelLibrary" id=4]
voxels/0 = SubResource( 2 )
voxels/1 = SubResource( 3 )

[node name="NoiseImageTerrain" type="Spatial"]

[node name="VoxelTerrain" type="VoxelTerrain" parent="."]
stream = SubResource( 1 )
voxel_library = SubResource( 4 )

[node name="Camera" type="Camera" parent="."]
transform = Transform( 1, 0, 0, 0, 0.906308, 0.422618, 0, -0.422618, 0.906308, 0, 75, 0 )

[node name="VoxelViewer" type="VoxelViewer" parent="."]
84 changes: 84 additions & 0 deletions VoxelTerrain/NoiseTerrain.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
[gd_scene load_steps=13 format=2]

[sub_resource type="OpenSimplexNoise" id=5]

[sub_resource type="VoxelGeneratorNoise" id=6]
noise = SubResource( 5 )
height_start = -50.0
height_range = 100.0

[sub_resource type="Voxel" id=2]
voxel_name = "air"
transparent = true

[sub_resource type="Voxel" id=3]
voxel_name = "solid"
geometry_type = 1
collision_aabbs = [ AABB( 0, 0, 0, 1, 1, 1 ) ]
cube_geometry/padding_y = null
cube_tiles/left = Vector2( 0, 0 )
cube_tiles/right = Vector2( 0, 0 )
cube_tiles/bottom = Vector2( 0, 0 )
cube_tiles/top = Vector2( 0, 0 )
cube_tiles/back = Vector2( 0, 0 )
cube_tiles/front = Vector2( 0, 0 )

[sub_resource type="VoxelLibrary" id=4]
voxels/0 = SubResource( 2 )
voxels/1 = SubResource( 3 )

[sub_resource type="SpatialMaterial" id=7]
albedo_color = Color( 0.552941, 0.345098, 0.345098, 1 )
roughness = 0.3

[sub_resource type="VoxelGeneratorFlat" id=8]

[sub_resource type="Voxel" id=9]
voxel_name = "air"
transparent = true

[sub_resource type="Voxel" id=10]
voxel_name = "solid"
geometry_type = 1
collision_aabbs = [ AABB( 0, 0, 0, 1, 1, 1 ) ]
cube_geometry/padding_y = null
cube_tiles/left = Vector2( 0, 0 )
cube_tiles/right = Vector2( 0, 0 )
cube_tiles/bottom = Vector2( 0, 0 )
cube_tiles/top = Vector2( 0, 0 )
cube_tiles/back = Vector2( 0, 0 )
cube_tiles/front = Vector2( 0, 0 )

[sub_resource type="VoxelLibrary" id=11]
voxels/0 = SubResource( 9 )
voxels/1 = SubResource( 10 )

[sub_resource type="SphereMesh" id=12]

[sub_resource type="SpatialMaterial" id=13]
albedo_color = Color( 0.933333, 0, 0, 1 )

[node name="NoiseTerrain" type="Spatial"]

[node name="Mountains" type="VoxelTerrain" parent="."]
stream = SubResource( 6 )
voxel_library = SubResource( 4 )
material/0 = SubResource( 7 )

[node name="Water" type="VoxelTerrain" parent="."]
stream = SubResource( 8 )
voxel_library = SubResource( 11 )

[node name="Camera" type="Camera" parent="."]
transform = Transform( 0.292705, 0.478101, -0.828096, 0, 0.866025, 0.5, 0.956203, -0.146353, 0.25349, 0, 15, 0 )

[node name="VoxelViewer" type="VoxelViewer" parent="."]

[node name="MeshInstance" type="MeshInstance" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 9.03833, 2.92618, -5.56389 )
mesh = SubResource( 12 )
material/0 = SubResource( 13 )

[node name="OmniLight" type="OmniLight" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 9.11286, 2.23073, -5.56389 )
light_energy = 10.0
63 changes: 63 additions & 0 deletions VoxelTerrain/SecondTerrain.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
[gd_scene load_steps=9 format=2]

[sub_resource type="VoxelGeneratorWaves" id=1]
height_start = -25.0

[sub_resource type="Voxel" id=2]
voxel_name = "air"
transparent = true

[sub_resource type="Voxel" id=3]
voxel_name = "solid"
geometry_type = 1
collision_aabbs = [ AABB( 0, 0, 0, 1, 1, 1 ) ]
cube_geometry/padding_y = null
cube_tiles/left = Vector2( 0, 0 )
cube_tiles/right = Vector2( 0, 0 )
cube_tiles/bottom = Vector2( 0, 0 )
cube_tiles/top = Vector2( 0, 0 )
cube_tiles/back = Vector2( 0, 0 )
cube_tiles/front = Vector2( 0, 0 )

[sub_resource type="VoxelLibrary" id=4]
voxels/0 = SubResource( 2 )
voxels/1 = SubResource( 3 )

[sub_resource type="SpatialMaterial" id=5]
albedo_color = Color( 0.32549, 0.788235, 0.180392, 1 )

[sub_resource type="PhysicsMaterial" id=8]
bounce = 1.0

[sub_resource type="SphereMesh" id=6]
radius = 5.0
height = 10.0

[sub_resource type="SphereShape" id=7]
radius = 5.0

[node name="BasicTerrain" type="Spatial"]

[node name="VoxelTerrain" type="VoxelTerrain" parent="."]
stream = SubResource( 1 )
voxel_library = SubResource( 4 )
max_view_distance = 96
material/0 = SubResource( 5 )

[node name="Camera" type="Camera" parent="."]
transform = Transform( 1, 0, 0, 0, 0.866025, 0.5, 0, -0.5, 0.866025, 0, 8, 13 )

[node name="RigidBody" type="RigidBody" parent="."]
physics_material_override = SubResource( 8 )

[node name="MeshInstance" type="MeshInstance" parent="RigidBody"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 20, 0 )
mesh = SubResource( 6 )
material/0 = null

[node name="CollisionShape" type="CollisionShape" parent="RigidBody"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 20, 0 )
shape = SubResource( 7 )

[node name="VoxelViewer" type="VoxelViewer" parent="."]
requires_collisions = true
7 changes: 7 additions & 0 deletions VoxelTerrain/default_env.tres
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[gd_resource type="Environment" load_steps=2 format=2]

[sub_resource type="ProceduralSky" id=1]

[resource]
background_mode = 2
background_sky = SubResource( 1 )
Binary file added VoxelTerrain/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 34 additions & 0 deletions VoxelTerrain/icon.png.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[remap]

importer="texture"
type="StreamTexture"
path="res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://icon.png"
dest_files=[ "res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex" ]

[params]

compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0
Binary file added VoxelTerrain/noise_distorted.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions VoxelTerrain/noise_distorted.png.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[remap]

importer="image"
type="Image"
path="res://.import/noise_distorted.png-a3823ac1452b83d7bf69c4608544df15.image"

[deps]

source_file="res://noise_distorted.png"
dest_files=[ "res://.import/noise_distorted.png-a3823ac1452b83d7bf69c4608544df15.image" ]

[params]

24 changes: 24 additions & 0 deletions VoxelTerrain/project.godot
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
; Engine configuration file.
; It's best edited using the editor UI and not directly,
; since the parameters that go here are not all obvious.
;
; Format:
; [section] ; section goes between []
; param=value ; assign values to parameters

config_version=4

_global_script_classes=[ ]
_global_script_class_icons={

}

[application]

config/name="VoxelTerrain"
run/main_scene="res://BasicTerrain.tscn"
config/icon="res://icon.png"

[rendering]

environment/default_environment="res://default_env.tres"
1 change: 0 additions & 1 deletion voxel_tools/VoxelTerrain.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,3 @@ transform = Transform( 1, 0, 0, 0, 0.906308, 0.422618, 0, -0.422618, 0.906308, 0
[node name="VoxelTerrain" type="VoxelTerrain" parent="."]
stream = SubResource( 1 )
voxel_library = SubResource( 4 )
viewer_path = NodePath("../Camera")

0 comments on commit 1a84360

Please sign in to comment.