Strange behavior with gridlike artifacts in noise

Godot Version

4.4.1

Question

Hi, I’m trying to implement the first noise algorithm described in https://thebookofshaders.com/11/ and I’m seeing some gridlike artifacts:

This is the code that generated the above image:

shader_type canvas_item;

uniform float size = 10.0;
uniform float seed: hint_range(1, 10) = 1.0;

float rand(vec2 coord) {
	return fract(sin(dot(coord.xy ,vec2(12.9898,78.233))) * 43758.5453123);
}

float noise(vec2 coord){
	vec2 i = floor(coord);
	vec2 f = fract(coord);
	
	float a = rand(i);
	float b = rand(i + vec2(1.0, 0.0));
	float c = rand(i + vec2(0.0, 1.0));
	float d = rand(i + vec2(1.0, 1.0));

	vec2 cubic = smoothstep(0.0, 1.0, f);

	return mix(a, b, cubic.x) + (c - a) * cubic.y * (1.0 - cubic.x) + (d - b) * cubic.x * cubic.y;
}

void fragment() {
	vec3 rgb = vec3(noise(UV * size));
	float a = 1.0;
	COLOR = vec4(rgb, a);
}

Something odd that I noticed when I was trying to get rid of the gridlike artifacts was that if I multiply the hardcoded vec2 in the rand() function by a seed (even if that seed is 1.0), the artifacts go away.

uniform float seed: hint_range(1, 10) = 1.0;

float rand(vec2 coord) {
	return fract(sin(dot(coord.xy ,vec2(12.9898,78.233) * seed)) * 43758.5453123);
}

results in:

Replacing the uniform seed with a hardcoded 1.0 brings back the artifacts. Also, using a locally-defined float seed = 1.0 also results in the artifacts.

Can anyone explain why I’m getting these artifacts, and why multiplying specifically by a uniform float seems to get rid of them?

Thank you!