Skip to content

Commit

Permalink
Update demo: Load Sky3D if present. Normalize player input movement
Browse files Browse the repository at this point in the history
  • Loading branch information
TokisanGames committed Jan 10, 2025
1 parent 8c241c1 commit ef638de
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 18 deletions.
11 changes: 9 additions & 2 deletions project/demo/NavigationDemo.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -38,22 +38,29 @@ _shader_parameters = {
"auto_height_reduction": 0.1,
"auto_overlay_texture": 1,
"auto_slope": 1.0,
"bias_distance": 512.0,
"blend_sharpness": 0.87,
"depth_blur": 0.0,
"dual_scale_far": 170.0,
"dual_scale_near": 100.0,
"dual_scale_reduction": 0.3,
"dual_scale_texture": 0,
"enable_macro_variation": true,
"enable_projection": true,
"height_blending": true,
"macro_variation1": Color(0.878431, 0.862745, 0.901961, 1),
"macro_variation2": Color(0.898039, 0.898039, 0.803922, 1),
"macro_variation_slope": 0.333,
"mipmap_bias": 1.0,
"noise1_angle": 0.1,
"noise1_offset": Vector2(0.5, 0.5),
"noise1_scale": 0.04,
"noise2_scale": 0.076,
"noise3_scale": 0.225,
"noise_texture": SubResource("NoiseTexture2D_bov7h"),
"tri_scale_reduction": 0.3,
"vertex_normals_distance": 128.0
"projection_angular_division": 1.436,
"projection_threshold": 0.8,
"tri_scale_reduction": 0.3
}
world_background = 0
auto_shader = true
Expand Down
45 changes: 31 additions & 14 deletions project/demo/components/DemoBase.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
[ext_resource type="PackedScene" uid="uid://d2jihfohphuue" path="res://demo/components/UI.tscn" id="4_gk532"]
[ext_resource type="Terrain3DAssets" uid="uid://dal3jhw6241qg" path="res://demo/data/assets.tres" id="7_mnexy"]

[sub_resource type="Gradient" id="Gradient_vs32v"]
offsets = PackedFloat32Array(0.3, 1)
[sub_resource type="Gradient" id="Gradient_f1plm"]
offsets = PackedFloat32Array(0.2, 1)
colors = PackedColorArray(1, 1, 1, 1, 0, 0, 0, 1)

[sub_resource type="FastNoiseLite" id="FastNoiseLite_7glc1"]
[sub_resource type="FastNoiseLite" id="FastNoiseLite_bfcw0"]
noise_type = 2
frequency = 0.03
cellular_jitter = 3.0
Expand All @@ -23,26 +23,43 @@ domain_warp_fractal_type = 2
domain_warp_fractal_lacunarity = 1.5
domain_warp_fractal_gain = 1.0

[sub_resource type="NoiseTexture2D" id="NoiseTexture2D_pvx8q"]
[sub_resource type="NoiseTexture2D" id="NoiseTexture2D_quxx0"]
seamless = true
color_ramp = SubResource("Gradient_vs32v")
noise = SubResource("FastNoiseLite_7glc1")
color_ramp = SubResource("Gradient_f1plm")
noise = SubResource("FastNoiseLite_bfcw0")

[sub_resource type="Terrain3DMaterial" id="Terrain3DMaterial_q2wt2"]
[sub_resource type="Terrain3DMaterial" id="Terrain3DMaterial_klrp5"]
_shader_parameters = {
"_mouse_layer": 2147483648,
"auto_base_texture": 0,
"auto_height_reduction": 0.1,
"auto_overlay_texture": 1,
"auto_slope": 1.0,
"bias_distance": 512.0,
"blend_sharpness": 0.87,
"depth_blur": 0.0,
"dual_scale_far": 170.0,
"dual_scale_near": 100.0,
"dual_scale_reduction": 0.3,
"dual_scale_texture": 0,
"enable_macro_variation": true,
"enable_projection": true,
"height_blending": true,
"macro_variation1": Color(1, 1, 1, 1),
"macro_variation2": Color(1, 1, 1, 1),
"macro_variation_slope": 0.333,
"mipmap_bias": 1.0,
"noise1_angle": 0.0,
"noise1_offset": Vector2(0.5, 0.5),
"noise1_scale": 0.05,
"noise2_scale": 0.03,
"noise3_scale": 0.01,
"noise_texture": SubResource("NoiseTexture2D_pvx8q"),
"vertex_normals_distance": 128.0
"noise1_scale": 0.04,
"noise2_scale": 0.076,
"noise3_scale": 0.225,
"noise_texture": SubResource("NoiseTexture2D_quxx0"),
"projection_angular_division": 1.436,
"projection_threshold": 0.8,
"tri_scale_reduction": 0.3
}
auto_shader = true
dual_scaling = true

[node name="Demo" type="Node"]
script = ExtResource("1_k7qca")
Expand All @@ -59,7 +76,7 @@ transform = Transform3D(0.134125, 0, -0.990965, 0, 1, 0, 0.990965, 0, 0.134125,

[node name="Terrain3D" type="Terrain3D" parent="."]
data_directory = "res://demo/data"
material = SubResource("Terrain3DMaterial_q2wt2")
material = SubResource("Terrain3DMaterial_klrp5")
assets = ExtResource("7_mnexy")
collision_mask = 3
top_level = true
Expand Down
14 changes: 14 additions & 0 deletions project/demo/src/DemoScene.gd
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,17 @@ extends Node
func _ready():
if not Engine.is_editor_hint() and has_node("UI"):
$UI.player = $Player

# Load Sky3D into the demo environment if enabled
if Engine.is_editor_hint() and has_node("Environment") and \
Engine.get_singleton(&"EditorInterface").is_plugin_enabled("sky_3d"):
$Environment.queue_free()
var sky3d = load("res://addons/sky_3d/src/Sky3D.gd").new()
sky3d.name = "Sky3D"
add_child(sky3d, true)
move_child(sky3d, 1)
sky3d.owner = self
sky3d.current_time = 10
sky3d.enable_editor_time = false


4 changes: 2 additions & 2 deletions project/demo/src/Player.gd
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ extends CharacterBody3D

func _physics_process(p_delta) -> void:
var direction: Vector3 = get_camera_relative_input()
var h_veloc: Vector2 = Vector2(direction.x, direction.z) * MOVE_SPEED
var h_veloc: Vector2 = Vector2(direction.x, direction.z).normalized() * MOVE_SPEED
if Input.is_key_pressed(KEY_SHIFT):
h_veloc *= 2
velocity.x = h_veloc.x
Expand Down Expand Up @@ -57,7 +57,7 @@ func get_camera_relative_input() -> Vector3:
MOVE_SPEED = clamp(MOVE_SPEED + .5, 5, 9999)
if Input.is_key_pressed(KEY_KP_SUBTRACT) or Input.is_key_pressed(KEY_MINUS):
MOVE_SPEED = clamp(MOVE_SPEED - .5, 5, 9999)
return input_dir
return input_dir


func _input(p_event: InputEvent) -> void:
Expand Down

0 comments on commit ef638de

Please sign in to comment.