### 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)

Size2i size_2d_override;
	bool size_allocated = false;
	RID contact_2d_debug;
	RID contact_3d_debug_multimesh;
	RID contact_3d_debug_instance;
	Rect2 last_vp_rect;
	bool transparent_bg = false;
	bool gen_mipmaps = false;
	bool snap_controls_to_pixels = true;
	bool snap_2d_transforms_to_pixel = false;
	bool snap_2d_vertices_to_pixel = false;
	bool physics_object_picking = false;
	bool physics_object_picking_sort = false;
	List<Ref<InputEvent>> physics_picking_events;
	ObjectID physics_object_capture;
	ObjectID physics_object_over;
	Transform3D physics_last_object_transform;
	Transform3D physics_last_camera_transform;
	ObjectID physics_last_id;
	bool handle_input_locally = true;
	bool local_input_handled = false;
	
	HashMap<ObjectID, uint64_t> physics_2d_mouseover;
	
	HashMap<Pair<ObjectID, int>, uint64_t, PairHash<ObjectID, int>> physics_2d_shape_mouseover;
	
	void _cleanup_mouseover_colliders(bool p_clean_all_frames, bool p_paused_only, uint64_t p_frame_reference = 0);
	Ref<World2D> world_2d;
	StringName input_group;
	StringName gui_input_group;