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:
parent
ea5006e8a2
commit
3959333534
46 changed files with 559 additions and 77 deletions
30
Utilities/MaterialManager/MaterialManager.gd
Normal file
30
Utilities/MaterialManager/MaterialManager.gd
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
class_name MaterialManagerClass
|
||||
extends Node
|
||||
|
||||
var material_application_queue: Array = []
|
||||
var max_materials_per_frame: int = 20 # Adjust based on performance
|
||||
|
||||
func _process(_delta):
|
||||
# Process material applications gradually over multiple frames
|
||||
process_material_queue()
|
||||
|
||||
func process_material_queue():
|
||||
var processed = 0
|
||||
while material_application_queue.size() > 0 and processed < max_materials_per_frame:
|
||||
var task = material_application_queue.pop_front()
|
||||
|
||||
if is_instance_valid(task.mesh_instance) and task.mesh_instance != null:
|
||||
apply_material_immediately(task.mesh_instance, task.surface_index, task.material)
|
||||
|
||||
processed += 1
|
||||
|
||||
func queue_material_application(mesh_instance: MeshInstance3D, surface_index: int, material: StandardMaterial3D):
|
||||
material_application_queue.append({
|
||||
"mesh_instance": mesh_instance,
|
||||
"surface_index": surface_index,
|
||||
"material": material
|
||||
})
|
||||
|
||||
func apply_material_immediately(mesh_instance: MeshInstance3D, surface_index: int, material: StandardMaterial3D):
|
||||
if is_instance_valid(mesh_instance):
|
||||
mesh_instance.set_surface_override_material(surface_index, material)
|
||||
Loading…
Add table
Add a link
Reference in a new issue