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

}
	}
	Ref<InputEventGesture> gesture_event = p_event;
	if (gesture_event.is_valid()) {
		gui.key_event_accepted = false;
		_gui_cancel_tooltip();
		Size2 pos = gesture_event->get_position();
		Control *over = gui_find_control(pos);
		if (over) {
			bool stopped = false;
			if (over->can_process()) {
				gesture_event = gesture_event->xformed_by(Transform2D()); 
				pos = over->get_global_transform_with_canvas().affine_inverse().xform(pos);
				gesture_event->set_position(pos);
				stopped = _gui_call_input(over, gesture_event);
			}
			if (stopped) {
				set_input_as_handled();
			}
			return;
		}
	}
	Ref<InputEventScreenDrag> drag_event = p_event;
	if (drag_event.is_valid()) {
		const int drag_event_index = drag_event->get_index();
		ObjectID control_id = gui.touch_focus[drag_event_index];
		Control *over = control_id.is_valid() ? Object::cast_to<Control>(ObjectDB::get_instance(control_id)) : nullptr;
		if (!over) {
			over = gui_find_control(drag_event->get_position());
		}