How to generate simplex noise in shader?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By zachThePerson

Everywhere I look I see posts on how to generate opensimplex noise within GDScript, but I can’t find any on how to generate that noise in a fragment shader. Can anybody help me out?

I would love if somebody could provide just a simple grayscale noise shader using the build in noise function.

:bust_in_silhouette: Reply From: zachThePerson

Ok, figured it out myself. You have to create a texture uniform, and then in the node inspector you set that to a new noise texture

uniform sampler2D NOISE_PATTERN;

void fragment(){
    float noiseValue = texture(NOISE_PATTERN, UV).x;
    COLOR = vec4(noiseValue);
}

The above will simply sample the noise texture and set the color as the output

It did work in my tests,Thanks for sharing, I will use it to make a 2d water

Pony | 2022-05-14 20:21

1 Like