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

Vector2 segment[2];
		segment[0] = fill_from;
		segment[1] = fill_to;
		Vector2 closest = Geometry2D::get_closest_point_to_segment_uncapped(pos, &segment[0]);
		ofs = (closest - fill_from).length() / (fill_to - fill_from).length();
		if ((closest - fill_from).dot(fill_to - fill_from) < 0) {
			ofs *= -1;
		}
	} else if (fill == Fill::FILL_RADIAL) {
		ofs = (pos - fill_from).length() / (fill_to - fill_from).length();
	} else if (fill == Fill::FILL_SQUARE) {
		ofs = MAX(Math::abs(pos.x - fill_from.x), Math::abs(pos.y - fill_from.y)) / MAX(Math::abs(fill_to.x - fill_from.x), Math::abs(fill_to.y - fill_from.y));
	}
	if (repeat == Repeat::REPEAT_NONE) {
		ofs = CLAMP(ofs, 0.0, 1.0);
	} else if (repeat == Repeat::REPEAT) {
		ofs = Math::fmod(ofs, 1.0f);
		if (ofs < 0) {
			ofs = 1 + ofs;
		}
	} else if (repeat == Repeat::REPEAT_MIRROR) {
		ofs = Math::abs(ofs);
		ofs = Math::fmod(ofs, 2.0f);
		if (ofs > 1.0) {
			ofs = 2.0 - ofs;
		}
	}
	return ofs;
}
void GradientTexture2D::set_width(int p_width) {