2D Perlin Noise Algorithm not working correctly

So I’m trying to write my own perlin noise algorithm at the moment but I’ve been stuck with this one problem for a long time

Here is my result:

And here’s my code (sorry it’s a bit messy, I’m not using a proper vector class at the moment):



private float dot(float x0, float y0, float x1, float y1) {
	return (x0 * x1) + (y0 * y1);
}

public float sample(float x, float y) {
	int gx0 = (int) Math.floor(x);
	int gy0 = (int) Math.floor(y);
	int gx1 = gx0 + 1;
	int gy1 = gy0 + 1;
	
	float dx0 = x - gx0;
	float dy0 = y - gy0;
	
	float dx1 = x - gx1;
	float dy1 = y - gy1;
	
	float w0 = dot(dx0, dy0, getVX(gx0, gy0), getVY(gx0, gy0));
	float w1 = dot(dx0, dy1, getVX(gx0, gy1), getVY(gx0, gy1));
	float w2 = dot(dx1, dy1, getVX(gx1, gy1), getVY(gx1, gy1));
	float w3 = dot(dx1, dy0, getVX(gx1, gy0), getVY(gx1, gy0));
	
	float sx = weigh(dx0);
	float sy = weigh(dy0);
	
	float a = lerp(sy, w0, w1);
	float b = lerp(sy, w2, w3);
	float h = lerp(sx, a, b);
	
	return h;
}

private float weigh(float x) {
	return 3 * (x * x) - 2 * (x * x * x);
}

private float lerp(float w, float a, float b) {
      return a + w * (b - a);
}

The functions getVX and getVY get the respective x and y components of the vectors at the grid points. I’m pretty sure this isn’t an issue with random generation of the gradients on the grid points but I can post this code if it will help!

Thanks in advanced :D!