blob: 5131fea85330651754c25f767234a9b8096af6a0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
// Scene2 effect shader - ShaderToy conversion (volumetric clouds)
// Generated by convert_shadertoy.py
// NOTE: Manual review recommended - conversion is basic
#include "sequence_uniforms"
#include "render/fullscreen_uv_vs"
@group(0) @binding(2) var<uniform> uniforms: UniformsSequenceParams;
const CloudColor = vec4f(3.0, 2.3, 1.0, 1.0);
fn N(a: vec3f, p: vec3f) -> f32 {
return abs(dot(sin(uniforms.time * .7 + 0.1 * p.z + 0.6 * p / a), a));
}
@fragment fn fs_main(in: VertexOutput) -> @location(0) vec4f {
let r = uniforms.resolution;
let uv = in.position.xy;
let u = (2. * uv - r.xy) / r.y;
let len_u = 1600. * max(length(u), 0.0001);
var p = vec3f(0.0);
var col = vec4f(0.0);
for (var i: f32 = 0.0; i < 100.0; i += 1.0) {
var s = 6.0 + p.y - .3 * p.x;
s -= N(vec3f(0.15), p);
s -= N(vec3f(0.5), p);
s -= N(vec3f(1.2), p);
s = 0.1 + abs(s) * 0.2;
col += CloudColor / s;
p += vec3f(u * s, s);
}
col *= smoothstep(0.8, 0.75 - .3 * uniforms.beat_phase, abs(u.y));
col = tanh(col / len_u);
return vec4f(col.rgb, 1.0);
}
|