You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-14 13:41:12 +00:00
Added material_overlay property to MeshInstance
Applying overlay materials into multi-surface meshes currently requires adding a next pass material to all the surfaces, which might be cumbersome when the material is to be applied to a range of different geometries. This also makes it not trivial to use AnimationPlayer to control the material in case of visual effects. The material_override property is not an option as it works replacing the active material for the surfaces, not adding a new pass. This commit adds the material_overlay property to GeometryInstance (and therefore MeshInstance), having the same reach as material_override (that is, all surfaces) but adding a new material pass on top of the active materials, instead of replacing them. Implemented in rasterizer of both GLES2 and GLES3.
This commit is contained in:
@@ -733,6 +733,14 @@ void MeshInstance::set_material_override(const Ref<Material> &p_material) {
|
||||
}
|
||||
}
|
||||
|
||||
void MeshInstance::set_material_overlay(const Ref<Material> &p_material) {
|
||||
if (p_material == get_material_overlay()) {
|
||||
return;
|
||||
}
|
||||
|
||||
GeometryInstance::set_material_overlay(p_material);
|
||||
}
|
||||
|
||||
void MeshInstance::set_software_skinning_transform_normals(bool p_enabled) {
|
||||
if (p_enabled == is_software_skinning_transform_normals_enabled()) {
|
||||
return;
|
||||
@@ -852,6 +860,11 @@ bool MeshInstance::is_mergeable_with(const MeshInstance &p_other) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// overlay materials must match
|
||||
if (get_material_overlay() != p_other.get_material_overlay()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (int n = 0; n < num_surfaces; n++) {
|
||||
// materials must match
|
||||
if (get_active_material(n) != p_other.get_active_material(n)) {
|
||||
@@ -1154,6 +1167,9 @@ bool MeshInstance::create_by_merging(Vector<MeshInstance *> p_list) {
|
||||
set_surface_material(n, first->get_active_material(n));
|
||||
}
|
||||
|
||||
// set overlay material
|
||||
set_material_overlay(first->get_material_overlay());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user