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

update_pending = false;
	if (gradient.is_null()) {
		return;
	}
	Ref<Image> image;
	image.instantiate();
	if (gradient->get_point_count() <= 1) { 
		image->initialize_data(width, height, false, (use_hdr) ? Image::FORMAT_RGBAF : Image::FORMAT_RGBA8);
		image->fill((gradient->get_point_count() == 1) ? gradient->get_color(0) : Color(0, 0, 0, 1));
	} else {
		if (use_hdr) {
			image->initialize_data(width, height, false, Image::FORMAT_RGBAF);
			Gradient &g = **gradient;
			
			for (int y = 0; y < height; y++) {
				for (int x = 0; x < width; x++) {
					float ofs = _get_gradient_offset_at(x, y);
					image->set_pixel(x, y, g.get_color_at_offset(ofs));
				}
			}
		} else {
			Vector<uint8_t> data;
			data.resize(width * height * 4);
			{
				uint8_t *wd8 = data.ptrw();
				Gradient &g = **gradient;
				for (int y = 0; y < height; y++) {
					for (int x = 0; x < width; x++) {
						float ofs = _get_gradient_offset_at(x, y);
						const Color &c = g.get_color_at_offset(ofs);