• General Chat
  • What is simplest way to add a brief color over lay over a whole 3d textured model?

I want a character model to turn pink while in collision with another certain scene. I know who to change textures and colors on models with just one material- but how would I be able to do this on a model with many materials?

I was thinking of particles- but I dont know if particles can be clipped to match the shape of the model so only the model would be pink overlaid?

Thanks

You can temporarily assign the pink material to material_override property. If you need an animated transition, you'll have to add a second shader/material pass to all the assigned materials and fade its transparency in and out.

@xyz said: You can temporarily assign the pink material to material_override property. If you need an animated transition, you'll have to add a second shader/material pass to all the assigned materials and fade its transparency in and out.

So you leave the original materials alone, then assign / delete the material in material override as needed? And the orginal materials will still be in place?

Yes. They are different properties and material_override just, well, overrides the materials in the rendering process :)

You can also change the albedo color. If you use a texture, usually the albedo is white, so it just uses the texture color. But if you set it to a whitish pink it will tint the material. You should be able to do this in real time and animate but I haven't tried it.

When I try and assign the material override this is the error I get:

Invalid set index 'material_overide' (on base: 'MeshInstance') with value of type 'SpatialMaterial'.

$obj_0004.material_overide=Global.pink_material

In Global script var pink_material=preload("res://materials/pinkoverlay.tres")

Changing the albedo is going to be easier and I believe faster, since it doesn't have to switch materials.

var mesh_obj = get_node("YourMesh")
var mesh_mat = mesh_obj.get_surface_material(0)
mesh_mat.albedo_color = Color.red

I found it I was mispelling "override"

this works:

$obj_0004.material_override=Global.pink_material

@cybereality said: Changing the albedo is going to be easier and I believe faster, since it doesn't have to switch materials.

var mesh_obj = get_node("YourMesh")
var mesh_mat = mesh_obj.get_surface_material(0)
mesh_mat.albedo_color = Color.red

Wouldnt that change all instances?

I see my code also changed all instances.

I figured it out. I needed to get the instance.get_node("mymesh") before I could access materials

My preferred way of doing it would be assigning the same second pass material to all mesh materials (via gui), make that material local to scene, and then set or animate this material's transparency as needed

@xyz said: My preferred way of doing it would be assigning the same second pass material to all mesh materials (via gui), make that material local to scene, and then set or animate this material's transparency as needed

I will have to research that method too. :)