Merge pull request #694 from aaronfranke/gd4-voxel

Update Voxel demo to Godot 4
This commit is contained in:
Aaron Franke
2022-03-27 18:25:43 -05:00
committed by GitHub
25 changed files with 438 additions and 421 deletions

View File

@@ -1,8 +1,8 @@
[gd_resource type="AudioBusLayout" load_steps=2 format=2]
[gd_resource type="AudioBusLayout" load_steps=2 format=3 uid="uid://bnigwafdluiy2"]
[sub_resource type="AudioEffectPitchShift" id=1]
[sub_resource type="AudioEffectPitchShift" id="1"]
resource_name = "PitchShift"
[resource]
bus/0/effect/0/effect = SubResource( 1 )
bus/0/effect/0/effect = SubResource( "1" )
bus/0/effect/0/enabled = true

View File

@@ -1,18 +1,16 @@
[gd_resource type="Environment" load_steps=2 format=2]
[gd_resource type="Environment" load_steps=3 format=3 uid="uid://brymefbrev3s"]
[sub_resource type="Sky" id=1]
sun_longitude = 100.0
sun_angle_min = 2.0
sun_angle_max = 20.0
[sub_resource type="ProceduralSkyMaterial" id="ProceduralSkyMaterial_rhfg5"]
sky_horizon_color = Color(0.64625, 0.65575, 0.67075, 1)
ground_horizon_color = Color(0.64625, 0.65575, 0.67075, 1)
[sub_resource type="Sky" id="Sky_iri27"]
sky_material = SubResource( "ProceduralSkyMaterial_rhfg5" )
[resource]
background_mode = 2
background_sky = SubResource( 1 )
sky = SubResource( "Sky_iri27" )
tonemap_mode = 2
glow_enabled = true
fog_enabled = true
fog_color = Color( 0.501961, 0.6, 0.701961, 1 )
fog_depth_begin = 32.0
fog_depth_end = 64.0
fog_transmit_enabled = true
dof_blur_far_enabled = true
dof_blur_far_transition = 32.0
dof_blur_far_amount = 0.05
fog_aerial_perspective = 0.5

View File

@@ -1,8 +1,9 @@
[remap]
importer="texture"
type="StreamTexture2D"
path="res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.stex"
type="CompressedTexture2D"
uid="uid://cpmihwb2gtevf"
path="res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.ctex"
metadata={
"vram_texture": false
}
@@ -10,26 +11,23 @@ metadata={
[deps]
source_file="res://icon.png"
dest_files=["res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.stex"]
dest_files=["res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.ctex"]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/hdr_compression=1
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
process/normal_map_invert_y=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0
process/hdr_as_srgb=false
process/size_limit=0
detect_3d/compress_to=1

View File

@@ -1,8 +1,9 @@
[remap]
importer="texture"
type="StreamTexture2D"
path="res://.godot/imported/button.png-e6ddd405c0968c9fb68dca7b600a69a3.stex"
type="CompressedTexture2D"
uid="uid://ej6lqf2fptv8"
path="res://.godot/imported/button.png-e6ddd405c0968c9fb68dca7b600a69a3.ctex"
metadata={
"vram_texture": false
}
@@ -10,26 +11,23 @@ metadata={
[deps]
source_file="res://menu/button.png"
dest_files=["res://.godot/imported/button.png-e6ddd405c0968c9fb68dca7b600a69a3.stex"]
dest_files=["res://.godot/imported/button.png-e6ddd405c0968c9fb68dca7b600a69a3.ctex"]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/hdr_compression=1
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
process/normal_map_invert_y=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0
process/hdr_as_srgb=false
process/size_limit=0
detect_3d/compress_to=1

View File

@@ -1,132 +1,120 @@
[gd_scene load_steps=6 format=2]
[gd_scene load_steps=6 format=3 uid="uid://dk8arl1if3lyr"]
[ext_resource path="res://player/crosshair.svg" type="Texture2D" id=1]
[ext_resource path="res://menu/theme/theme.tres" type="Theme" id=2]
[ext_resource path="res://menu/options/options.tscn" type="PackedScene" id=3]
[ext_resource path="res://menu/ingame/pause_menu.gd" type="Script" id=4]
[ext_resource path="res://menu/button.png" type="Texture2D" id=5]
[ext_resource type="Texture2D" uid="uid://cgv7xgoy43rbc" path="res://player/crosshair.svg" id="1"]
[ext_resource type="Theme" path="res://menu/theme/theme.tres" id="2"]
[ext_resource type="PackedScene" uid="uid://e22n700qhxqr" path="res://menu/options/options.tscn" id="3"]
[ext_resource type="Script" path="res://menu/ingame/pause_menu.gd" id="4"]
[ext_resource type="Texture2D" uid="uid://ej6lqf2fptv8" path="res://menu/button.png" id="5"]
[node name="PauseMenu" type="Control"]
anchor_right = 1.0
anchor_bottom = 1.0
theme = ExtResource( 2 )
script = ExtResource( 4 )
__meta__ = {
"_edit_use_anchors_": false
}
theme = ExtResource( "2" )
script = ExtResource( "4" )
[node name="Crosshair" type="CenterContainer" parent="."]
anchor_right = 1.0
anchor_bottom = 1.0
__meta__ = {
"_edit_use_anchors_": false
}
[node name="TextureRect" type="TextureRect" parent="Crosshair"]
offset_left = 784.0
offset_top = 434.0
offset_right = 816.0
offset_bottom = 466.0
texture = ExtResource( 1 )
offset_left = 496.0
offset_top = 284.0
offset_right = 528.0
offset_bottom = 316.0
texture = ExtResource( "1" )
[node name="Pause" type="VBoxContainer" parent="."]
visible = false
anchor_right = 1.0
anchor_bottom = 1.0
__meta__ = {
"_edit_use_anchors_": false
}
[node name="ButtonHolder" type="HBoxContainer" parent="Pause"]
offset_right = 1600.0
offset_bottom = 900.0
offset_right = 1024.0
offset_bottom = 600.0
size_flags_vertical = 3
alignment = 1
[node name="MainButtons" type="VBoxContainer" parent="Pause/ButtonHolder"]
offset_left = 608.0
offset_right = 992.0
offset_bottom = 900.0
custom_constants/separation = 20
offset_left = 320.0
offset_right = 704.0
offset_bottom = 600.0
theme_override_constants/separation = 20
alignment = 1
[node name="Resume" type="TextureButton" parent="Pause/ButtonHolder/MainButtons"]
offset_top = 292.0
offset_top = 142.0
offset_right = 384.0
offset_bottom = 356.0
rect_min_size = Vector2(384, 64)
texture_normal = ExtResource( 5 )
offset_bottom = 206.0
texture_normal = ExtResource( "5" )
[node name="Label" type="Label" parent="Pause/ButtonHolder/MainButtons/Resume"]
anchor_right = 1.0
anchor_bottom = 1.0
offset_top = -1.0
offset_bottom = -18.0
theme_override_font_sizes/font_size = 60
text = "Resume Game"
align = 1
valign = 1
__meta__ = {
"_edit_use_anchors_": false
}
horizontal_alignment = 1
vertical_alignment = 1
[node name="Options" type="TextureButton" parent="Pause/ButtonHolder/MainButtons"]
offset_top = 376.0
offset_top = 226.0
offset_right = 384.0
offset_bottom = 440.0
rect_min_size = Vector2(384, 64)
texture_normal = ExtResource( 5 )
offset_bottom = 290.0
texture_normal = ExtResource( "5" )
[node name="Label" type="Label" parent="Pause/ButtonHolder/MainButtons/Options"]
anchor_right = 1.0
anchor_bottom = 1.0
offset_top = -1.0
offset_bottom = -18.0
theme_override_font_sizes/font_size = 60
text = "Options"
align = 1
valign = 1
horizontal_alignment = 1
vertical_alignment = 1
__meta__ = {
"_edit_use_anchors_": false
}
[node name="MainMenu" type="TextureButton" parent="Pause/ButtonHolder/MainButtons"]
offset_top = 460.0
offset_top = 310.0
offset_right = 384.0
offset_bottom = 524.0
rect_min_size = Vector2(384, 64)
texture_normal = ExtResource( 5 )
offset_bottom = 374.0
texture_normal = ExtResource( "5" )
[node name="Label" type="Label" parent="Pause/ButtonHolder/MainButtons/MainMenu"]
anchor_right = 1.0
anchor_bottom = 1.0
offset_top = -1.0
offset_bottom = -18.0
theme_override_font_sizes/font_size = 60
text = "Main Menu"
align = 1
valign = 1
horizontal_alignment = 1
vertical_alignment = 1
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Exit" type="TextureButton" parent="Pause/ButtonHolder/MainButtons"]
offset_top = 544.0
offset_top = 394.0
offset_right = 384.0
offset_bottom = 608.0
rect_min_size = Vector2(384, 64)
texture_normal = ExtResource( 5 )
offset_bottom = 458.0
texture_normal = ExtResource( "5" )
[node name="Label" type="Label" parent="Pause/ButtonHolder/MainButtons/Exit"]
anchor_right = 1.0
anchor_bottom = 1.0
offset_top = -1.0
offset_bottom = -18.0
theme_override_font_sizes/font_size = 60
text = "Exit Game"
align = 1
valign = 1
horizontal_alignment = 1
vertical_alignment = 1
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Options" parent="." instance=ExtResource( 3 )]
[node name="Options" parent="." instance=ExtResource( "3" )]
[connection signal="pressed" from="Pause/ButtonHolder/MainButtons/Resume" to="." method="_on_Resume_pressed"]
[connection signal="pressed" from="Pause/ButtonHolder/MainButtons/Options" to="." method="_on_Options_pressed"]

View File

@@ -1,8 +1,9 @@
[remap]
importer="texture"
type="StreamTexture2D"
path="res://.godot/imported/dark_dirt.png-8e8d84e3c30520a8995166be2b7ea97e.stex"
type="CompressedTexture2D"
uid="uid://c514noc8ngc4x"
path="res://.godot/imported/dark_dirt.png-8e8d84e3c30520a8995166be2b7ea97e.ctex"
metadata={
"vram_texture": false
}
@@ -10,26 +11,23 @@ metadata={
[deps]
source_file="res://menu/main/dark_dirt.png"
dest_files=["res://.godot/imported/dark_dirt.png-8e8d84e3c30520a8995166be2b7ea97e.stex"]
dest_files=["res://.godot/imported/dark_dirt.png-8e8d84e3c30520a8995166be2b7ea97e.ctex"]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/hdr_compression=1
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
process/normal_map_invert_y=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0
process/hdr_as_srgb=false
process/size_limit=0
detect_3d/compress_to=1

View File

@@ -1,152 +1,147 @@
[gd_scene load_steps=8 format=2]
[gd_scene load_steps=8 format=3 uid="uid://csdy1t6j24awl"]
[ext_resource path="res://menu/main/title.png" type="Texture2D" id=1]
[ext_resource path="res://menu/main/splash_text.gd" type="Script" id=2]
[ext_resource path="res://menu/main/main_menu.gd" type="Script" id=3]
[ext_resource path="res://menu/main/dark_dirt.png" type="Texture2D" id=4]
[ext_resource path="res://menu/options/options.tscn" type="PackedScene" id=5]
[ext_resource path="res://menu/theme/theme.tres" type="Theme" id=6]
[ext_resource path="res://menu/button.png" type="Texture2D" id=7]
[ext_resource type="Texture2D" uid="uid://c2eorasvxyf5u" path="res://menu/main/title.png" id="1"]
[ext_resource type="Script" path="res://menu/main/splash_text.gd" id="2"]
[ext_resource type="Script" path="res://menu/main/main_menu.gd" id="3"]
[ext_resource type="Texture2D" uid="uid://c514noc8ngc4x" path="res://menu/main/dark_dirt.png" id="4"]
[ext_resource type="PackedScene" uid="uid://e22n700qhxqr" path="res://menu/options/options.tscn" id="5"]
[ext_resource type="Theme" path="res://menu/theme/theme.tres" id="6"]
[ext_resource type="Texture2D" uid="uid://ej6lqf2fptv8" path="res://menu/button.png" id="7"]
[node name="MainMenu" type="Control"]
anchor_right = 1.0
anchor_bottom = 1.0
theme = ExtResource( 6 )
script = ExtResource( 3 )
__meta__ = {
"_edit_use_anchors_": false
}
theme = ExtResource( "6" )
script = ExtResource( "3" )
[node name="Background" type="TextureRect" parent="."]
anchor_right = 1.0
anchor_bottom = 1.0
texture = ExtResource( 4 )
stretch_mode = 2
__meta__ = {
"_edit_use_anchors_": false
}
texture = ExtResource( "4" )
stretch_mode = 1
[node name="TitleScreen" type="VBoxContainer" parent="."]
anchor_right = 1.0
anchor_bottom = 1.0
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Logo" type="CenterContainer" parent="TitleScreen"]
offset_right = 1600.0
offset_bottom = 300.0
rect_min_size = Vector2(0, 300)
texture_repeat = 2
minimum_size = Vector2(0, 240)
offset_right = 1024.0
offset_bottom = 240.0
[node name="Logo" type="TextureRect" parent="TitleScreen/Logo"]
offset_left = 432.0
offset_top = 110.0
offset_right = 1168.0
offset_bottom = 190.0
texture = ExtResource( 1 )
offset_left = 144.0
offset_top = 80.0
offset_right = 880.0
offset_bottom = 160.0
texture = ExtResource( "1" )
[node name="SplashHolder" type="Control" parent="TitleScreen/Logo/Logo"]
anchor_left = 1.0
anchor_top = 1.0
anchor_right = 1.0
anchor_bottom = 1.0
script = ExtResource( 2 )
__meta__ = {
"_edit_use_anchors_": false
}
offset_left = -36.0
offset_right = -36.0
script = ExtResource( "2" )
[node name="SplashText" type="Label" parent="TitleScreen/Logo/Logo/SplashHolder"]
modulate = Color(1, 1, 0, 1)
texture_filter = 1
anchor_left = 1.0
anchor_top = 1.0
anchor_right = 1.0
anchor_bottom = 1.0
offset_left = -110.0
offset_top = 10.0
offset_right = -110.0
offset_bottom = 12.0
rect_rotation = -20.0
offset_left = -120.0
offset_right = 124.0
offset_bottom = 52.0
grow_horizontal = 0
grow_vertical = 0
rotation = -0.261799
theme_override_font_sizes/font_size = 61
text = "Made in Godot!"
__meta__ = {
"_edit_use_anchors_": false
"_edit_layout_mode": 1,
"_edit_use_anchors_": false,
"_edit_use_custom_anchors": false
}
[node name="ButtonHolder" type="HBoxContainer" parent="TitleScreen"]
offset_top = 304.0
offset_right = 1600.0
offset_bottom = 680.0
offset_top = 244.0
offset_right = 1024.0
offset_bottom = 476.0
size_flags_vertical = 3
alignment = 1
[node name="MainButtons" type="VBoxContainer" parent="TitleScreen/ButtonHolder"]
offset_left = 608.0
offset_right = 992.0
offset_bottom = 376.0
custom_constants/separation = 20
offset_left = 320.0
offset_right = 704.0
offset_bottom = 232.0
theme_override_constants/separation = 20
alignment = 1
[node name="Start" type="TextureButton" parent="TitleScreen/ButtonHolder/MainButtons"]
offset_top = 72.0
offset_right = 384.0
offset_bottom = 136.0
rect_min_size = Vector2(384, 64)
texture_normal = ExtResource( 7 )
offset_bottom = 64.0
texture_normal = ExtResource( "7" )
[node name="Label" type="Label" parent="TitleScreen/ButtonHolder/MainButtons/Start"]
texture_filter = 1
anchor_right = 1.0
anchor_bottom = 1.0
offset_top = -1.0
offset_bottom = -18.0
theme_override_font_sizes/font_size = 60
text = "Start Game"
align = 1
valign = 1
horizontal_alignment = 1
vertical_alignment = 1
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Options" type="TextureButton" parent="TitleScreen/ButtonHolder/MainButtons"]
offset_top = 156.0
offset_top = 84.0
offset_right = 384.0
offset_bottom = 220.0
rect_min_size = Vector2(384, 64)
texture_normal = ExtResource( 7 )
offset_bottom = 148.0
texture_normal = ExtResource( "7" )
[node name="Label" type="Label" parent="TitleScreen/ButtonHolder/MainButtons/Options"]
texture_filter = 1
anchor_right = 1.0
anchor_bottom = 1.0
offset_top = -1.0
offset_bottom = -18.0
theme_override_font_sizes/font_size = 60
text = "Options"
align = 1
valign = 1
__meta__ = {
"_edit_use_anchors_": false
}
horizontal_alignment = 1
vertical_alignment = 1
[node name="Exit" type="TextureButton" parent="TitleScreen/ButtonHolder/MainButtons"]
offset_top = 240.0
offset_top = 168.0
offset_right = 384.0
offset_bottom = 304.0
rect_min_size = Vector2(384, 64)
texture_normal = ExtResource( 7 )
offset_bottom = 232.0
texture_normal = ExtResource( "7" )
[node name="Label" type="Label" parent="TitleScreen/ButtonHolder/MainButtons/Exit"]
texture_filter = 1
anchor_right = 1.0
anchor_bottom = 1.0
offset_top = -1.0
offset_bottom = -18.0
theme_override_font_sizes/font_size = 60
text = "Exit Game"
align = 1
valign = 1
horizontal_alignment = 1
vertical_alignment = 1
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Spacer" type="Control" parent="TitleScreen"]
offset_top = 684.0
offset_right = 1600.0
offset_bottom = 900.0
rect_min_size = Vector2(0, 216)
minimum_size = Vector2(0, 120)
offset_top = 480.0
offset_right = 1024.0
offset_bottom = 600.0
[node name="StartGame" type="HBoxContainer" parent="."]
visible = false
@@ -158,76 +153,75 @@ __meta__ = {
}
[node name="StartButtons" type="VBoxContainer" parent="StartGame"]
offset_left = 608.0
offset_right = 992.0
offset_bottom = 900.0
custom_constants/separation = 20
offset_left = 320.0
offset_right = 704.0
offset_bottom = 600.0
theme_override_constants/separation = 20
alignment = 1
[node name="Spacer" type="Control" parent="StartGame/StartButtons"]
offset_top = 292.0
offset_top = 198.0
offset_right = 384.0
offset_bottom = 356.0
rect_min_size = Vector2(0, 64)
offset_bottom = 198.0
[node name="RandomBlocks" type="TextureButton" parent="StartGame/StartButtons"]
offset_top = 376.0
offset_top = 202.0
offset_right = 384.0
offset_bottom = 440.0
rect_min_size = Vector2(384, 64)
texture_normal = ExtResource( 7 )
offset_bottom = 266.0
texture_normal = ExtResource( "7" )
[node name="Label" type="Label" parent="StartGame/StartButtons/RandomBlocks"]
anchor_right = 1.0
anchor_bottom = 1.0
offset_top = -1.0
offset_bottom = -18.0
theme_override_font_sizes/font_size = 60
text = "Random Blocks"
align = 1
valign = 1
horizontal_alignment = 1
vertical_alignment = 1
__meta__ = {
"_edit_use_anchors_": false
}
[node name="FlatGrass" type="TextureButton" parent="StartGame/StartButtons"]
offset_top = 460.0
offset_top = 270.0
offset_right = 384.0
offset_bottom = 524.0
rect_min_size = Vector2(384, 64)
texture_normal = ExtResource( 7 )
offset_bottom = 334.0
texture_normal = ExtResource( "7" )
[node name="Label" type="Label" parent="StartGame/StartButtons/FlatGrass"]
anchor_right = 1.0
anchor_bottom = 1.0
offset_top = -1.0
offset_bottom = -18.0
theme_override_font_sizes/font_size = 60
text = "Flat Grass"
align = 1
valign = 1
horizontal_alignment = 1
vertical_alignment = 1
__meta__ = {
"_edit_use_anchors_": false
}
[node name="BackToTitle" type="TextureButton" parent="StartGame/StartButtons"]
offset_top = 544.0
offset_top = 338.0
offset_right = 384.0
offset_bottom = 608.0
rect_min_size = Vector2(384, 64)
texture_normal = ExtResource( 7 )
offset_bottom = 402.0
texture_normal = ExtResource( "7" )
[node name="Label" type="Label" parent="StartGame/StartButtons/BackToTitle"]
anchor_right = 1.0
anchor_bottom = 1.0
offset_top = -1.0
offset_bottom = -18.0
theme_override_font_sizes/font_size = 60
text = "Back"
align = 1
valign = 1
horizontal_alignment = 1
vertical_alignment = 1
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Options" parent="." instance=ExtResource( 5 )]
[node name="Options" parent="." instance=ExtResource( "5" )]
[connection signal="pressed" from="TitleScreen/ButtonHolder/MainButtons/Start" to="." method="_on_Start_pressed"]
[connection signal="pressed" from="TitleScreen/ButtonHolder/MainButtons/Options" to="." method="_on_Options_pressed"]

View File

@@ -5,4 +5,4 @@ var time := 0.0
func _process(delta):
time += delta
rect_scale = Vector2.ONE * (1 - abs(sin(time * 4)) / 4)
scale = Vector2.ONE * (1 - abs(sin(time * 4)) / 4)

View File

@@ -1,8 +1,9 @@
[remap]
importer="texture"
type="StreamTexture2D"
path="res://.godot/imported/title.png-73a3b55f70af530edac2d45668ba262c.stex"
type="CompressedTexture2D"
uid="uid://c2eorasvxyf5u"
path="res://.godot/imported/title.png-73a3b55f70af530edac2d45668ba262c.ctex"
metadata={
"vram_texture": false
}
@@ -10,26 +11,23 @@ metadata={
[deps]
source_file="res://menu/main/title.png"
dest_files=["res://.godot/imported/title.png-73a3b55f70af530edac2d45668ba262c.stex"]
dest_files=["res://.godot/imported/title.png-73a3b55f70af530edac2d45668ba262c.ctex"]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/hdr_compression=1
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=false
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=false
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
process/normal_map_invert_y=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0
process/hdr_as_srgb=false
process/size_limit=0
detect_3d/compress_to=1

View File

@@ -2,13 +2,13 @@ extends Control
@onready var render_distance_label = $RenderDistanceLabel
@onready var render_distance_slider = $RenderDistanceSlider
@onready var fog_checkbox = $FogCheckBox
@onready var fog_checkbox: CheckBox = $FogCheckBox
func _ready():
render_distance_slider.value = Settings.render_distance
render_distance_label.text = "Render distance: " + str(Settings.render_distance)
fog_checkbox.pressed = Settings.fog_enabled
fog_checkbox.button_pressed = Settings.fog_enabled
func _on_RenderDistanceSlider_value_changed(value):
@@ -18,5 +18,5 @@ func _on_RenderDistanceSlider_value_changed(value):
func _on_FogCheckBox_pressed():
Settings.fog_enabled = fog_checkbox.pressed
Settings.fog_enabled = fog_checkbox.button_pressed
Settings.save_settings()

View File

@@ -1,33 +1,35 @@
[gd_scene load_steps=4 format=2]
[gd_scene load_steps=5 format=3 uid="uid://e22n700qhxqr"]
[ext_resource path="res://menu/options/options.gd" type="Script" id=1]
[ext_resource path="res://menu/options/option_buttons.gd" type="Script" id=2]
[ext_resource path="res://menu/button.png" type="Texture2D" id=3]
[ext_resource type="Script" path="res://menu/options/options.gd" id="1"]
[ext_resource type="Theme" path="res://menu/theme/theme.tres" id="1_1y7gy"]
[ext_resource type="Script" path="res://menu/options/option_buttons.gd" id="2"]
[ext_resource type="Texture2D" uid="uid://ej6lqf2fptv8" path="res://menu/button.png" id="3"]
[node name="Options" type="HBoxContainer"]
visible = false
anchor_right = 1.0
anchor_bottom = 1.0
theme = ExtResource( "1_1y7gy" )
alignment = 1
script = ExtResource( 1 )
script = ExtResource( "1" )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="VBoxContainer" type="VBoxContainer" parent="."]
offset_left = 384.0
offset_right = 1216.0
offset_bottom = 900.0
custom_constants/separation = 93
offset_left = 87.0
offset_right = 937.0
offset_bottom = 600.0
theme_override_constants/separation = 20
alignment = 1
[node name="OptionsBackground" type="TextureRect" parent="VBoxContainer"]
offset_top = 288.0
offset_right = 832.0
offset_bottom = 448.0
rect_min_size = Vector2(832, 160)
texture = ExtResource( 3 )
stretch_mode = 2
minimum_size = Vector2(850, 150)
offset_top = 183.0
offset_right = 850.0
offset_bottom = 333.0
texture = ExtResource( "3" )
stretch_mode = 1
[node name="OptionButtons" type="GridContainer" parent="VBoxContainer/OptionsBackground"]
anchor_left = 0.5
@@ -38,28 +40,25 @@ offset_left = -400.0
offset_top = -66.0
offset_right = 400.0
offset_bottom = 66.0
rect_min_size = Vector2(800, 128)
columns = 2
script = ExtResource( 2 )
__meta__ = {
"_edit_use_anchors_": false
}
script = ExtResource( "2" )
[node name="RenderDistanceLabel" type="Label" parent="VBoxContainer/OptionsBackground/OptionButtons"]
offset_right = 384.0
minimum_size = Vector2(320, 0)
offset_right = 320.0
offset_bottom = 64.0
rect_min_size = Vector2(384, 64)
size_flags_vertical = 5
theme_override_font_sizes/font_size = 60
text = "Render distance: 3"
horizontal_alignment = 2
__meta__ = {
"_edit_use_anchors_": false
}
[node name="RenderDistanceSlider" type="HSlider" parent="VBoxContainer/OptionsBackground/OptionButtons"]
offset_left = 388.0
offset_left = 324.0
offset_right = 800.0
offset_bottom = 64.0
rect_min_size = Vector2(384, 64)
size_flags_horizontal = 3
size_flags_vertical = 3
min_value = 3.0
@@ -68,45 +67,42 @@ value = 7.0
[node name="FogLabel" type="Label" parent="VBoxContainer/OptionsBackground/OptionButtons"]
offset_top = 68.0
offset_right = 384.0
offset_right = 320.0
offset_bottom = 132.0
rect_min_size = Vector2(384, 64)
size_flags_vertical = 5
theme_override_font_sizes/font_size = 60
text = "Fog Enabled"
horizontal_alignment = 2
[node name="FogCheckBox" type="CheckBox" parent="VBoxContainer/OptionsBackground/OptionButtons"]
offset_left = 388.0
offset_left = 324.0
offset_top = 68.0
offset_right = 800.0
offset_bottom = 132.0
rect_min_size = Vector2(384, 64)
size_flags_horizontal = 3
size_flags_vertical = 3
[node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainer"]
offset_top = 548.0
offset_right = 832.0
offset_bottom = 612.0
offset_top = 353.0
offset_right = 850.0
offset_bottom = 417.0
alignment = 1
[node name="Back" type="TextureButton" parent="VBoxContainer/HBoxContainer"]
offset_left = 224.0
offset_right = 608.0
offset_left = 233.0
offset_right = 617.0
offset_bottom = 64.0
rect_min_size = Vector2(384, 64)
texture_normal = ExtResource( 3 )
texture_normal = ExtResource( "3" )
[node name="Label" type="Label" parent="VBoxContainer/HBoxContainer/Back"]
anchor_right = 1.0
anchor_bottom = 1.0
offset_top = -1.0
offset_bottom = -18.0
theme_override_font_sizes/font_size = 60
text = "Back"
align = 1
valign = 1
__meta__ = {
"_edit_use_anchors_": false
}
horizontal_alignment = 1
vertical_alignment = 1
[connection signal="value_changed" from="VBoxContainer/OptionsBackground/OptionButtons/RenderDistanceSlider" to="VBoxContainer/OptionsBackground/OptionButtons" method="_on_RenderDistanceSlider_value_changed"]
[connection signal="pressed" from="VBoxContainer/OptionsBackground/OptionButtons/FogCheckBox" to="VBoxContainer/OptionsBackground/OptionButtons" method="_on_FogCheckBox_pressed"]

View File

@@ -1,7 +1,6 @@
[gd_resource type="Font" load_steps=2 format=2]
[gd_resource type="Font" load_steps=2 format=3 uid="uid://65p88jvybwaw"]
[ext_resource path="res://menu/theme/TinyUnicode.ttf" type="FontData" id=1]
[ext_resource type="FontData" uid="uid://d223lt6j1fyie" path="res://menu/theme/TinyUnicode.ttf" id="1"]
[resource]
size = 64
font_data = ExtResource( 1 )
data/0 = ExtResource( "1" )

View File

@@ -0,0 +1,33 @@
[remap]
importer="font_data_dynamic"
type="FontData"
uid="uid://d223lt6j1fyie"
path="res://.godot/imported/TinyUnicode.ttf-eba88eb6541afc571b283cb8123beb7f.fontdata"
[deps]
source_file="res://menu/theme/TinyUnicode.ttf"
dest_files=["res://.godot/imported/TinyUnicode.ttf-eba88eb6541afc571b283cb8123beb7f.fontdata"]
[params]
antialiased=true
multichannel_signed_distance_field=false
msdf_pixel_range=8
msdf_size=48
force_autohinter=false
hinting=1
subpixel_positioning=1
embolden=0.0
transform=Transform2D(1, 0, 0, 1, 0, 0)
oversampling=0.0
compress=true
opentype_feature_overrides={}
preload/char_ranges=PackedStringArray()
preload/glyph_ranges=PackedStringArray()
preload/configurations=PackedStringArray()
support_overrides/language_enabled=PackedStringArray()
support_overrides/language_disabled=PackedStringArray()
support_overrides/script_enabled=PackedStringArray()
support_overrides/script_disabled=PackedStringArray()

View File

@@ -1,8 +1,9 @@
[remap]
importer="texture"
type="StreamTexture2D"
path="res://.godot/imported/crosshair.svg-c15896115a8fc4f09948d0fd31ee95e9.stex"
type="CompressedTexture2D"
uid="uid://cgv7xgoy43rbc"
path="res://.godot/imported/crosshair.svg-c15896115a8fc4f09948d0fd31ee95e9.ctex"
metadata={
"vram_texture": false
}
@@ -10,26 +11,24 @@ metadata={
[deps]
source_file="res://player/crosshair.svg"
dest_files=["res://.godot/imported/crosshair.svg-c15896115a8fc4f09948d0fd31ee95e9.stex"]
dest_files=["res://.godot/imported/crosshair.svg-c15896115a8fc4f09948d0fd31ee95e9.ctex"]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/hdr_compression=1
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
process/normal_map_invert_y=false
stream=false
size_limit=0
detect_3d=true
process/hdr_as_srgb=false
process/size_limit=0
detect_3d/compress_to=1
svg/scale=1.0

View File

@@ -1,7 +1,5 @@
extends CharacterBody3D
var velocity = Vector3()
var _mouse_motion = Vector2()
var _selected_block = 6
@@ -9,6 +7,7 @@ var _selected_block = 6
@onready var head = $Head
@onready var raycast = $Head/RayCast3D
@onready var camera_effects = $Head/Camera3D.effects
@onready var selected_block_texture = $SelectedBlock
@onready var voxel_world = $"../VoxelWorld"
@onready var crosshair = $"../PauseMenu/Crosshair"
@@ -21,15 +20,15 @@ func _ready():
func _process(_delta):
# Mouse movement.
_mouse_motion.y = clamp(_mouse_motion.y, -1550, 1550)
transform.basis = Basis(Vector3(0, _mouse_motion.x * -0.001, 0))
head.transform.basis = Basis(Vector3(_mouse_motion.y * -0.001, 0, 0))
transform.basis = Basis.from_euler(Vector3(0, _mouse_motion.x * -0.001, 0))
head.transform.basis = Basis.from_euler(Vector3(_mouse_motion.y * -0.001, 0, 0))
# Block selection.
var position = raycast.get_collision_point()
var normal = raycast.get_collision_normal()
var ray_position = raycast.get_collision_point()
var ray_normal = raycast.get_collision_normal()
if Input.is_action_just_pressed("pick_block"):
# Block picking.
var block_global_position = (position - normal / 2).floor()
var block_global_position = Vector3i((ray_position - ray_normal / 2).floor())
_selected_block = voxel_world.get_block_global_position(block_global_position)
else:
# Block prev/next keys.
@@ -51,14 +50,17 @@ func _process(_delta):
return
if breaking:
var block_global_position = (position - normal / 2).floor()
var block_global_position = Vector3i((ray_position - ray_normal / 2).floor())
voxel_world.set_block_global_position(block_global_position, 0)
elif placing:
var block_global_position = (position + normal / 2).floor()
var block_global_position = Vector3i((ray_position + ray_normal / 2).floor())
voxel_world.set_block_global_position(block_global_position, _selected_block)
func _physics_process(delta):
camera_effects.dof_blur_far_enabled = Settings.fog_enabled
camera_effects.dof_blur_far_distance = Settings.fog_distance * 1.5
camera_effects.dof_blur_far_transition = Settings.fog_distance / 8
# Crouching.
var crouching = Input.is_action_pressed("crouch")
if crouching:
@@ -76,8 +78,8 @@ func _physics_process(delta):
velocity.y -= gravity * delta
#warning-ignore:return_value_discarded
# TODO: This information should be set to the CharacterBody properties instead of arguments.
move_and_slide(Vector3(movement.x, velocity.y, movement.z), Vector3.UP)
velocity = Vector3(movement.x, velocity.y, movement.z)
move_and_slide()
# Jumping, applied next frame.
if is_on_floor() and Input.is_action_pressed("jump"):
@@ -91,4 +93,4 @@ func _input(event):
func chunk_pos():
return (transform.origin / Chunk.CHUNK_SIZE).floor()
return Vector3i((transform.origin / Chunk.CHUNK_SIZE).floor())

View File

@@ -1,49 +1,48 @@
[gd_scene load_steps=5 format=2]
[gd_scene load_steps=6 format=3 uid="uid://1s4asqpay67m"]
[ext_resource path="res://player/player.gd" type="Script" id=1]
[ext_resource path="res://world/textures/texture_sheet.png" type="Texture2D" id=2]
[ext_resource type="Script" path="res://player/player.gd" id="1"]
[ext_resource type="Texture2D" uid="uid://d3f34krqfgdjd" path="res://world/textures/texture_sheet.png" id="2"]
[sub_resource type="CylinderShape3D" id=1]
radius = 0.4
height = 1.8
[sub_resource type="CylinderShape3D" id="1"]
radius = 0.375
height = 1.75
[sub_resource type="AtlasTexture" id=2]
flags = 11
atlas = ExtResource( 2 )
[sub_resource type="CameraEffects" id="CameraEffects_hnscx"]
dof_blur_far_enabled = true
dof_blur_far_distance = 100.0
dof_blur_far_transition = 16.0
dof_blur_amount = 0.25
[sub_resource type="AtlasTexture" id="2"]
atlas = ExtResource( "2" )
region = Rect2(0, 0, 64, 64)
[node name="Player" type="CharacterBody3D"]
collision_layer = 0
script = ExtResource( 1 )
script = ExtResource( "1" )
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.9, 0)
shape = SubResource( 1 )
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.875, 0)
shape = SubResource( "1" )
[node name="Head" type="Node3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.6, 0)
[node name="Camera3D" type="Camera3D" parent="Head"]
fov = 75.0
effects = SubResource( "CameraEffects_hnscx" )
near = 0.02
far = 1000.0
[node name="RayCast3D" type="RayCast3D" parent="Head"]
enabled = true
cast_to = Vector3(0, 0, -5)
target_position = Vector3(0, 0, -4)
[node name="SelectedBlock" type="TextureRect" parent="."]
texture_filter = 1
anchor_left = 1.0
anchor_top = 1.0
anchor_right = 1.0
anchor_bottom = 1.0
offset_left = -128.0
offset_top = -128.0
offset_right = -64.0
offset_bottom = -64.0
rect_min_size = Vector2(64, 64)
rect_scale = Vector2(2, 2)
texture = SubResource( 2 )
__meta__ = {
"_edit_use_anchors_": false
}
texture = SubResource( "2" )
ignore_texture_size = true

View File

@@ -6,7 +6,7 @@
; [section] ; section goes between []
; param=value ; assign values to parameters
config_version=4
config_version=5
_global_script_classes=[{
"base": "StaticBody3D",
@@ -34,6 +34,7 @@ quite limiting. If you are making your own voxel game, you should probably
use Zylann's voxel module instead: https://github.com/Zylann/godot_voxel"
run/main_scene="res://menu/main/main_menu.tscn"
config/icon="res://icon.png"
config/features=PackedStringArray("4.0")
[autoload]
@@ -41,11 +42,10 @@ Settings="*res://settings.gd"
[display]
window/size/width=1600
window/size/height=900
window/dpi/allow_hidpi=true
window/stretch/mode="2d"
window/stretch/aspect="expand"
window/size/width=1600
window/size/height=900
[input]
@@ -156,11 +156,14 @@ pick_block={
[physics]
common/physics_fps=120
3d/physics_engine="Bullet"
common/physics_fps=120
[rendering]
anti_aliasing/quality/msaa=3
anti_aliasing/quality/screen_space_aa=1
textures/canvas_textures/default_texture_filter=0
quality/driver/driver_name="GLES2"
vram_compression/import_etc=true
vram_compression/import_etc2=false

View File

@@ -3,9 +3,11 @@ extends Node
var render_distance = 7
var fog_enabled = true
var fog_distance = 32.0 # Not saved, only used during runtime.
var world_type = 0 # Not saved, only used during runtime.
var _save_path = "user://settings.json"
@warning_ignore(unused_private_class_variable)
var _loaded = false
@@ -19,7 +21,7 @@ func _enter_tree():
var file = File.new()
if file.file_exists(_save_path):
file.open(_save_path, File.READ)
while file.get_position() < file.get_len():
while file.get_position() < file.get_length():
# Get the saved dictionary from the next line in the save file
var json = JSON.new()
json.parse(file.get_line())

View File

@@ -19,7 +19,7 @@ var _thread
func _ready():
transform.origin = chunk_position * CHUNK_SIZE
transform.origin = Vector3(chunk_position * CHUNK_SIZE)
name = str(chunk_position)
if Settings.world_type == 0:
data = TerrainGenerator.random_blocks()
@@ -30,7 +30,7 @@ func _ready():
_generate_chunk_collider()
# However, we can use a thread for mesh generation.
_thread = Thread.new()
_thread.start(self, "_generate_chunk_mesh")
_thread.start(self._generate_chunk_mesh)
func regenerate():
@@ -113,7 +113,7 @@ func _draw_block_mesh(surface_tool, block_sub_position, block_id):
bottom_uvs = top_uvs
# Main rendering code for normal blocks.
var other_block_position = block_sub_position + Vector3.LEFT
var other_block_position = block_sub_position + Vector3i.LEFT
var other_block_id = 0
if other_block_position.x == -1:
other_block_id = voxel_world.get_block_global_position(other_block_position + chunk_position * CHUNK_SIZE)
@@ -122,7 +122,7 @@ func _draw_block_mesh(surface_tool, block_sub_position, block_id):
if block_id != other_block_id and is_block_transparent(other_block_id):
_draw_block_face(surface_tool, [verts[2], verts[0], verts[3], verts[1]], uvs)
other_block_position = block_sub_position + Vector3.RIGHT
other_block_position = block_sub_position + Vector3i.RIGHT
other_block_id = 0
if other_block_position.x == CHUNK_SIZE:
other_block_id = voxel_world.get_block_global_position(other_block_position + chunk_position * CHUNK_SIZE)
@@ -131,7 +131,7 @@ func _draw_block_mesh(surface_tool, block_sub_position, block_id):
if block_id != other_block_id and is_block_transparent(other_block_id):
_draw_block_face(surface_tool, [verts[7], verts[5], verts[6], verts[4]], uvs)
other_block_position = block_sub_position + Vector3.FORWARD
other_block_position = block_sub_position + Vector3i.FORWARD
other_block_id = 0
if other_block_position.z == -1:
other_block_id = voxel_world.get_block_global_position(other_block_position + chunk_position * CHUNK_SIZE)
@@ -140,7 +140,7 @@ func _draw_block_mesh(surface_tool, block_sub_position, block_id):
if block_id != other_block_id and is_block_transparent(other_block_id):
_draw_block_face(surface_tool, [verts[6], verts[4], verts[2], verts[0]], uvs)
other_block_position = block_sub_position + Vector3.BACK
other_block_position = block_sub_position + Vector3i.BACK
other_block_id = 0
if other_block_position.z == CHUNK_SIZE:
other_block_id = voxel_world.get_block_global_position(other_block_position + chunk_position * CHUNK_SIZE)
@@ -149,7 +149,7 @@ func _draw_block_mesh(surface_tool, block_sub_position, block_id):
if block_id != other_block_id and is_block_transparent(other_block_id):
_draw_block_face(surface_tool, [verts[3], verts[1], verts[7], verts[5]], uvs)
other_block_position = block_sub_position + Vector3.DOWN
other_block_position = block_sub_position + Vector3i.DOWN
other_block_id = 0
if other_block_position.y == -1:
other_block_id = voxel_world.get_block_global_position(other_block_position + chunk_position * CHUNK_SIZE)
@@ -158,7 +158,7 @@ func _draw_block_mesh(surface_tool, block_sub_position, block_id):
if block_id != other_block_id and is_block_transparent(other_block_id):
_draw_block_face(surface_tool, [verts[4], verts[5], verts[0], verts[1]], bottom_uvs)
other_block_position = block_sub_position + Vector3.UP
other_block_position = block_sub_position + Vector3i.UP
other_block_id = 0
if other_block_position.y == CHUNK_SIZE:
other_block_id = voxel_world.get_block_global_position(other_block_position + chunk_position * CHUNK_SIZE)
@@ -168,21 +168,21 @@ func _draw_block_mesh(surface_tool, block_sub_position, block_id):
_draw_block_face(surface_tool, [verts[2], verts[3], verts[6], verts[7]], top_uvs)
func _draw_block_face(surface_tool, verts, uvs):
surface_tool.add_uv(uvs[1]); surface_tool.add_vertex(verts[1])
surface_tool.add_uv(uvs[2]); surface_tool.add_vertex(verts[2])
surface_tool.add_uv(uvs[3]); surface_tool.add_vertex(verts[3])
func _draw_block_face(surface_tool: SurfaceTool, verts, uvs):
surface_tool.set_uv(uvs[1]); surface_tool.add_vertex(verts[1])
surface_tool.set_uv(uvs[2]); surface_tool.add_vertex(verts[2])
surface_tool.set_uv(uvs[3]); surface_tool.add_vertex(verts[3])
surface_tool.add_uv(uvs[2]); surface_tool.add_vertex(verts[2])
surface_tool.add_uv(uvs[1]); surface_tool.add_vertex(verts[1])
surface_tool.add_uv(uvs[0]); surface_tool.add_vertex(verts[0])
surface_tool.set_uv(uvs[2]); surface_tool.add_vertex(verts[2])
surface_tool.set_uv(uvs[1]); surface_tool.add_vertex(verts[1])
surface_tool.set_uv(uvs[0]); surface_tool.add_vertex(verts[0])
func _create_block_collider(block_sub_position):
var collider = CollisionShape3D.new()
collider.shape = BoxShape3D.new()
collider.shape.extents = Vector3.ONE / 2
collider.transform.origin = block_sub_position + Vector3.ONE / 2
collider.transform.origin = Vector3(block_sub_position) + Vector3.ONE / 2
add_child(collider)
@@ -192,10 +192,12 @@ static func calculate_block_uvs(block_id):
var col = block_id % TEXTURE_SHEET_WIDTH
return [
TEXTURE_TILE_SIZE * Vector2(col, row),
TEXTURE_TILE_SIZE * Vector2(col, row + 1),
TEXTURE_TILE_SIZE * Vector2(col + 1, row),
TEXTURE_TILE_SIZE * Vector2(col + 1, row + 1),
# Godot 4 has a weird bug where there are seams at the edge
# of the textures. Adding a margin of 0.01 "fixes" it.
TEXTURE_TILE_SIZE * Vector2(col + 0.01, row + 0.01),
TEXTURE_TILE_SIZE * Vector2(col + 0.01, row + 0.99),
TEXTURE_TILE_SIZE * Vector2(col + 0.99, row + 0.01),
TEXTURE_TILE_SIZE * Vector2(col + 0.99, row + 0.99),
]

View File

@@ -6,12 +6,8 @@ extends WorldEnvironment
func _process(delta):
environment.fog_enabled = Settings.fog_enabled
environment.dof_blur_far_enabled = Settings.fog_enabled
var target_distance = clamp(voxel_world.effective_render_distance, 2, voxel_world.render_distance - 1) * Chunk.CHUNK_SIZE
var rate = delta * 4
if environment.fog_depth_end > target_distance:
rate *= 2
environment.fog_depth_begin = move_toward(environment.fog_depth_begin, target_distance - Chunk.CHUNK_SIZE, rate)
environment.fog_depth_end = move_toward(environment.fog_depth_end, target_distance, rate)
environment.dof_blur_far_distance = environment.fog_depth_end
Settings.fog_distance = move_toward(Settings.fog_distance, target_distance, rate)
environment.fog_density = 0.5 / Settings.fog_distance

View File

@@ -29,14 +29,14 @@ static func flat(chunk_position):
for x in range(CHUNK_SIZE):
for z in range(CHUNK_SIZE):
data[Vector3(x, 0, z)] = 3
data[Vector3i(x, 0, z)] = 3
return data
# Used to create the project icon.
static func origin_grass(chunk_position):
if chunk_position == Vector3.ZERO:
return {Vector3.ZERO: 3}
if chunk_position == Vector3i.ZERO:
return {Vector3i.ZERO: 3}
return {}

View File

@@ -1,8 +1,9 @@
[gd_resource type="StandardMaterial3D" load_steps=2 format=2]
[gd_resource type="StandardMaterial3D" load_steps=2 format=3 uid="uid://wfvc2s58yyad"]
[ext_resource path="res://world/textures/texture_sheet.png" type="Texture2D" id=1]
[ext_resource type="Texture2D" uid="uid://d3f34krqfgdjd" path="res://world/textures/texture_sheet.png" id="1"]
[resource]
flags_transparent = true
params_depth_draw_mode = 3
albedo_texture = ExtResource( 1 )
transparency = 4
albedo_texture = ExtResource( "1" )
texture_filter = 0
texture_repeat = false

View File

@@ -1,8 +1,9 @@
[remap]
importer="texture"
type="StreamTexture2D"
path="res://.godot/imported/texture_sheet.png-52286655fc64f0acb01bdaefe1f1bd3e.stex"
type="CompressedTexture2D"
uid="uid://d3f34krqfgdjd"
path="res://.godot/imported/texture_sheet.png-52286655fc64f0acb01bdaefe1f1bd3e.ctex"
metadata={
"vram_texture": false
}
@@ -10,26 +11,23 @@ metadata={
[deps]
source_file="res://world/textures/texture_sheet.png"
dest_files=["res://.godot/imported/texture_sheet.png-52286655fc64f0acb01bdaefe1f1bd3e.stex"]
dest_files=["res://.godot/imported/texture_sheet.png-52286655fc64f0acb01bdaefe1f1bd3e.ctex"]
[params]
compress/mode=0
compress/lossy_quality=1.0
compress/hdr_mode=0
compress/hdr_compression=1
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=true
flags/filter=false
flags/mipmaps=true
flags/anisotropic=true
flags/srgb=2
compress/channel_pack=0
mipmaps/generate=true
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=false
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
process/normal_map_invert_y=false
stream=false
size_limit=0
detect_3d=false
svg/scale=1.0
process/hdr_as_srgb=false
process/size_limit=0
detect_3d/compress_to=0

View File

@@ -6,8 +6,9 @@ const CHUNK_END_SIZE = Chunk.CHUNK_SIZE - 1
var render_distance:
set(value):
# TODO: Manually copy the code from this method.
_set_render_distance(value)
render_distance = value
_delete_distance = value + 2
var _delete_distance = 0
var effective_render_distance = 0
var _old_player_chunk = Vector3i()
@@ -21,8 +22,8 @@ var _chunks = {}
func _process(_delta):
_set_render_distance(Settings.render_distance)
var player_chunk = (player.transform.origin / Chunk.CHUNK_SIZE).round()
render_distance = Settings.render_distance
var player_chunk = Vector3i((player.transform.origin / Chunk.CHUNK_SIZE).round())
if _deleting or player_chunk != _old_player_chunk:
_delete_far_away_chunks(player_chunk)
@@ -38,8 +39,8 @@ func _process(_delta):
for x in range(player_chunk.x - effective_render_distance, player_chunk.x + effective_render_distance):
for y in range(player_chunk.y - effective_render_distance, player_chunk.y + effective_render_distance):
for z in range(player_chunk.z - effective_render_distance, player_chunk.z + effective_render_distance):
var chunk_position = Vector3(x, y, z)
if player_chunk.distance_to(chunk_position) > render_distance:
var chunk_position = Vector3i(x, y, z)
if Vector3(player_chunk).distance_to(Vector3(chunk_position)) > render_distance:
continue
if _chunks.has(chunk_position):
@@ -60,20 +61,20 @@ func _process(_delta):
_generating = false
func get_block_global_position(block_global_position):
var chunk_position = (block_global_position / Chunk.CHUNK_SIZE).floor()
func get_block_global_position(block_global_position: Vector3i):
var chunk_position = Vector3i((block_global_position / Chunk.CHUNK_SIZE))
if _chunks.has(chunk_position):
var chunk = _chunks[chunk_position]
var sub_position = block_global_position.posmod(Chunk.CHUNK_SIZE)
var sub_position = Vector3i(Vector3(block_global_position).posmod(Chunk.CHUNK_SIZE))
if chunk.data.has(sub_position):
return chunk.data[sub_position]
return 0
func set_block_global_position(block_global_position, block_id):
var chunk_position = (block_global_position / Chunk.CHUNK_SIZE).floor()
func set_block_global_position(block_global_position: Vector3i, block_id):
var chunk_position = Vector3i((Vector3(block_global_position) / Chunk.CHUNK_SIZE).floor())
var chunk = _chunks[chunk_position]
var sub_position = block_global_position.posmod(Chunk.CHUNK_SIZE)
var sub_position = Vector3i(Vector3(block_global_position).posmod(Chunk.CHUNK_SIZE))
if block_id == 0:
chunk.data.erase(sub_position)
else:
@@ -83,17 +84,17 @@ func set_block_global_position(block_global_position, block_id):
# We also might need to regenerate some neighboring chunks.
if Chunk.is_block_transparent(block_id):
if sub_position.x == 0:
_chunks[chunk_position + Vector3.LEFT].regenerate()
_chunks[chunk_position + Vector3i.LEFT].regenerate()
elif sub_position.x == CHUNK_END_SIZE:
_chunks[chunk_position + Vector3.RIGHT].regenerate()
_chunks[chunk_position + Vector3i.RIGHT].regenerate()
if sub_position.z == 0:
_chunks[chunk_position + Vector3.FORWARD].regenerate()
_chunks[chunk_position + Vector3i.FORWARD].regenerate()
elif sub_position.z == CHUNK_END_SIZE:
_chunks[chunk_position + Vector3.BACK].regenerate()
_chunks[chunk_position + Vector3i.BACK].regenerate()
if sub_position.y == 0:
_chunks[chunk_position + Vector3.DOWN].regenerate()
_chunks[chunk_position + Vector3i.DOWN].regenerate()
elif sub_position.y == CHUNK_END_SIZE:
_chunks[chunk_position + Vector3.UP].regenerate()
_chunks[chunk_position + Vector3i.UP].regenerate()
func clean_up():
@@ -119,7 +120,7 @@ func _delete_far_away_chunks(player_chunk):
var max_deletions = clamp(2 * (render_distance - effective_render_distance), 2, 8)
# Also take the opportunity to delete far away chunks.
for chunk_position_key in _chunks.keys():
if player_chunk.distance_to(chunk_position_key) > _delete_distance:
if Vector3(player_chunk).distance_to(Vector3(chunk_position_key)) > _delete_distance:
var thread = _chunks[chunk_position_key]._thread
if thread:
thread.wait_to_finish()
@@ -134,8 +135,3 @@ func _delete_far_away_chunks(player_chunk):
# We're done deleting.
_deleting = false
func _set_render_distance(value):
render_distance = value
_delete_distance = value + 2

View File

@@ -1,16 +1,30 @@
[gd_scene load_steps=8 format=2]
[gd_scene load_steps=10 format=3 uid="uid://3wtpjm677uyk"]
[ext_resource path="res://player/player.tscn" type="PackedScene" id=1]
[ext_resource path="res://world/voxel_world.gd" type="Script" id=2]
[ext_resource path="res://default_env.tres" type="Environment" id=3]
[ext_resource path="res://world/environment.gd" type="Script" id=4]
[ext_resource path="res://menu/ingame/pause_menu.tscn" type="PackedScene" id=5]
[ext_resource path="res://menu/debug.gd" type="Script" id=6]
[ext_resource path="res://menu/theme/theme.tres" type="Theme" id=7]
[ext_resource type="PackedScene" uid="uid://1s4asqpay67m" path="res://player/player.tscn" id="1"]
[ext_resource type="Script" path="res://world/voxel_world.gd" id="2"]
[ext_resource type="Script" path="res://world/environment.gd" id="4"]
[ext_resource type="PackedScene" uid="uid://dk8arl1if3lyr" path="res://menu/ingame/pause_menu.tscn" id="5"]
[ext_resource type="Script" path="res://menu/debug.gd" id="6"]
[ext_resource type="Theme" path="res://menu/theme/theme.tres" id="7"]
[sub_resource type="ProceduralSkyMaterial" id="ProceduralSkyMaterial_rhfg5"]
sky_horizon_color = Color(0.64625, 0.65575, 0.67075, 1)
ground_horizon_color = Color(0.64625, 0.65575, 0.67075, 1)
[sub_resource type="Sky" id="Sky_iri27"]
sky_material = SubResource( "ProceduralSkyMaterial_rhfg5" )
[sub_resource type="Environment" id="Environment_cs0j5"]
background_mode = 2
sky = SubResource( "Sky_iri27" )
tonemap_mode = 2
glow_enabled = true
fog_enabled = true
fog_aerial_perspective = 0.5
[node name="World3D" type="Node3D"]
[node name="Player" parent="." instance=ExtResource( 1 )]
[node name="Player" parent="." instance=ExtResource( "1" )]
[node name="Debug" type="Label" parent="."]
visible = false
@@ -19,20 +33,25 @@ anchor_bottom = 1.0
offset_left = 20.0
offset_right = -20.0
offset_bottom = -20.0
theme = ExtResource( 7 )
script = ExtResource( 6 )
theme = ExtResource( "7" )
theme_override_font_sizes/font_size = 48
script = ExtResource( "6" )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="PauseMenu" parent="." instance=ExtResource( 5 )]
[node name="PauseMenu" parent="." instance=ExtResource( "5" )]
[node name="VoxelWorld" type="Node" parent="."]
script = ExtResource( 2 )
script = ExtResource( "2" )
[node name="Environment" type="WorldEnvironment" parent="."]
environment = ExtResource( 3 )
script = ExtResource( 4 )
environment = SubResource( "Environment_cs0j5" )
script = ExtResource( "4" )
[node name="Sun" type="DirectionalLight3D" parent="Environment"]
transform = Transform3D(0.173648, -0.564863, 0.806707, 0, 0.819152, 0.573576, -0.984808, -0.0996005, 0.142244, 0, 0, 0)
transform = Transform3D(-0.866025, -0.433013, 0.25, 0, 0.5, 0.866026, -0.5, 0.75, -0.433013, 0, 0, 0)
shadow_enabled = true
directional_shadow_max_distance = 250.0
[node name="MeshInstance3D" type="MeshInstance3D" parent="."]