diff --git a/modules/openxr/scene/openxr_composition_layer.cpp b/modules/openxr/scene/openxr_composition_layer.cpp index 64dbfb35185b..770d97cee1e7 100644 --- a/modules/openxr/scene/openxr_composition_layer.cpp +++ b/modules/openxr/scene/openxr_composition_layer.cpp @@ -85,6 +85,7 @@ OpenXRCompositionLayer::~OpenXRCompositionLayer() { composition_layer_nodes.erase(this); if (openxr_layer_provider != nullptr) { + _clear_composition_layer_provider(); memdelete(openxr_layer_provider); openxr_layer_provider = nullptr; } @@ -374,16 +375,7 @@ void OpenXRCompositionLayer::_reset_fallback_material() { material->set_flag(StandardMaterial3D::FLAG_DISABLE_DEPTH_TEST, !enable_hole_punch); material->set_transparency(get_alpha_blend() ? StandardMaterial3D::TRANSPARENCY_ALPHA : StandardMaterial3D::TRANSPARENCY_DISABLED); - - Ref texture = material->get_texture(StandardMaterial3D::TEXTURE_ALBEDO); - if (texture.is_null()) { - texture = layer_viewport->get_texture(); - } - - Node *loc_scene = texture->get_local_scene(); - NodePath viewport_path = loc_scene->get_path_to(layer_viewport); - texture->set_viewport_path_in_scene(viewport_path); - material->set_texture(StandardMaterial3D::TEXTURE_ALBEDO, texture); + material->set_texture(StandardMaterial3D::TEXTURE_ALBEDO, layer_viewport->get_texture()); } else { fallback->set_surface_override_material(0, Ref()); }