How to use sin wave in shader

Godot Version

4.2.2

Question

my code

shader_type canvas_item;
varying float depth;
// uniform vec4 color;
uniform float frequency = 0.1;

void vertex() {
	// Called for every vertex the material is visible on.
	depth = (sin(10.0*VERTEX.x)+1.0)/2.0;
}

void fragment() {
	// Called for every pixel the material is visible on.
	vec4 pixelColor = texture(TEXTURE,UV);
	pixelColor.a = depth;
	COLOR = pixelColor;
}

//void light() {
	// Called for every pixel for every light affecting the CanvasItem.
	// Uncomment to replace the default light processing function with this one.
//}

I expect this to form a sinwave like structure but why it giving a gradient?

Note: Vertex.x ranges from 0 to 1 since i made the size as 1 and increased the scale factor accordingly

Ok so here is why:
The VERTEX function is only running on the four corners of your ColorRect. I don’t know if that is entirely truthful, because I have never done 2D shaders, only 3D. But your problem is that you calculate it in the VERTEX function. For debug reasons add ‘flat’ after the word ‘varying’ on your depth shader. You see it all becomes the same color. So what you have to do is calculate it inside the FRAGMENT function, using UV.x instead of VERTEX.x: