49 lines
1.4 KiB
Plaintext
49 lines
1.4 KiB
Plaintext
shader_type canvas_item;
|
|
|
|
// source: https://godotshaders.com/shader/smooth-2d-cloud/
|
|
// inspired by: https://www.youtube.com/watch?v=8OrvIQUFptA&t=2s
|
|
uniform sampler2D perlin_noise: repeat_enable;
|
|
uniform sampler2D cell_noise: repeat_enable;
|
|
|
|
//#define pow2(x) (x * x)
|
|
////#define iResolution 1.0/SCREEN_PIXEL_SIZE
|
|
|
|
//const int samples = 16;
|
|
//const int half_samples = 8;
|
|
//const float sigma = float(samples) * 0.25;
|
|
|
|
//float gaussian(vec2 i) {
|
|
//return 1.0 / (2.0 * PI * pow2(sigma)) * exp(-((pow2(i.x) + pow2(i.y)) / (2.0 * pow2(sigma))));
|
|
//}
|
|
//
|
|
//float blur(sampler2D sp, vec2 uv, vec2 scale) {
|
|
//float col = 0.0;
|
|
//float accum = 0.0;
|
|
//float weight = 1.0;
|
|
//vec2 offset;
|
|
//for (int x = - half_samples ; x < half_samples; ++x) {
|
|
//for (int y = - half_samples; y < half_samples; ++y) {
|
|
//offset = vec2(float(x), float(y));
|
|
////weight = gaussian(offset);
|
|
//col += texture(sp, uv + scale * offset).r * weight;
|
|
//accum += weight;
|
|
//}
|
|
//}
|
|
//return col / accum;
|
|
//}
|
|
|
|
void fragment() {
|
|
vec2 uv1 = vec2(UV.x + TIME * .02, UV.y + TIME * .005);
|
|
vec2 uv2 = vec2(UV.x + TIME * .03, UV.y + TIME * .005);
|
|
|
|
//float noise1 = blur(perlin_noise, uv1, SCREEN_PIXEL_SIZE);
|
|
//float noise2 = blur(cell_noise, uv2, SCREEN_PIXEL_SIZE);
|
|
float noise1 = texture(perlin_noise, uv1).r;
|
|
float noise2 = texture(cell_noise, uv2).r;
|
|
//noise1 = 1.0;
|
|
//noise2 = 1.0;
|
|
float noise = smoothstep(noise1 * noise2, .0, .15);
|
|
|
|
COLOR.a *= noise;
|
|
}
|