### Godot version

9f9210e60cddb2fa82ce5f7d71fcba340f2edbd1

### System information

Windows 11

### Issue description

I found that one of particles shaders in my project begin working incorrectly after the recent fixes. I've bisected it to 9f9210e60cddb2fa82ce5f7d71fcba340f2edbd1.

Before:
![image](https://github.com/godotengine/godot/assets/3036176/556bb0ed-6214-42ce-b194-8b54b0349b18)


After:
![image](https://github.com/godotengine/godot/assets/3036176/b3fa0b8a-20a6-4c5a-aea7-3e1ec465ea3e)


### Steps to reproduce

Download the provided test project and compare changes with different version.

### Minimal reproduction project

[bug.zip](https://github.com/godotengine/godot/files/12476303/bug.zip)

if (texture.is_valid()) {
		ERR_FAIL_NULL(RenderingServer::get_singleton());
		RS::get_singleton()->free(texture);
	}
}
void GradientTexture2D::set_gradient(Ref<Gradient> p_gradient) {
	if (gradient == p_gradient) {
		return;
	}
	if (gradient.is_valid()) {
		gradient->disconnect_changed(callable_mp(this, &GradientTexture2D::_queue_update));
	}
	gradient = p_gradient;
	if (gradient.is_valid()) {
		gradient->connect_changed(callable_mp(this, &GradientTexture2D::_queue_update));
	}
	_queue_update();
	emit_changed();
}
Ref<Gradient> GradientTexture2D::get_gradient() const {
	return gradient;
}
void GradientTexture2D::_queue_update() {
	if (update_pending) {
		return;
	}
	update_pending = true;
	callable_mp(this, &GradientTexture2D::update_now).call_deferred();
}
void GradientTexture2D::_update() {