You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-12-04 17:04:49 +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:
@@ -2222,6 +2222,27 @@ void RasterizerSceneGLES3::_add_geometry(RasterizerStorageGLES3::Geometry *p_geo
|
||||
}
|
||||
_add_geometry_with_material(p_geometry, p_instance, p_owner, m, p_depth_pass, p_shadow_pass);
|
||||
}
|
||||
|
||||
// Repeat the "nested chain" logic also for the overlay
|
||||
if (p_instance->material_overlay.is_valid()) {
|
||||
m = storage->material_owner.getornull(p_instance->material_overlay);
|
||||
|
||||
if (!m || !m->shader || !m->shader->valid) {
|
||||
return;
|
||||
}
|
||||
|
||||
_add_geometry_with_material(p_geometry, p_instance, p_owner, m, p_depth_pass, p_shadow_pass);
|
||||
|
||||
while (m->next_pass.is_valid()) {
|
||||
m = storage->material_owner.getornull(m->next_pass);
|
||||
|
||||
if (!m || !m->shader || !m->shader->valid) {
|
||||
break;
|
||||
}
|
||||
|
||||
_add_geometry_with_material(p_geometry, p_instance, p_owner, m, p_depth_pass, p_shadow_pass);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void RasterizerSceneGLES3::_add_geometry_with_material(RasterizerStorageGLES3::Geometry *p_geometry, InstanceBase *p_instance, RasterizerStorageGLES3::GeometryOwner *p_owner, RasterizerStorageGLES3::Material *p_material, bool p_depth_pass, bool p_shadow_pass) {
|
||||
|
||||
Reference in New Issue
Block a user