# Strange origin seams and rotation in shader when using 3D noise

4.2.2

### Question

I’m using 3D noise to create continents for my planet, based on this youtube short I saw.

When I use lower noise values it gives me mostly reasonable outputs like this:

But when I use high frequency noise it creates these odd macro patterns about the origin that don’t flow seemlessly.

I’m new to godot shaders, so if anyone has insight on why this is happening, that would be appreciated. Here is my shader script:

``````void fragment() {
float dx = -(float(width/2) - VERTEX.x) / p_radius;
float dy = -(float(height/2) - VERTEX.y) / p_radius;
float dz = sqrt(1.0 - pow(dx, 2.0) - pow(dy, 2.0));
vec4 offset = texture(noise, vec3(dx, dy, dz));
if (sqrt(pow(dx, 2.0) + pow(dy, 2.0)) <= 1.0) {
vec3 depth = vec3((offset.x) * magnitude, offset.y * magnitude, offset.z * magnitude);
if (sqrt(pow(depth.x, 2.0) + pow(depth.y,2.0) + pow(depth.z, 2.0)) > 0.6) {
COLOR = vec4(0.2, 0.8, 0.1, 1);
}
} else {
COLOR = vec4(0, 0, 0, 1);
}
}
``````
1 Like

Well, I like debugging math type problems (I suspect using a different approach on coordinates/geometry will fix the issue), but I am completely green on shaders. But I would like to learn some.

If you help me to get your example to run, I will help tinker with it.

Do you have a basic example project with this that you could upload to github? Preferably with an example using both types of noise.

1 Like

The material is under the node2D. It contains a script to draw a rectangle on screen for the shader to draw on, and it also contains the script for rotating the planet.

1 Like

I’ll check this when I am on break tomorrow

1 Like

Okay well I finally got it working, the issue was that the coordinates of my sphere went from (-1, 1) on each axis, while the texture coordinates I was looking up for the noise went from (0, 1). This caused the weird changes when the coordinates switched signs. trying to take the absolute value caused weird symmetry, so I had to remap the coordinates to (0-1) for each axis after it had gone through the rotation matrix, which has fixed the problem.

1 Like

I’ve uploaded the fixed code to github if you still want to check it out

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.