Godot Version
v4.4
Question
Meshinstances have a surface override property which allows you to swap in a different material at runtime. Is it possible to do the same for particles or is a separate resource or node required?
Currently I’m using a solid albedo colour that changes depending on a couple of other variables to set the colour of MeshInstances:
var clr:Array=(colour_defaults[num] if colour_use_defaults else colour)
for thing in visibles:
var targ_clr
thing.set_surface_override_material(0,thing.mesh.material.duplicate())
targ_clr = thing.get_surface_override_material(0).albedo_color
for rgb in 3: targ_clr[rgb]=clr[rgb]
thing.get_surface_override_material(0).albedo_color = targ_clr
The closest I’ve gotten with GPUParticles is this, which changes it for every instance in the scene:
var clr:Array=(colour_defaults[num] if colour_use_defaults else colour)
for thing in visibles:
var targ_clr
if thing is MeshInstance3D:
thing.set_surface_override_material(0,thing.mesh.material.duplicate())
targ_clr = thing.get_surface_override_material(0).albedo_color
elif thing is GPUParticles3D:
targ_clr = thing.draw_pass_1.material.albedo_color
else: break
for rgb in 3: targ_clr[rgb]=clr[rgb]
if thing is MeshInstance3D: thing.get_surface_override_material(0).albedo_color = targ_clr
elif thing is GPUParticles3D: thing.draw_pass_1.material.albedo_color = targ_clr