2023-10-13 00:49:16 +05:30
|
|
|
float noise_random_value(vec2 uv){
|
2023-10-13 15:44:54 +05:30
|
|
|
return fract(sin(dot(uv.xy, vec2(12.9898,78.233))) * 43758.5453123);
|
2023-10-13 00:49:16 +05:30
|
|
|
}
|
|
|
|
|
2023-10-13 17:00:44 +05:30
|
|
|
float value_noise(vec2 uv){
|
|
|
|
vec2 _floor = floor(uv);
|
|
|
|
vec2 _fraction = fract(uv);
|
|
|
|
_fraction = _fraction * _fraction * (3.0 - 2.0 * _fraction);
|
|
|
|
vec2 _corner = vec2(1.0, 0.0);
|
2023-12-24 20:47:18 +05:30
|
|
|
|
2023-10-13 17:00:44 +05:30
|
|
|
float _c0 = noise_random_value(_floor + _corner.yy);
|
|
|
|
float _c1 = noise_random_value(_floor + _corner.xy);
|
|
|
|
float _c2 = noise_random_value(_floor + _corner.yx);
|
|
|
|
float _c3 = noise_random_value(_floor + _corner.xx);
|
2023-12-24 20:47:18 +05:30
|
|
|
|
2023-10-13 17:00:44 +05:30
|
|
|
vec2 _blur = smoothstep(0.0, 1.0, _fraction);
|
|
|
|
float mix_one = mix(_c0, _c1, _blur.x) + (_c2 - _c0) * _blur.y * (1.0 - _blur.x) + (_c3 - _c1) * _blur.x * _blur.y;
|
|
|
|
return mix_one;
|
2023-10-13 00:49:16 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
float simple_noise(vec2 uv, float scale){
|
2023-10-13 15:44:54 +05:30
|
|
|
int octaves = 6;
|
2023-10-13 17:00:44 +05:30
|
|
|
float amplitude = 0.25;
|
2023-10-13 15:44:54 +05:30
|
|
|
float value = 0.0;
|
2023-12-24 20:47:18 +05:30
|
|
|
|
2023-10-13 15:44:54 +05:30
|
|
|
for(int i = 0; i < octaves; i++) {
|
2023-10-13 17:00:44 +05:30
|
|
|
value += amplitude * value_noise(scale * uv);
|
|
|
|
amplitude *= 0.85;
|
|
|
|
scale *= 3.0;
|
2023-10-13 15:44:54 +05:30
|
|
|
}
|
|
|
|
return value;
|
2023-10-13 00:49:16 +05:30
|
|
|
}
|