Adds bushes and flowers to ground tiles

Implements bush and flower spawning on ground tiles based on vegetation density.
Adds new assets for bushes and flowers, and introduces multi-mesh rendering for optimized performance.
Introduces seasonal color variations for vegetation using a shader for bushes and materials for flowers and grass.
Refactors material application into a MaterialManager to handle material assignments over multiple frames.
Moves ground tile scripts into a subfolder.
Adds floating particles to test scene.
This commit is contained in:
Dan Baker 2025-06-29 10:58:18 +01:00
parent ea5006e8a2
commit 3959333534
46 changed files with 559 additions and 77 deletions

View file

@ -1,10 +1,11 @@
[gd_scene load_steps=45 format=4 uid="uid://bwsugg4p50fjr"]
[gd_scene load_steps=46 format=4 uid="uid://bwsugg4p50fjr"]
[ext_resource type="Environment" uid="uid://cm77bbr0io118" path="res://Stages/Test3D/new_environment.tres" id="1_8ph61"]
[ext_resource type="Script" uid="uid://bwed2dwogfmxv" path="res://Entities/Player/scripts/player.gd" id="1_d602n"]
[ext_resource type="AnimationLibrary" uid="uid://bwnn7vpd0dqds" path="res://Common/animations/basic-movement.res" id="1_tfa5t"]
[ext_resource type="Script" uid="uid://bbjv6a7yg7m02" path="res://Stages/Test3D/camera_pivot.gd" id="2_sdmks"]
[ext_resource type="Shader" uid="uid://bsemnmdracd4m" path="res://Common/shaders/outline.gdshader" id="4_feu7y"]
[ext_resource type="Script" uid="uid://bjco8musjqog4" path="res://Stages/Test3D/particles.gd" id="9_oiyue"]
[ext_resource type="Texture2D" uid="uid://c78jcjh8fjndd" path="res://Stages/Test3D/assets/3d/particles/flamelet_smooth.png" id="21_xvexm"]
[ext_resource type="Script" uid="uid://dglvt140rhg00" path="res://Stages/Test3D/omni_light_3d.gd" id="22_ukp6m"]
[ext_resource type="PackedScene" uid="uid://mdxkaqaoybjv" path="res://Stages/Test3D/assets/tent-canvas.glb" id="23_5r2bu"]
@ -737,11 +738,11 @@ transform = Transform3D(0.707107, -0.408607, 0.577096, 0, 0.816138, 0.577857, -0
script = ExtResource("2_sdmks")
[node name="Camera3D" type="Camera3D" parent="SubViewportContainer/SubViewport/Player/CameraPivot"]
transform = Transform3D(1, 0, 0, 0, 1, -1.49012e-07, 0, 1.19209e-07, 1, 0.0410548, 0.237644, 3.45114)
transform = Transform3D(1, 0, 0, 0, 1, 1.78814e-07, 0, -3.27826e-07, 1, 0, 0, 7)
projection = 1
current = true
size = 3.0
near = 0.005
near = 0.001
far = 100.0
[node name="PostProcessing" type="MeshInstance3D" parent="SubViewportContainer/SubViewport/Player/CameraPivot/Camera3D"]
@ -759,10 +760,10 @@ mesh = SubResource("QuadMesh_tfa5t")
shape = SubResource("BoxShape3D_tfa5t")
[node name="VFX" type="Node3D" parent="SubViewportContainer/SubViewport"]
visible = false
[node name="Fire" type="GPUParticles3D" parent="SubViewportContainer/SubViewport/VFX"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 1.08083, 0.0837402, 0.501403)
visible = false
amount = 50
lifetime = 0.4
speed_scale = 0.4
@ -772,7 +773,7 @@ draw_pass_1 = SubResource("QuadMesh_hvb1l")
[node name="OmniLight3D" type="OmniLight3D" parent="SubViewportContainer/SubViewport/VFX/Fire"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.000509977, 0.121094, -0.00151992)
light_color = Color(0.89, 0.461613, 0.2136, 1)
light_energy = 0.802091
light_energy = 0.590552
light_indirect_energy = 1.084
light_volumetric_fog_energy = 3.764
light_size = 0.105
@ -794,6 +795,9 @@ trail_lifetime = 0.1
process_material = SubResource("ParticleProcessMaterial_p5fn2")
draw_pass_1 = SubResource("RibbonTrailMesh_5r2bu")
[node name="FloatingParticles" type="GPUParticles3D" parent="SubViewportContainer/SubViewport/VFX"]
script = ExtResource("9_oiyue")
[node name="TileGround" type="Node3D" parent="SubViewportContainer/SubViewport"]
unique_name_in_owner = true
script = ExtResource("24_vyi1v")

View file

@ -2,7 +2,6 @@
[sub_resource type="ProceduralSkyMaterial" id="ProceduralSkyMaterial_lg8b7"]
sky_horizon_color = Color(0.67451, 0.682353, 0.698039, 1)
sky_curve = 0.0175
ground_bottom_color = Color(1, 1, 1, 1)
ground_curve = 0.171484
@ -10,7 +9,7 @@ ground_curve = 0.171484
sky_material = SubResource("ProceduralSkyMaterial_lg8b7")
[resource]
background_mode = 1
background_mode = 2
background_color = Color(0.752941, 0.776471, 0.827451, 1)
sky = SubResource("Sky_7bk1c")
ambient_light_source = 2
@ -18,12 +17,12 @@ ambient_light_color = Color(0.662745, 0.694118, 0.772549, 1)
ambient_light_energy = 0.5
reflected_light_source = 2
tonemap_mode = 2
ssao_enabled = true
ssao_radius = 0.3
ssao_intensity = 0.5
ssao_power = 15.0
ssil_enabled = true
sdfgi_use_occlusion = true
glow_levels/2 = 0.6
glow_levels/3 = 0.6
glow_levels/5 = 0.0
glow_intensity = 2.0
fog_density = 0.0635
volumetric_fog_emission = Color(0.821925, 0.333878, 0.419207, 1)
volumetric_fog_ambient_inject = 16.0

View file

@ -0,0 +1,79 @@
extends GPUParticles3D
@onready var player: Node3D = get_node("%Player")
var last_player_position: Vector3
var update_distance: float = 1
func _ready():
setup_floating_particles()
func _process(delta):
if player:
var current_player_pos = player.global_position
var target_pos = Vector3(
current_player_pos.x,
1.0,
current_player_pos.z
)
global_position = global_position.lerp(target_pos, delta * 3.0)
func setup_floating_particles():
# Basic particle setup
emitting = true
amount = 100
lifetime = 8.0
visibility_aabb = AABB(Vector3(-20, 0, -20), Vector3(40, 10, 40))
# Create material
var material = ParticleProcessMaterial.new()
# Emission
material.emission_shape = ParticleProcessMaterial.EMISSION_SHAPE_BOX
material.emission_box_extents = Vector3(5, 2, 5)
# Movement
material.direction = Vector3(0.1, 0.8, 0.1)
material.initial_velocity_min = 0.2
material.initial_velocity_max = 0.8
material.gravity = Vector3(0, -0.3, 0)
# Floating motion
material.orbit_velocity_min = 0.1
material.orbit_velocity_max = 0.3
material.radial_velocity_min = -0.2
material.radial_velocity_max = 0.2
# Size and fade
material.scale_min = 0.01
material.scale_max = 0.03
material.scale_over_velocity_min = 0.0
material.scale_over_velocity_max = 2.0
# Color (golden dust particles)
var gradient = Gradient.new()
gradient.add_point(0.0, Color(1.0, 0.9, 0.6, 0.0)) # Fade in
gradient.add_point(0.2, Color(1.0, 0.9, 0.6, 0.5)) # Full opacity
gradient.add_point(0.8, Color(1.0, 0.8, 0.4, 0.3)) # Slight color shift
gradient.add_point(1.0, Color(1.0, 0.7, 0.3, 0.0)) # Fade out
var gradient_texture = GradientTexture1D.new()
gradient_texture.gradient = gradient
material.color_ramp = gradient_texture
# Assign the material to the particle system
process_material = material
# Create and assign visual mesh (small billboard)
var quad_mesh = QuadMesh.new()
quad_mesh.size = Vector2(0.01, 0.01)
draw_pass_1 = quad_mesh
# Create a basic material for the particles to be visible
var particle_material = StandardMaterial3D.new()
particle_material.albedo_color = ColorData.grass_materials[Season.current]['top']
particle_material.flags_transparent = true
particle_material.flags_unshaded = true
particle_material.billboard_mode = BaseMaterial3D.BILLBOARD_ENABLED
material_override = particle_material

View file

@ -0,0 +1 @@
uid://bjco8musjqog4