Branchwell

PulseCanvas / app · pulsecanvas.ai / Sources / PulseCanvas / Resources / NativeExpansionVoyage.metal

1// Original PulseCanvas forward-motion scenes, authored from geometry and surface math.
2
3float3 fuchsiaFlyway(Ctx c, constant NativeFrame &f) {
4
5 float2 p=c.uv/c.size; float h=.35, d=max(h-p.y,.035f), z=2/d+c.travel*2.4;
6 float x=p.x/d-.6*sin(z*.13+c.t*.2);
7 float road=exp(-pow(x*.3,4.f)), rails=glow(abs(x)-3.2,.11);
8 float cable=glow(abs(x)-3.7-(.6+.5*cos(z*.7)),.08);
9 float posts=line(sin(z*1.4),.08,c.px/d)*smoothstep(2.8f,3.2f,abs(x));
10 float3 ground=paint(.15+z*.023,f)*(.17*road+rails*1.8+cable+posts*.5);
11 ground+=paint(.85,f)*road*pow(.5+.5*cos(z*3+x*.7+c.b.x*sin(x)*2),6.f)*.3;
12 float sky=.5+.5*sin(p.x*2+sin(p.y*3+c.t*.3));
13 return mix(paint(.6+sky*.15,f)*(.15+sky*.3),ground,smoothstep(-.03f,.04f,h-p.y));
14}
15NATIVE_EFFECT(fuchsiaFlyway)
16
17float3 amberAqueduct(Ctx c, constant NativeFrame &f) {
18
19 float2 p=c.uv/c.size; float r=max(length(p*float2(1,.6)),.06f), z=2.4/r+c.travel*1.8;
20 float a=atan2(p.y*.6,p.x), wave=sin(z*1.7+a*5+c.t*.6);
21 float channel=pow(.5+.5*cos(a*2),4.f), bricks=line(sin(z*3+cos(a*6)),.13,c.px/r);
22 float water=.5+.5*sin(z*.8+sin(a*4+z*.2)*2+c.b.x*sin(a*9));
23 float3 col=paint((.5+.3*sin(a))+z*.012,f)*(.25+channel*.45+bricks*.8);
24 col+=paint(.8+water*.1,f)*pow(max(0.f,wave),12.f)*(1+c.b.w)*.8;
25 return col*smoothstep(.025f,.18f,r)+deep(.5,f)*.08;
26}
27NATIVE_EFFECT(amberAqueduct)
28
29float3 photonOverpass(Ctx c, constant NativeFrame &f) {
30
31 float3 col=deep(.4,f)*.1;
32 for(int k=0;k<5;++k){float2 s=layerSlot(k,5,c.travel*.15); float sc=layerScale(s.x,3)/c.size;
33 float2 p=rot(c.uv*sc,.5*sin(c.t*.2)+s.y*.38); float arc=p.y-.4*sin(p.x*1.3+s.y);
34 float ribbon=glow(arc,.22), curb=glow(abs(arc)-.3,.025);
35 float dash=pow(.5+.5*cos(p.x*5+s.y+c.t*.7),5.f);
36 col+=paint(s.y*.18+p.x*.025,f)*(ribbon*(.35+dash*.55)+curb*1.7)*(1+c.b[int(s.y-4*floor(s.y/4))]*.5)*layerFade(s.x);
37 }return col;
38}
39NATIVE_EFFECT(photonOverpass)
40
41float3 indigoEscalator(Ctx c, constant NativeFrame &f) {
42
43 float2 p=rot(c.uv/c.size,.12*sin(c.t*.2)); float d=max(.4-p.y,.035f), z=2.3/d+c.travel*2;
44 float x=p.x/d, step=fract(z*.8), edge=line(sin(z*.8*PI),.06,c.px/(d*d));
45 float groove=line(sin(x*4),.035,c.px/d), rail=glow(abs(x)-4,.15);
46 float3 floor=paint(z*.04+x*.035,f)*(.22+step*.4+edge*.8+groove*.3+rail*1.6);
47 floor+=paint(.75,f)*pow(max(0.f,cos(x*2+z*3+c.b.y*sin(x))),12.f)*.45;
48 return mix(paint(.7+sin(p.x+c.t*.2)*.1,f)*.2,floor,smoothstep(-.03f,.04f,.4-p.y));
49}
50NATIVE_EFFECT(indigoEscalator)
51
52float3 solarSlalom(Ctx c, constant NativeFrame &f) {
53
54 float2 p=c.uv/c.size; float d=max(.3-p.y,.04f), z=2/d+c.travel*2.3;
55 float lane=p.x/d-1.5*sin(z*.3+c.t*.3), rip=.5+.5*sin(z*2.4+lane*1.4+c.b.x*sin(lane)*2);
56 float stripe=glow(abs(lane)-2,.18), gates=line(sin(z*2),.08,c.px/d)*glow(abs(lane)-2.6,.35);
57 float chevron=line(sin(z*4-abs(lane)*1.6),.09+c.b.w*.1,c.px/d);
58 float3 floor=paint(lane*.045+z*.019,f)*(.18+rip*.5+stripe+gates+chevron*.5);
59 float3 sky=paint(.7+p.y*.05,f)*(.2+.15*sin(p.x*3+p.y*2+c.t*.2));
60 return mix(sky,floor,smoothstep(-.03f,.03f,.3-p.y));
61}
62NATIVE_EFFECT(solarSlalom)
63
64float3 glacialSprint(Ctx c, constant NativeFrame &f) {
65
66 float2 p=rot(c.uv/c.size,c.t*.08); float r=max(max(abs(p.x),abs(p.y)),.05f), z=2/r+c.travel*1.7;
67 float wall=(abs(p.x)>abs(p.y)?p.y:p.x)/r; float crevice=abs(sin(wall*6+sin(z*.7)*1.6+c.b.y*sin(wall*9)));
68 float crystal=pow(.5+.5*cos(z*3.5+wall*4),3.f);
69 float joint=line(sin(z*2+floor(wall*3)),.1,c.px/r);
70 float3 col=paint(.55+wall*.12+z*.016,f)*(.25+crystal*.65+joint*.6);
71 col+=paint(.85,f)*glow(crevice,.045)*1.6;
72 return col*smoothstep(.03f,.15f,r)+deep(.6,f)*.08;
73}
74NATIVE_EFFECT(glacialSprint)
75
76float3 velvetVoyage(Ctx c, constant NativeFrame &f) {
77
78 float2 p=c.uv/c.size; float r=max(length(p),.05f), a=atan2(p.y,p.x), z=2/r+c.travel*2;
79 float fabric=sin(a*4+z*.65+c.t*.3)+.35*sin(a*11-z*.4+c.b.y*sin(z)*2);
80 float folds=.5+.5*sin(fabric*4+z*.2), fringe=line(sin(a*12+z*.5),.06,c.px/r);
81 float sheen=pow(max(0.f,cos(fabric*4+z*.2)),8.f);
82 float3 col=paint(fabric*.11+z*.012,f)*(.15+folds*.65+fringe*.3);
83 col+=paint(.9,f)*sheen*(.6+c.b.w*.5);
84 return col*smoothstep(.02f,.13f,r)+deep(.4,f)*.1;
85}
86NATIVE_EFFECT(velvetVoyage)
87
88float3 plasmaRally(Ctx c, constant NativeFrame &f) {
89
90 float2 p=rot(c.uv/c.size,c.t*.09); float r=max(length(p),.05f), a=atan2(p.y,p.x), z=2.1/r+c.travel*2;
91 float2 tile=float2(a*6/PI+z*.08,z*.7); float4 cell=hexCell(tile);
92 float rim=line(sdHex(cell.xy,.48),.05+c.b.w*.035,c.px/r*1.2);
93 float panel=exp(-dot(cell.xy,cell.xy)*5)*(.5+.5*sin(cell.z*.8+cell.w*.6+c.t));
94 float ion=glow(sin(a*3+z*.45),.11);
95 float3 col=paint(.3*sin(cell.z*TAU/12)+cell.w*.08,f)*(.14+rim+panel*.6+ion*.7);
96 return col*smoothstep(.03f,.16f,r)+paint(.6,f)*.08;
97}
98NATIVE_EFFECT(plasmaRally)
99
100float3 crystalCauseway(Ctx c, constant NativeFrame &f) {
101
102 float2 p=c.uv/c.size; float d=max(.45-p.y,.05f), z=1.8/d+c.travel*1.7;
103 float2 q=float2(p.x/d,z); q.x+=sin(q.y*.2+c.t*.3)*.6;
104 float2 cell=floor(q), l=fract(q); float diagonal=abs(l.x+l.y-1);
105 float facet=l.x+l.y<1 ? l.x : 1-l.y; float linework=line(diagonal,.035,c.px/d);
106 float seams=line(min(min(l.x,1-l.x),min(l.y,1-l.y)),.025,c.px/d);
107 float3 floor=paint(cell.x*.09+cell.y*.05,f)*(.2+facet*.7+linework*.6+seams*.5);
108 floor+=paint(.9,f)*pow(.5+.5*sin(cell.x*1.3+cell.y+c.t*.6),8.f)*c.b.x*.8;
109 return mix(paint(.7+sin(p.x+c.t*.1)*.15,f)*.23,floor,smoothstep(-.03f,.05f,.45-p.y));
110}
111NATIVE_EFFECT(crystalCauseway)
112
113float3 luminousLift(Ctx c, constant NativeFrame &f) {
114
115 float2 p=rot(c.uv/c.size,.18*sin(c.t*.2)); float d=max(abs(p.x),.045f), z=2/d+c.travel*1.8;
116 float vertical=p.y/d, q=z*.6+vertical*.25; float pane=line(sin(q*PI),.07,c.px/d);
117 float beam=glow(sin(vertical*2-c.t*.4),.12), step=.5+.5*cos(q*TAU+sin(vertical*3)*c.b.y);
118 float3 col=paint(z*.025+vertical*.05,f)*(.22+step*.25+pane*.95+beam*.7);
119 float central=exp(-abs(p.x)*5);
120 return col*(1-central*.7)+paint(.8,f)*central*.18;
121}
122NATIVE_EFFECT(luminousLift)
123
124float3 arcJetstream(Ctx c, constant NativeFrame &f) {
125
126 float3 col=paint(.4,f)*.12;
127 for(int k=0;k<7;++k){float2 s=layerSlot(k,7,c.travel*.13); float scale=layerScale(s.x,2.8)/c.size;
128 float2 p=rot(c.uv*scale,.18*sin(s.y*.7+c.t*.3));
129 float wave=p.y-.45*sin(s.y*.83)-.35*sin(p.x*.9+c.t*.8+s.y);
130 float trail=glow(wave,.045+.07*c.b[int(s.y-4*floor(s.y/4))]), broad=glow(wave,.25)*.2;
131 float streak=.3+.7*pow(.5+.5*cos(p.x*3+s.y*1.8),4.f);
132 col+=paint(s.y*.16+p.x*.025,f)*(trail*streak*2+broad)*layerFade(s.x);
133 }return col;
134}
135NATIVE_EFFECT(arcJetstream)
136
137float3 rubyRollway(Ctx c, constant NativeFrame &f) {
138
139 float2 p=c.uv/c.size; float d=max(.5-p.y,.04f), z=2/d+c.travel*2;
140 float x=p.x/d+.6*sin(z*.18), row=z*.9; float roller=cos(row*TAU), seam=line(sin(row*PI),.045,c.px/d);
141 float teeth=pow(.5+.5*cos(x*6+c.t*.6),5.f), band=glow(abs(x)-3.5,.13);
142 float3 floor=paint(z*.025+x*.05,f)*(.18+.6*max(0.f,roller)+teeth*.25+band*1.4);
143 floor+=paint(.85,f)*(seam+.3*pow(max(0.f,roller),12.f))*(1+c.b.x*.6);
144 return mix(paint(.7,f)*(.22+.1*sin(p.x*3+c.t*.3)),floor,smoothstep(-.04f,.04f,.5-p.y));
145}
146NATIVE_EFFECT(rubyRollway)
147
148float3 neonRegatta(Ctx c, constant NativeFrame &f) {
149
150 float2 p=c.uv/c.size; float d=max(.15-p.y,.045f), z=1.6/d+c.travel*2;
151 float x=p.x/d; float wake=sin(z*2-abs(x)*2.6+c.b.x*sin(x)*2), wave=sin(x*1.5+z*.9+c.t*.5);
152 float foam=pow(max(0.f,wake),10.f), spec=pow(max(0.f,cos(wave*3)),12.f);
153 float buoys=glow(abs(x)-3,.17)*pow(.5+.5*cos(z*3),7.f);
154 float3 water=paint(z*.016+x*.03,f)*(.2+(.5+.5*wave)*.35+foam*.8+spec*.5+buoys);
155 float3 sky=paint(.65+p.x*.02,f)*(.16+.2*pow(.5+.5*sin(p.x+p.y*3+c.t*.1),3.f));
156 return mix(sky,water,smoothstep(-.03f,.05f,.15-p.y));
157}
158NATIVE_EFFECT(neonRegatta)
159
160float3 radiantRunway(Ctx c, constant NativeFrame &f) {
161
162 float2 p=c.uv/c.size; float d=max(.2-p.y,.04f), z=2/d+c.travel*3;
163 float x=p.x/d, linework=glow(x,.035)*pow(.5+.5*cos(z*4),6.f);
164 float lamps=glow(abs(x)-3,.13)*pow(.5+.5*cos(z*2.5),12.f);
165 float tarmac=exp(-pow(x*.24,4.f));
166 float3 floor=paint(z*.013,f)*(.2*tarmac+linework*2+lamps*2.5);
167 floor+=paint(.85,f)*tarmac*pow(.5+.5*sin(z*1.1+x*3+c.b.y),8.f)*.35;
168 float cloud=.5+.5*sin(p.x*2+sin(p.y*3+c.t*.3));
169 return mix(paint(.65+cloud*.2,f)*(.15+cloud*.3),floor,smoothstep(-.03f,.05f,.2-p.y));
170}
171NATIVE_EFFECT(radiantRunway)
172
173float3 electricViaduct(Ctx c, constant NativeFrame &f) {
174
175 float2 p=c.uv/c.size; float r=max(length(p*float2(.8,1)),.05f), z=2.3/r+c.travel*2.3;
176 float a=atan2(p.y,p.x*.8), ribs=line(sin(z*1.8+.8*cos(a*2)),.085,c.px/r);
177 float span=glow(sin(a*4+z*.16+c.t*.2),.075+c.b.w*.04);
178 float window=pow(.5+.5*cos(a*8),5.f)*pow(.5+.5*cos(z*3.6),4.f);
179 float3 col=paint((.5+.3*sin(a))+z*.02,f)*(.22+ribs+span*.8+window*.6);
180 return col*smoothstep(.025f,.15f,r)+deep(.7,f)*.08;
181}
182NATIVE_EFFECT(electricViaduct)
183
184float3 orbitExpress(Ctx c, constant NativeFrame &f) {
185
186 float3 col=deep(.5,f)*.18;
187 for(int k=0;k<8;++k){float2 s=layerSlot(k,8,c.travel*.15); float sc=layerScale(s.x,3.2)/c.size;
188 float2 p=rot(c.uv*sc-float2(sin(s.y*.3),cos(s.y*.5))*.25,s.y*.4+c.t*.15);
189 float orbit=length(p/float2(1.4,.8))-(1.3+.12*c.b[int(s.y-4*floor(s.y/4))]*sin(atan2(p.y,p.x)*5));
190 float rim=glow(orbit,.06), studs=pow(.5+.5*cos(atan2(p.y,p.x)*16+s.y+c.t*.4),8.f);
191 col+=paint(s.y*.13,f)*(rim*(.8+studs*1.2)+glow(orbit,.25)*.18)*layerFade(s.x);
192 }return col;
193}
194NATIVE_EFFECT(orbitExpress)
195
196float3 moltenHighway(Ctx c, constant NativeFrame &f) {
197
198 float2 p=c.uv/c.size; float d=max(.35-p.y,.04f), z=1.9/d+c.travel*2;
199 float2 q=float2(p.x/d,z); float lava=sin(q.x*2+sin(q.y*.9)*2)+cos(q.y*2+sin(q.x));
200 lava+=c.b.x*sin(q.x*4+q.y)*.65; float crust=smoothstep(.15f,.7f,lava);
201 float crack=glow(lava-.2,.13), heat=pow(.5+.5*sin(q.x*3-q.y*.7+c.t*.4),5.f);
202 float3 floor=paint(.1+q.y*.012,f)*(crack*1.8+(1-crust)*(.4+heat*.4))+deep(.5,f)*crust*.22;
203 float embers=pow(.5+.5*sin(p.x*8+p.y*11+c.t*.8),16.f)*.3;
204 return mix(paint(.65,f)*(.2+embers),floor,smoothstep(-.03f,.05f,.35-p.y));
205}
206NATIVE_EFFECT(moltenHighway)
207
208float3 violetFlight(Ctx c, constant NativeFrame &f) {
209
210 float3 col=paint(.3,f)*.14;
211 for(int k=0;k<7;++k){float2 s=layerSlot(k,7,c.travel*.14); float sc=layerScale(s.x,3)/c.size;
212 float2 p=rot(c.uv*sc,c.t*.15+s.y*.37); p.y-=.3*sin(s.y*.5+c.t*.4);
213 float delta=abs(p.x)*.7+p.y, wing=glow(delta-.8,.06+.06*c.b[int(s.y-4*floor(s.y/4))]);
214 float wingfill=exp(-abs(delta-.8)*4)*exp(-abs(p.x)*.3);
215 float braces=line(sin(p.x*5+s.y),.06,c.px*sc)*wingfill;
216 col+=paint(s.y*.13+p.x*.04,f)*(wing*1.8+wingfill*.5+braces*.4)*layerFade(s.x);
217 }return col;
218}
219NATIVE_EFFECT(violetFlight)
220
221float3 emeraldLaunch(Ctx c, constant NativeFrame &f) {
222
223 float2 p=c.uv/c.size; float r=max(length(p),.05f), a=atan2(p.y,p.x), z=2.2/r+c.travel*2.5;
224 float petal=.5+.5*cos(a*7+z*.22+c.t*.15), cut=sin(z*2.4+petal*3);
225 float ribs=line(cut,.08+c.b.z*.04,c.px/r), veins=line(sin(a*28-z*.8),.045,c.px/r);
226 float tissue=petal*(.5+.5*sin(z*1.2+sin(a*7)));
227 float3 col=paint((.5+.3*sin(a))+z*.011,f)*(.16+tissue*.6+ribs*1.3+veins*.35);
228 return col*smoothstep(.03f,.16f,r)+deep(.4,f)*.12;
229}
230NATIVE_EFFECT(emeraldLaunch)
231
232float3 coralDriftway(Ctx c, constant NativeFrame &f) {
233
234 float2 p=c.uv/c.size; float r=max(length(p),.06f), a=atan2(p.y,p.x), z=1.6/r+c.travel*1.5;
235 float branch=sin(a*6+z*.18+c.t*.1)+.35*sin(a*17-z*.5);
236 float coral=glow(branch,.16+c.b.y*.08), bubbles=pow(.5+.5*cos(z*4+sin(a*12)),10.f);
237 float water=.5+.5*sin(a*3-z*.7+sin(z*.3));
238 float3 col=paint(.45+water*.15,f)*(.2+water*.3);
239 col+=paint((.5+.3*sin(a))+z*.02,f)*(coral*(.8+bubbles*.9)+bubbles*.2);
240 return col*smoothstep(.03f,.15f,r)+paint(.65,f)*.1;
241}
242NATIVE_EFFECT(coralDriftway)
243
244float3 azureAscent(Ctx c, constant NativeFrame &f) {
245
246 float2 p=rot(c.uv/c.size,-.3); float d=max(.6-p.y,.04f), z=2/d+c.travel*2;
247 float x=p.x/d; float zig=abs(fract(z*.7+x*.15)-.5), stair=line(zig-.4,.06,c.px/d);
248 float tread=.5+.5*cos(z*4.4+x*.9), rail=glow(abs(x)-3,.13);
249 float3 floor=paint(x*.07+z*.018,f)*(.2+tread*.4+stair+rail);
250 floor+=paint(.85,f)*pow(.5+.5*cos(x*3-z+c.b.z*sin(x)),12.f)*.5;
251 return mix(paint(.7,f)*(.2+.12*sin(p.x*2+c.t*.2)),floor,smoothstep(-.02f,.05f,.6-p.y));
252}
253NATIVE_EFFECT(azureAscent)
254
255float3 festivalCruise(Ctx c, constant NativeFrame &f) {
256
257 float2 p=c.uv/c.size; float r=max(length(p),.055f), a=atan2(p.y,p.x), z=2.5/r+c.travel*2;
258 float2 q=float2(a*7/PI+.1*sin(z*.4),z*.8), id=floor(q), l=fract(q)-.5;
259 l.x+=sin(id.y+c.t*.7)*.07; float lantern=length(l/float2(.3,.4));
260 float light=fill(lantern-.85,c.px/r), cage=line(sin(l.x*23),.08,c.px/r)*light;
261 float cord=glow(l.x,.025), glowlight=glow(lantern,.45);
262 float3 col=paint(.3*sin(id.x*TAU/14)+id.y*.09,f)*(.12+light*(.8-cage*.4)*(1+c.b[int(id.y-4*floor(id.y/4))]*.7)+glowlight*.2);
263 col+=paint(.65,f)*cord*.25;
264 return col*smoothstep(.03f,.15f,r)+deep(.3,f)*.1;
265}
266NATIVE_EFFECT(festivalCruise)
267
268float3 quantumSled(Ctx c, constant NativeFrame &f) {
269
270 float2 p=c.uv/c.size; float r=max(length(p*float2(1,.7)),.055f), a=atan2(p.y*.7,p.x), z=2/r+c.travel*2.1;
271 float braid=sin(a*3+z*.55+c.t*.2), companion=sin(a*3-z*.55-c.t*.2);
272 float rails=glow(braid,.09)+glow(companion,.09), ties=line(sin(z*3),.07,c.px/r);
273 float ice=.5+.5*cos(a*6+z*.4+c.b.x*sin(a*11));
274 float3 col=paint((.5+.3*sin(a))+z*.017,f)*(.15+ice*.35+rails+ties*.3);
275 return col*smoothstep(.03f,.17f,r)+paint(.8,f)*.08;
276}
277NATIVE_EFFECT(quantumSled)
278
279float3 citrusSurge(Ctx c, constant NativeFrame &f) {
280
281 float2 p=c.uv/c.size; float r=max(length(p),.055f), a=atan2(p.y,p.x), z=2.6/r+c.travel*2;
282 float juice=sin(a*4+sin(z*.8+a*2)*2+c.t*.3)+cos(z*1.1-a*3);
283 juice+=c.b.y*sin(a*13+z)*.7; float flesh=.5+.5*sin(juice*3);
284 float peel=line(sin(z*2.6+.6*cos(a*8)),.07,c.px/r), gleam=pow(max(0.f,cos(juice*3)),14.f);
285 float3 col=paint(juice*.07+z*.013,f)*(.2+flesh*.6+peel*.7);
286 col+=paint(.85,f)*gleam*(.9+c.b.w*.5);
287 return col*smoothstep(.025f,.14f,r)+deep(.6,f)*.1;
288}
289NATIVE_EFFECT(citrusSurge)
290
291float3 starlightPursuit(Ctx c, constant NativeFrame &f) {
292
293 float2 p=c.uv/c.size; float r=max(length(p),.04f), a=atan2(p.y,p.x), z=2.8/r+c.travel*3;
294 float drift=a+z*.12+c.t*.1; float lane=pow(.5+.5*cos(drift*15),8.f);
295 float star=pow(.5+.5*sin(z*4+floor(drift*8)*1.7),14.f)*lane;
296 float streak=lane*pow(.5+.5*cos(z*.9),4.f), canyon=.5+.5*sin(a*4+z*.4);
297 float3 col=paint((.5+.3*sin(drift))+z*.013,f)*(.15+canyon*.25+streak*.65+star*(1.5+c.b.w));
298 return col*smoothstep(.02f,.12f,r)+paint(.8,f)*.1;
299}
300NATIVE_EFFECT(starlightPursuit)