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

bool is_input_handled() const;
	void set_handle_input_locally(bool p_enable);
	bool is_handling_input_locally() const;
	bool gui_is_dragging() const;
	bool gui_is_drag_successful() const;
	Control *gui_find_control(const Point2 &p_global);
	void set_sdf_oversize(SDFOversize p_sdf_oversize);
	SDFOversize get_sdf_oversize() const;
	void set_sdf_scale(SDFScale p_sdf_scale);
	SDFScale get_sdf_scale() const;
	void set_default_canvas_item_texture_filter(DefaultCanvasItemTextureFilter p_filter);
	DefaultCanvasItemTextureFilter get_default_canvas_item_texture_filter() const;
	void set_default_canvas_item_texture_repeat(DefaultCanvasItemTextureRepeat p_repeat);
	DefaultCanvasItemTextureRepeat get_default_canvas_item_texture_repeat() const;
	
	void set_vrs_mode(VRSMode p_vrs_mode);
	VRSMode get_vrs_mode() const;
	void set_vrs_texture(Ref<Texture2D> p_texture);
	Ref<Texture2D> get_vrs_texture() const;
	virtual DisplayServer::WindowID get_window_id() const = 0;
	void set_embedding_subwindows(bool p_embed);
	bool is_embedding_subwindows() const;
	Viewport *get_parent_viewport() const;
	Window *get_base_window() const;
	void pass_mouse_focus_to(Viewport *p_viewport, Control *p_control);
	void set_canvas_cull_mask(uint32_t p_layers);
	uint32_t get_canvas_cull_mask() const;
	void set_canvas_cull_mask_bit(uint32_t p_layer, bool p_enable);
	bool get_canvas_cull_mask_bit(uint32_t p_layer) const;
	virtual bool is_size_2d_override_stretch_enabled() const { return true; }