### Godot version

v4.1.dev.custom_build [18112ba36]

### System information

Linux Mint 21.1, NVIDIA GeForce GTX 1050 Ti,  Vulkan API 1.3.205

### Issue description

This is a regression from #64388. 

Textures seem to be used differently in 2D and 3D. They are rendered using the `RID` in 3D, and changing the `viewport_path` will cause the `RID` to change.

https://github.com/godotengine/godot/assets/30386067/ad393fe8-50c1-4a89-870d-58d4e224bcc6


### Steps to reproduce

1. Download and import MRP.
2. Open 1.tscn, and try to switch the `viewport_path` of the `MeshInstance3D:mesh:material:albedo_texture` in the MeshInstance3D node.
3. After switching, the MeshInstance3D is rendered as white in the editor;
4. Close and then reopen 1.tscn.

### Minimal reproduction project

[ViewportTexture-change-viewport_path.zip](https://github.com/godotengine/godot/files/11509010/ViewportTexture-change-viewport_path.zip)

contact_3d_debug_multimesh = RenderingServer::get_singleton()->multimesh_create();
				RenderingServer::get_singleton()->multimesh_allocate_data(contact_3d_debug_multimesh, get_tree()->get_collision_debug_contact_count(), RS::MULTIMESH_TRANSFORM_3D, false);
				RenderingServer::get_singleton()->multimesh_set_visible_instances(contact_3d_debug_multimesh, 0);
				RenderingServer::get_singleton()->multimesh_set_mesh(contact_3d_debug_multimesh, get_tree()->get_debug_contact_mesh()->get_rid());
				contact_3d_debug_instance = RenderingServer::get_singleton()->instance_create();
				RenderingServer::get_singleton()->instance_set_base(contact_3d_debug_instance, contact_3d_debug_multimesh);
				RenderingServer::get_singleton()->instance_set_scenario(contact_3d_debug_instance, find_world_3d()->get_scenario());
				RenderingServer::get_singleton()->instance_geometry_set_flag(contact_3d_debug_instance, RS::INSTANCE_FLAG_DRAW_NEXT_FRAME_IF_VISIBLE, true);
#endif 
				set_physics_process_internal(true);
			}
		} break;
		case NOTIFICATION_READY: {
#ifndef _3D_DISABLED
			if (audio_listener_3d_set.size() && !audio_listener_3d) {
				AudioListener3D *first = nullptr;
				for (AudioListener3D *E : audio_listener_3d_set) {
					if (first == nullptr || first->is_greater_than(E)) {
						first = E;
					}
				}
				if (first) {
					first->make_current();
				}
			}
			if (camera_3d_set.size() && !camera_3d) {
				
				Camera3D *first = nullptr;
				for (Camera3D *E : camera_3d_set) {
					if (first == nullptr || first->is_greater_than(E)) {