效果如下:
shader:
float snoise(vec3 uv, float res)
{
const vec3 s = vec3(1e0, 1e2, 1e3);
uv *= res;
vec3 uv0 = floor(mod(uv, res))*s;
vec3 uv1 = floor(mod(uv+vec3(1.), res))*s;
vec3 f = fract(uv); f = f*f*(3.0-2.0*f);
vec4 v = vec4(uv0.x+uv0.y+uv0.z, uv1.x+uv0.y+uv0.z,
uv0.x+uv1.y+uv0.z, uv1.x+uv1.y+uv0.z);
vec4 r = fract(sin(v*1e-1)*1e3);
float r0 = mix(mix(r.x, r.y, f.x), mix(r.z, r.w, f.x), f.y);
r = fract(sin((v + uv1.z - uv0.z)*1e-1)*1e3);
float r1 = mix(mix(r.x, r.y, f.x), mix(r.z, r.w, f.x), f.y);
return mix(r0, r1, f.z)*2.-1.;
}
float noise(vec2 uv, float baseres)
{
float n = 0.0;
for (int i = 0; i < 7; i++)
{
float v = pow(2.0, float(i));
n += (1.5 / v) * snoise(vec3(uv + vec2(1.,1.) * (float(i) / 17.), 1), v * baseres);
}
return clamp((1.0 - n) * .5, 0., 1.);
}
void mainImage( out vec4 fragColor, in vec2 fragCoord )
{
vec2 uv = (fragCoord/iResolution.xy);
// Tweaking vars
vec4 color = vec4(0.925, 0.291, 0.023, 1.0);
vec2 tiling = vec2(1.0, .6);
vec2 speed1 = vec2(0.05, -0.32);
vec2 speed2 = vec2(-0.10, -0.39);
float ss_min = 0.2;
float ss_max = ss_min + 0.5;
float noise_sz = 8.0f;
// Tiled UV
vec2 tuv = vec2(mod(uv.x * tiling.x, 1.0), mod(uv.y * tiling.y, 1.0));
// Samplings
vec2 uv1 = tuv + (speed1 * iTime);
vec2 uv2 = tuv + (speed2 * iTime);
// Mask
vec2 uvt = vec2(uv.x, pow(1.0 - uv.y, 2.2));
vec2 nuvt = (uvt * 2.0) - 1.0;
float v = 1. - length(nuvt);
v = ((v * .6) + (pow(v, 4.3) * 4.55));
float samplings = noise(uv1, noise_sz) * noise(uv2, noise_sz);
float mask = pow(v, 1.2) * samplings;
float amask = smoothstep(ss_min, ss_max, mask);
// Output to screen
fragColor = color + (color * pow((1.0 - uv.y), 3.0) * .3);
fragColor += samplings * .3;
fragColor *= (2. * amask);
}