PageSourceSearch

https://noteworthy.app/assets/built/chunks/light-rays-s4TWLiK3.js

js noteworthy.app collected 2026-10-04 08:04:53 UTC 3,078 bytes, 66 lines download raw bytes

1import{c as m,u as r,s as t,a as i}from"./helpers-CxDxNF8W.js";var _=`
2precision highp float;
3
4uniform vec2 u_resolution;
5uniform float u_time;
6uniform float u_speed;
7uniform vec3 u_accent;
8uniform vec3 u_baseColor;
9uniform float u_lightSpread;
10uniform float u_rayLength;
11uniform float u_pulsating;
12uniform float u_fadeDistance;
13uniform float u_saturation;
14uniform vec2 u_mouse;
15uniform float u_mouseInfluence;
16uniform float u_distortion;
17
18float rayStrength(vec2 src, vec2 refDir, vec2 coord, float sA, float sB, float spd) {
19	float t = u_time * u_speed;
20	vec2 delta = coord - src;
21	float ca = dot(normalize(delta), refDir);
22	float da = ca + u_distortion * sin(t * 2.0 + length(delta) * 0.01) * 0.2;
23	float sf = pow(max(da, 0.0), 1.0 / max(u_lightSpread, 0.001));
24	float dist = length(delta);
25	float maxDist = u_resolution.x * u_rayLength;
26	float lf = clamp((maxDist - dist) / maxDist, 0.0, 1.0);
27	float ff = clamp((u_resolution.x * u_fadeDistance - dist) / (u_resolution.x * u_fadeDistance), 0.5, 1.0);
28	float pulse = u_pulsating > 0.5 ? (0.8 + 0.2 * sin(t * spd * 3.0)) : 1.0;
29	float base = clamp(
30		(0.45 + 0.15 * sin(da * sA + t * spd)) +
31		(0.3 + 0.2 * cos(-da * sB + t * spd)),
32		0.0, 1.0);
33	return base * lf * ff * sf * pulse;
34}
35
36void main() {
37	float t = u_time * u_speed;
38	vec2 coord = vec2(gl_FragCoord.x, u_resolution.y - gl_FragCoord.y);
39
40	vec2 rayPos = vec2(u_resolution.x * 0.5, u_resolution.y * -0.2);
41	vec2 rayDir = vec2(0.0, 1.0);
42
43	vec2 finalDir = rayDir;
44	if (u_mouseInfluence > 0.0) {
45		vec2 mScreen = vec2(u_mouse.x, 1.0 - u_mouse.y) * u_resolution;
46		vec2 mDir = normalize(mScreen - rayPos);
47		finalDir = normalize(mix(rayDir, mDir, u_mouseInfluence));
48	}
49
50	float r1 = rayStrength(rayPos, finalDir, coord, 36.2214, 21.11349, 1.5);
51	float r2 = rayStrength(rayPos, finalDir, coord, 22.3991, 18.0234, 1.1);
52	vec3 color = vec3(r1 * 0.5 + r2 * 0.4);
53
54	float brt = 1.0 - coord.y / u_resolution.y;
55	color.x *= 0.1 + brt * 0.8;
56	color.y *= 0.3 + brt * 0.6;
57	color.z *= 0.5 + brt * 0.5;
58
59	float gray = dot(color, vec3(0.299, 0.587, 0.114));
60	color = mix(vec3(gray), color, u_saturation);
61	color *= u_accent;
62
63	vec3 outColor = clamp(u_baseColor + color, 0.0, 1.0);
64	gl_FragColor = vec4(outColor, 1.0);
65}
66`;function g(e,a,p,l,y,{config:c}={}){const{primary:f,background:s}=l,o=m(e,a),{animation:d,rays:u,mouse:n}=c;return o.speed=r(e,a,"u_speed"),o.accent=r(e,a,"u_accent"),o.baseColor=r(e,a,"u_baseColor"),o.lightSpread=r(e,a,"u_lightSpread"),o.rayLength=r(e,a,"u_rayLength"),o.pulsating=r(e,a,"u_pulsating"),o.fadeDistance=r(e,a,"u_fadeDistance"),o.saturation=r(e,a,"u_saturation"),o.mouseInfluence=r(e,a,"u_mouseInfluence"),o.distortion=r(e,a,"u_distortion"),n?.enabled&&(o.mouse=r(e,a,"u_mouse")),t(e,o.speed,d.speed),i(e,o.baseColor,s),t(e,o.lightSpread,u.lightSpread),t(e,o.rayLength,u.rayLength),t(e,o.pulsating,u.pulsating),t(e,o.fadeDistance,u.fadeDistance),t(e,o.saturation,u.saturation),t(e,o.mouseInfluence,n?.enabled?u.mouseInfluence:0),t(e,o.distortion,u.distortion),i(e,o.accent,f),i(e,o.baseColor,s),o}export{_ as default,g as setupLightRaysUniforms};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.