MCPcopy Create free account
hub / github.com/NMWplays/Glowify / startBackground

Function startBackground

theme.js:103–252  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

101 vec2 uv = v_texCoord;
102 float t = u_time * 0.05;
103
104 vec2 center = uv - 0.5;
105 float centerWeight = 1.0 - smoothstep(0.0, 0.7, length(center));
106
107 // Large-scale movement (slow, big blobs)
108 float n1 = snoise(uv * 0.35 + vec2(t, t * 0.7));
109 float n2 = snoise(uv * 0.35 + vec2(-t * 0.8, t * 0.5) + vec2(50.0, 50.0));
110
111 // Medium-scale detail (adds organic movement)
112 float n3 = snoise(uv * 0.9 + vec2(t * 1.2, -t) + vec2(100.0, 0.0));
113 float n4 = snoise(uv * 0.9 + vec2(-t, t * 1.1) + vec2(0.0, 100.0));
114
115 // Combine two octaves
116 vec2 warp = vec2(
117 n1 * 0.65 + n3 * 0.35,
118 n2 * 0.65 + n4 * 0.35
119 ) * centerWeight;
120
121 vec2 warpedUV = uv + warp * u_intensity;
122 warpedUV = clamp(warpedUV, 0.0, 1.0);
123
124 gl_FragColor = texture2D(u_texture, warpedUV);
125 }
126`;
127 var OUTPUT_SHADER = `
128 precision highp float;
129 uniform sampler2D u_texture;
130 uniform float u_saturation;
131 uniform float u_dithering;
132 uniform float u_time;
133 uniform float u_scale;
134 uniform vec2 u_resolution;
135 varying vec2 v_texCoord;
136
137 highp float hash(highp vec3 p) {
138 p = fract(p * 0.1031);
139 p += dot(p, p.zyx + 31.32);
140 return fract((p.x + p.y) * p.z);
141 }
142
143 void main() {
144 vec2 uv = (v_texCoord - 0.5) / u_scale + 0.5;
145 uv = clamp(uv, 0.0, 1.0);
146
147 vec4 color = texture2D(u_texture, uv);
148
149 vec2 center = v_texCoord - 0.5;
150 float vignette = 1.0 - dot(center, center) * 0.3;
151 color.rgb *= vignette;
152
153 float gray = dot(color.rgb, vec3(0.299, 0.587, 0.114));
154 color.rgb = mix(vec3(gray), color.rgb, u_saturation);
155
156 highp vec2 pixelPos = floor(v_texCoord * u_resolution);
157 highp float noise = hash(vec3(pixelPos, floor(u_time * 60.0)));
158 color.rgb += (noise - 0.5) * u_dithering;
159
160 gl_FragColor = color;

Callers 1

startFunction · 0.85

Calls 2

getContextUriFunction · 0.85

Tested by

no test coverage detected