level building tool good enough for first cave draft

This commit is contained in:
2026-02-06 02:17:33 +11:00
parent 126c2fd72d
commit 2bacff5b7d
15 changed files with 483 additions and 51 deletions

View File

@@ -6,17 +6,212 @@
[ext_resource type="PackedScene" uid="uid://bhroqr4s1qso5" path="res://Worlds/GreenPlanet/Levels/Cave/cave_level.glb" id="4_x53u6"]
[ext_resource type="Script" uid="uid://dkuxg6ek5us4f" path="res://Scripts/enemy_spawner.gd" id="5_e8b6i"]
[ext_resource type="Script" uid="uid://cxwtuxytavfu5" path="res://Scripts/enemy_goal.gd" id="6_n26ay"]
[ext_resource type="AudioStream" uid="uid://dknygn5eyuhxt" path="res://Audio/shot1.wav" id="7_e8b6i"]
[ext_resource type="PackedScene" uid="uid://1b2ikdanl66b" path="res://Scenes/CardPrinter/card_printer.tscn" id="7_y5pxn"]
[ext_resource type="PackedScene" uid="uid://7g3jev3v6d3l" path="res://Scenes/ShopStand/shop_stand.tscn" id="8_x53u6"]
[ext_resource type="Script" uid="uid://yk54owkf7pgj" path="res://Scripts/cinema_cam.gd" id="9_x53u6"]
[node name="Node3D" type="Node3D" unique_id=1915460305 node_paths=PackedStringArray("tower_path", "player_spawns", "enemy_spawns", "enemy_goals", "corpses", "printer", "shop")]
[sub_resource type="SphereShape3D" id="SphereShape3D_x53u6"]
radius = 4.5510416
[sub_resource type="Shader" id="Shader_6od8s"]
code = "shader_type sky;
render_mode use_debanding;
uniform vec4 sky_top_color : source_color = vec4(0.385, 0.454, 0.55, 1.0);
uniform vec4 sky_horizon_color : source_color = vec4(0.646, 0.656, 0.67, 1.0);
uniform float sky_curve : hint_range(0, 1) = 0.15;
uniform float sky_energy = 1.0; // In Lux.
uniform sampler2D sky_cover : filter_linear, source_color, hint_default_black;
uniform vec4 sky_cover_modulate : source_color = vec4(1.0, 1.0, 1.0, 1.0);
uniform vec4 ground_bottom_color : source_color = vec4(0.2, 0.169, 0.133, 1.0);
uniform vec4 ground_horizon_color : source_color = vec4(0.646, 0.656, 0.67, 1.0);
uniform float ground_curve : hint_range(0, 1) = 0.02;
uniform float ground_energy = 1.0;
uniform float sun_angle_max = 30.0;
uniform float sun_curve : hint_range(0, 1) = 0.15;
uniform float exposure : hint_range(0, 128) = 1.0;
// Wind offset direction (x and y only)
uniform vec2 wind_offset_direction = vec2(0.5, 0.1); // Control direction of offset (x, y)
uniform float wind_speed : hint_range(0.0, 25.0) = 1.0; // Speed of the noise movement over time
// Cloud change settings
uniform bool clouds_change = true; // Whether to change the cloud layer or not
uniform float cloud_change_rate : hint_range(0.0, 5.0) = .40; // Rate at which the cloud effect changes
// Pole blending parameters
uniform float pole_blend_shape : hint_range(0.0, 2.0) = 0.05; // How much the noise affects the blend shape
uniform float pole_blend_strength : hint_range(0, 1) = 0.05; // Control blending intensity at poles
uniform float pole_blend_brightness : hint_range(0.0, 1.0) = .3;
// Horizon blending parameters - similar to pole blending
uniform float horizon_blend_shape : hint_range(0.0, 2.0) = 0.05; // How much the noise affects the horizon blend shape
uniform float horizon_blend_strength : hint_range(0, 1) = 0.05; // Control blending intensity at horizon
uniform float horizon_blend_brightness : hint_range(0.0, 1.0) = .3;
uniform float horizon_blend_width : hint_range(0.0, 0.5) = 0.1; // Width of the horizon blend region
void sky() {
float v_angle = acos(clamp(EYEDIR.y, -1.0, 1.0));
float c = (1.0 - v_angle / (PI * 0.5));
vec3 sky = mix(sky_horizon_color.rgb, sky_top_color.rgb, clamp(1.0 - pow(1.0 - c, 1.0 / sky_curve), 0.0, 1.0));
sky *= sky_energy;
if (LIGHT0_ENABLED) {
float sun_angle = acos(dot(LIGHT0_DIRECTION, EYEDIR));
if (sun_angle < LIGHT0_SIZE) {
sky = LIGHT0_COLOR * LIGHT0_ENERGY;
} else if (sun_angle < sun_angle_max) {
float c2 = (sun_angle - LIGHT0_SIZE) / (sun_angle_max - LIGHT0_SIZE);
sky = mix(LIGHT0_COLOR * LIGHT0_ENERGY, sky, clamp(1.0 - pow(1.0 - c2, 1.0 / sun_curve), 0.0, 1.0));
}
}
if (LIGHT1_ENABLED) {
float sun_angle = acos(dot(LIGHT1_DIRECTION, EYEDIR));
if (sun_angle < LIGHT1_SIZE) {
sky = LIGHT1_COLOR * LIGHT1_ENERGY;
} else if (sun_angle < sun_angle_max) {
float c2 = (sun_angle - LIGHT1_SIZE) / (sun_angle_max - LIGHT1_SIZE);
sky = mix(LIGHT1_COLOR * LIGHT1_ENERGY, sky, clamp(1.0 - pow(1.0 - c2, 1.0 / sun_curve), 0.0, 1.0));
}
}
if (LIGHT2_ENABLED) {
float sun_angle = acos(dot(LIGHT2_DIRECTION, EYEDIR));
if (sun_angle < LIGHT2_SIZE) {
sky = LIGHT2_COLOR * LIGHT2_ENERGY;
} else if (sun_angle < sun_angle_max) {
float c2 = (sun_angle - LIGHT2_SIZE) / (sun_angle_max - LIGHT2_SIZE);
sky = mix(LIGHT2_COLOR * LIGHT2_ENERGY, sky, clamp(1.0 - pow(1.0 - c2, 1.0 / sun_curve), 0.0, 1.0));
}
}
if (LIGHT3_ENABLED) {
float sun_angle = acos(dot(LIGHT3_DIRECTION, EYEDIR));
if (sun_angle < LIGHT3_SIZE) {
sky = LIGHT3_COLOR * LIGHT3_ENERGY;
} else if (sun_angle < sun_angle_max) {
float c2 = (sun_angle - LIGHT3_SIZE) / (sun_angle_max - LIGHT3_SIZE);
sky = mix(LIGHT3_COLOR * LIGHT3_ENERGY, sky, clamp(1.0 - pow(1.0 - c2, 1.0 / sun_curve), 0.0, 1.0));
}
}
// Sample the sky cover texture with dynamic offset (only x and y direction)
vec2 noise_coords = SKY_COORDS.xy + wind_offset_direction * wind_speed * TIME * 0.01;
// Wrap UVs to keep tiling seamless
noise_coords = mod(noise_coords, 1.0);
// Sample the original noise texture
vec4 sky_cover_texture = texture(sky_cover, noise_coords);
// Sample flipped noise for Z-offset effect
vec4 flipped_noise = texture(sky_cover, vec2(noise_coords.x, 1.0 - noise_coords.y));
// Z blending (cloud change) logic
float cloud_blend_factor = 0.0;
if (clouds_change) {
// Use a sine wave to blend clouds smoothly over time based on the cloud_change_rate
cloud_blend_factor = 0.5 + 0.5 * sin(TIME * cloud_change_rate);
}
// Blend between the original and flipped noise using cloud_blend_factor
vec4 blended_noise_texture = mix(sky_cover_texture, flipped_noise, cloud_blend_factor);
// Pole blending
float base_pole_blend_factor = abs(EYEDIR.y); // Original blend factor (circular)
float noise_pole_blend = blended_noise_texture.r * pole_blend_shape;
float pole_blend_factor = smoothstep(1.0 - pole_blend_strength, 1.0, base_pole_blend_factor + noise_pole_blend);
// Horizon blending - detect when we're near the horizon
float horizon_distance = abs(EYEDIR.y); // This will be close to 0 near the horizon
float horizon_factor = 1.0 - smoothstep(0.0, horizon_blend_width, horizon_distance);
float noise_horizon_blend = blended_noise_texture.g * horizon_blend_shape;
float horizon_blend_factor = smoothstep(1.0 - horizon_blend_strength, 1.0, horizon_factor + noise_horizon_blend);
// Combine both blend factors (poles and horizon)
float combined_blend_factor = max(pole_blend_factor, horizon_blend_factor);
// Blend noise with brightness value based on the combined factor
vec3 blended_noise = mix(blended_noise_texture.rgb, vec3(pole_blend_brightness), pole_blend_factor);
blended_noise = mix(blended_noise, vec3(horizon_blend_brightness), horizon_blend_factor);
sky += (blended_noise * sky_cover_modulate.rgb) * blended_noise_texture.a * sky_cover_modulate.a * sky_energy;
// Ground blending
c = (v_angle - (PI * 0.5)) / (PI * 0.5);
vec3 ground = mix(ground_horizon_color.rgb, ground_bottom_color.rgb, clamp(1.0 - pow(1.0 - c, 1.0 / ground_curve), 0.0, 1.0));
ground *= ground_energy;
COLOR = mix(ground, sky, step(0.0, EYEDIR.y)) * exposure;
}"
[sub_resource type="Gradient" id="Gradient_e8b6i"]
offsets = PackedFloat32Array(0.151786, 0.5625, 1)
colors = PackedColorArray(0, 0, 0, 1, 0.565217, 0.565217, 0.565217, 1, 1, 1, 1, 1)
[sub_resource type="FastNoiseLite" id="FastNoiseLite_n26ay"]
noise_type = 3
domain_warp_enabled = true
[sub_resource type="NoiseTexture2D" id="NoiseTexture2D_r4es0"]
width = 1024
height = 1024
noise = SubResource("FastNoiseLite_n26ay")
color_ramp = SubResource("Gradient_e8b6i")
seamless = true
[sub_resource type="ShaderMaterial" id="ShaderMaterial_gow2y"]
shader = SubResource("Shader_6od8s")
shader_parameter/sky_top_color = Color(0.25262, 0.408375, 0.692798, 1)
shader_parameter/sky_horizon_color = Color(0.48476, 0.638261, 0.884351, 1)
shader_parameter/sky_curve = 0.0349887
shader_parameter/sky_energy = 1.0
shader_parameter/sky_cover = SubResource("NoiseTexture2D_r4es0")
shader_parameter/sky_cover_modulate = Color(1, 1, 1, 1)
shader_parameter/ground_bottom_color = Color(0.121409, 0.203944, 0.437026, 1)
shader_parameter/ground_horizon_color = Color(0.486275, 0.639216, 0.882353, 1)
shader_parameter/ground_curve = 0.02
shader_parameter/ground_energy = 1.0
shader_parameter/sun_angle_max = 0.523599
shader_parameter/sun_curve = 0.15
shader_parameter/exposure = 1.0
shader_parameter/wind_offset_direction = Vector2(0.5, 0.1)
shader_parameter/wind_speed = 0.0
shader_parameter/clouds_change = true
shader_parameter/cloud_change_rate = 0.4
shader_parameter/pole_blend_shape = 0.05
shader_parameter/pole_blend_strength = 0.05
shader_parameter/pole_blend_brightness = 0.3
shader_parameter/horizon_blend_shape = 0.05
shader_parameter/horizon_blend_strength = 0.05
shader_parameter/horizon_blend_brightness = 0.3
shader_parameter/horizon_blend_width = 0.1
[sub_resource type="Sky" id="Sky_t42h5"]
sky_material = SubResource("ShaderMaterial_gow2y")
[sub_resource type="Environment" id="Environment_y23i6"]
background_mode = 2
sky = SubResource("Sky_t42h5")
tonemap_mode = 4
ssao_detail = 0.0
fog_enabled = true
fog_mode = 1
fog_density = 1.0
fog_depth_begin = 50.0
fog_depth_end = 200.0
[node name="Node3D" type="Node3D" unique_id=1915460305 node_paths=PackedStringArray("tower_path", "player_spawns", "enemy_spawns", "enemy_goals", "corpses", "cinematic_cam", "printer", "shop")]
script = ExtResource("1_li03l")
enemy_pool = Array[ExtResource("2_1sih4")]([ExtResource("3_y5pxn")])
tower_path = NodePath("Parents/Towers")
player_spawns = [NodePath("PlayerSpawn")]
enemy_spawns = [NodePath("EnemySpawner")]
enemy_spawns = [NodePath("EnemySpawner"), NodePath("EnemySpawner2"), NodePath("EnemySpawner3")]
enemy_goals = [NodePath("EnemyGoal")]
corpses = NodePath("Parents/Corpses")
cinematic_cam = NodePath("CinematicCamManager")
printer = NodePath("CardPrinter")
shop = NodePath("ShopStand")
metadata/_custom_type_script = "uid://cvejbo3srx8py"
@@ -32,18 +227,61 @@ metadata/_custom_type_script = "uid://cvejbo3srx8py"
[node name="PlayerSpawn" type="Node3D" parent="." unique_id=2082895124]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.7781315, 0)
[node name="EnemySpawner" type="Node3D" parent="." unique_id=1276116196]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.93684864, -30.9888)
[node name="EnemySpawner" type="Node3D" parent="." unique_id=1276116196 node_paths=PackedStringArray("enemy_path")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.40332747, -70.750275)
script = ExtResource("5_e8b6i")
type = 1
enemy_path = NodePath("../Node")
metadata/_custom_type_script = "uid://dkuxg6ek5us4f"
[node name="EnemyGoal" type="Node3D" parent="." unique_id=1902271599]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.93684864, -11.24234)
[node name="EnemySpawner2" type="Node3D" parent="." unique_id=422958724 node_paths=PackedStringArray("enemy_path")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -43.008965, -0.40332747, -48.143326)
script = ExtResource("5_e8b6i")
type = 1
enemy_path = NodePath("../Node")
metadata/_custom_type_script = "uid://dkuxg6ek5us4f"
[node name="EnemySpawner3" type="Node3D" parent="." unique_id=2111262624 node_paths=PackedStringArray("enemy_path")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 33.049927, 3.8600483, -66.462)
script = ExtResource("5_e8b6i")
type = 1
enemy_path = NodePath("../Node")
metadata/_custom_type_script = "uid://dkuxg6ek5us4f"
[node name="EnemyGoal" type="Node3D" parent="." unique_id=1902271599 node_paths=PackedStringArray("audio_player")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.7545819, 0.21650457, 3.3273573)
script = ExtResource("6_n26ay")
audio_player = NodePath("AudioStreamPlayer3D")
metadata/_custom_type_script = "uid://cxwtuxytavfu5"
[node name="Area3D" type="Area3D" parent="EnemyGoal" unique_id=598009303]
collision_mask = 4
[node name="CollisionShape3D" type="CollisionShape3D" parent="EnemyGoal/Area3D" unique_id=1884514185]
shape = SubResource("SphereShape3D_x53u6")
[node name="AudioStreamPlayer3D" type="AudioStreamPlayer3D" parent="EnemyGoal" unique_id=1013833370]
stream = ExtResource("7_e8b6i")
[node name="CardPrinter" parent="." unique_id=459800869 instance=ExtResource("7_y5pxn")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -4.507948, 0.03549701, 5.868264)
[node name="ShopStand" parent="." unique_id=1287436541 instance=ExtResource("8_x53u6")]
transform = Transform3D(-1, 0, 6.976922e-05, 0, 1, 0, -6.976922e-05, 0, -1, 4.381688, 0.5, 7.0162544)
[node name="CinematicCamManager" type="Node3D" parent="." unique_id=1005738879 node_paths=PackedStringArray("path_follows", "cameras")]
script = ExtResource("9_x53u6")
path_follows = [NodePath("PathFollow3D")]
cameras = [NodePath("Camera3D")]
metadata/_custom_type_script = "uid://yk54owkf7pgj"
[node name="Camera3D" type="Camera3D" parent="CinematicCamManager" unique_id=63929698]
[node name="PathFollow3D" type="PathFollow3D" parent="CinematicCamManager" unique_id=1152081903]
[node name="Node" type="Node" parent="." unique_id=1123170520]
[node name="WorldEnvironment" type="WorldEnvironment" parent="." unique_id=624876315]
environment = SubResource("Environment_y23i6")
[connection signal="body_entered" from="EnemyGoal/Area3D" to="EnemyGoal" method="_on_area_3d_body_entered"]