PulseCanvas / app · pulsecanvas.ai / Sources / PulseCanvas / Resources / NativeExpansionFestival.metal
| 1 | // Original PulseCanvas dancing surfaces, ribbons, assemblies and liquid forms. |
| 2 | |
| 3 | float3 radiantRondo(Ctx c, constant NativeFrame &f) { |
| 4 | |
| 5 | float2 q=c.uv*2.2/c.size, id=floor(q),p=fract(q)-.5;float phase=id.x*.9+id.y*1.3; |
| 6 | float a=atan2(p.y,p.x)+c.t*.4,r=length(p), band=c.b[int(abs(id.x+id.y))%4]; |
| 7 | float radius=.28+.045*sin(c.t*1.3+phase)+band*.08*sin(a*5+phase); |
| 8 | float rim=glow(r-radius,.025), hoops=glow(r-radius*.65,.018), spokes=line(sin(a*8),.06,c.px)*exp(-r*5); |
| 9 | return paint(phase*.1+a*.025,f)*(.14+rim+hoops*.7+spokes*.4)+deep(.5,f)*.1; |
| 10 | } |
| 11 | NATIVE_EFFECT(radiantRondo) |
| 12 | |
| 13 | float3 fuchsiaFandango(Ctx c, constant NativeFrame &f) { |
| 14 | |
| 15 | float2 p=c.uv/c.size;float3 col=deep(.5,f)*.2; |
| 16 | for(int k=0;k<6;++k){float y=float(k-3)*.55;float phase=c.t*.9+float(k)*1.2; |
| 17 | float bend=sin(p.x*2.4+phase)*(.16+c.b[k%4]*.22)+.08*sin(p.x*6-phase); |
| 18 | float d=p.y-y-bend;float ribbon=glow(d,.1), satin=pow(max(0.f,cos(d*15)),10.f)*exp(-abs(d)*8); |
| 19 | col+=paint(float(k)*.15+p.x*.03,f)*(ribbon*.7+satin*.7); |
| 20 | }return col; |
| 21 | } |
| 22 | NATIVE_EFFECT(fuchsiaFandango) |
| 23 | |
| 24 | float3 satinShuffle(Ctx c, constant NativeFrame &f) { |
| 25 | |
| 26 | float2 p=rot(c.uv/c.size,.22*sin(c.t*.3));float3 col=deep(.5,f)*.15; |
| 27 | for(int k=0;k<5;++k){float a=float(k)*PI/5, phase=c.t*.5+float(k)*.8; |
| 28 | float2 q=rot(p,a);float d=sin(q.x*3+phase)+q.y*.6+c.b[k%4]*sin(q.x*7-phase)*.3; |
| 29 | float weave=glow(d,.09), stitch=line(sin(q.y*13+phase),.055,c.px)*weave; |
| 30 | col+=paint(float(k)*.19+q.x*.025,f)*(weave*.85+stitch*.35); |
| 31 | }return col; |
| 32 | } |
| 33 | NATIVE_EFFECT(satinShuffle) |
| 34 | |
| 35 | float3 chromaticCharleston(Ctx c, constant NativeFrame &f) { |
| 36 | |
| 37 | float2 q=c.uv*3/c.size;float2 id=floor(q),p=fract(q)-.5;float phase=id.x*1.2+id.y*.8; |
| 38 | p=rot(p,.5*sin(c.t+phase));float band=c.b[int(abs(id.x*2+id.y))%4]; |
| 39 | float2 radii=float2(.13+.03*sin(c.t*1.8+phase),.29+band*.12); |
| 40 | float d=length(p/radii), body=fill(d-1,c.px*4), halo=glow(d-1,.12); |
| 41 | float seams=line(sin(p.y*30+c.t),.09,c.px*3)*body; |
| 42 | return paint(phase*.12,f)*(.14+body*(.65+band*.5)+halo*.5+seams*.3); |
| 43 | } |
| 44 | NATIVE_EFFECT(chromaticCharleston) |
| 45 | |
| 46 | float3 prismaticPolka(Ctx c, constant NativeFrame &f) { |
| 47 | |
| 48 | float2 q=c.uv*2.4/c.size,id=floor(q),p=fract(q)-.5;float phase=id.x*.8+id.y*1.5; |
| 49 | p.y-=.1*sin(c.t*1.5+phase);p=rot(p,c.t*.3+.25*sin(phase)); |
| 50 | float a=atan2(p.y,p.x),band=c.b[int(abs(id.x+id.y*2))%4]; |
| 51 | float d=length(p)*cos(fmod(a+TAU,TAU/3)-PI/3)-(.2+band*.04); |
| 52 | float body=fill(d,c.px*3),facet=.5+.5*cos(a*3),rim=glow(d,.025); |
| 53 | return paint(phase*.1+a*.04,f)*(.13+body*(.3+facet*.65)+rim*.6); |
| 54 | } |
| 55 | NATIVE_EFFECT(prismaticPolka) |
| 56 | |
| 57 | float3 neonBolero(Ctx c, constant NativeFrame &f) { |
| 58 | |
| 59 | float2 p=c.uv/c.size;float3 col=deep(.4,f)*.18; |
| 60 | for(int k=0;k<5;++k){float2 q=rot(p,c.t*.13+float(k)*.37);q+=float2(sin(c.t*.4+float(k)),cos(c.t*.3+float(k)))*.2; |
| 61 | float2 tile=fract(q*(1.3+float(k)*.25))-.5;float d=sdBox2(tile,float2(.32,.22)+c.b[k%4]*.025); |
| 62 | float rim=glow(d,.016), cross=line(tile.x+tile.y,.02,c.px)*fill(d,c.px); |
| 63 | col+=paint(float(k)*.19+q.x*.02,f)*(rim*.6+cross*.18); |
| 64 | }return col; |
| 65 | } |
| 66 | NATIVE_EFFECT(neonBolero) |
| 67 | |
| 68 | float3 pearlescentSwing(Ctx c, constant NativeFrame &f) { |
| 69 | |
| 70 | float2 q=c.uv*2.1/c.size,id=floor(q);float3 col=paint(.6,f)*.12; |
| 71 | for(int y=-1;y<=1;++y)for(int x=-1;x<=1;++x){float2 cell=id+float2(x,y);float ph=cell.x*1.1+cell.y*.7; |
| 72 | float2 orbit=float2(cos(c.t*.8+ph),sin(c.t*.8+ph))*float2(.28,.16);float2 p=q-cell-.5-orbit; |
| 73 | float band=c.b[int(abs(cell.x+cell.y))%4],r=.22+band*.08; |
| 74 | float sphere=fill(length(p)-r,c.px*2),normal=sqrt(max(0.f,1-dot(p,p)/(r*r))); |
| 75 | float spec=pow(max(0.f,normal*.85-p.x*.5+p.y*.3),18.f); |
| 76 | col+=paint(ph*.15,f)*sphere*(.3+normal*.5)+paint(.9,f)*spec*sphere*.7; |
| 77 | }return col; |
| 78 | } |
| 79 | NATIVE_EFFECT(pearlescentSwing) |
| 80 | |
| 81 | float3 solarSway(Ctx c, constant NativeFrame &f) { |
| 82 | |
| 83 | float2 p=c.uv/c.size;float sun=sin(p.x*3+sin(p.y*2+c.t*.6)*1.6); |
| 84 | sun+=.7*cos(p.y*4-sin(p.x*2-c.t*.4))+c.b.x*sin(p.x*7+p.y*5)*.8; |
| 85 | float waves=.5+.5*sin(sun*3), veins=line(sin(sun*6+p.x*2),.09,c.px*6); |
| 86 | float gleam=pow(max(0.f,cos(sun*3)),14.f); |
| 87 | return paint(sun*.12+p.x*.025,f)*(.2+waves*.6+veins*.4)+paint(.85,f)*gleam*.85; |
| 88 | } |
| 89 | NATIVE_EFFECT(solarSway) |
| 90 | |
| 91 | float3 liquidLimbo(Ctx c, constant NativeFrame &f) { |
| 92 | |
| 93 | float2 p=c.uv*2/c.size;float wave=sin(p.y*1.7+c.t*.7)*(.35+c.b.x*.4); |
| 94 | p.x+=wave; p.y+=sin(p.x*1.9-c.t*.5)*(.2+c.b.y*.3); |
| 95 | float tile=sin(p.x*PI)*sin(p.y*PI),facet=.5+.5*tanh(tile*4); |
| 96 | float seam=glow(tile,.065),glass=pow(.5+.5*cos(p.x*2.5+p.y*1.8),10.f); |
| 97 | return paint(facet*.5+p.y*.025,f)*(.2+facet*.55+seam*.7)+paint(.9,f)*glass*.65; |
| 98 | } |
| 99 | NATIVE_EFFECT(liquidLimbo) |
| 100 | |
| 101 | float3 violetVogue(Ctx c, constant NativeFrame &f) { |
| 102 | |
| 103 | float2 p=c.uv/c.size;float3 col=deep(.6,f)*.18; |
| 104 | for(int k=0;k<8;++k){float phase=float(k)*.85+c.t*.6;float center=sin(p.y*1.4+phase)*.5+float(k-4)*.35; |
| 105 | center+=c.b[k%4]*sin(p.y*4-phase)*.17;float d=p.x-center; |
| 106 | float silk=glow(d,.08),pleat=.5+.5*sin(d*18+p.y*3+phase); |
| 107 | float stitch=line(sin(p.y*16+phase),.07,c.px)*silk; |
| 108 | col+=paint(float(k)*.13+p.y*.03,f)*(silk*(.35+pleat*.5)+stitch*.2); |
| 109 | }return col; |
| 110 | } |
| 111 | NATIVE_EFFECT(violetVogue) |
| 112 | |
| 113 | float3 discoRipple(Ctx c, constant NativeFrame &f) { |
| 114 | |
| 115 | float2 p=c.uv/c.size;float3 col=deep(.5,f)*.15; |
| 116 | for(int k=0;k<5;++k){float phase=float(k)*TAU/5;float2 origin=float2(cos(phase+c.t*.2),sin(phase-c.t*.15))*.8; |
| 117 | float r=length(p-origin);float wave=sin(r*(7+float(k))-c.t*(1.2+float(k)*.2)); |
| 118 | wave+=c.b[k%4]*sin(r*18+phase)*.6;float rim=glow(wave,.07), ripple=.5+.5*wave; |
| 119 | col+=paint(float(k)*.17+r*.02,f)*(rim*.55+ripple*.12)*exp(-r*.35); |
| 120 | }return col; |
| 121 | } |
| 122 | NATIVE_EFFECT(discoRipple) |
| 123 | |
| 124 | float3 gildedGroove(Ctx c, constant NativeFrame &f) { |
| 125 | |
| 126 | float2 p=c.uv/c.size;float3 col=deep(.5,f)*.2; |
| 127 | for(int k=0;k<6;++k){float phase=float(k)*PI/3;float center=sin(p.x*2+c.t*.7+phase)*.45+cos(p.x*.9-c.t*.4+phase)*.3; |
| 128 | float d=p.y-float(k-3)*.28-center-c.b[k%4]*sin(p.x*5+phase)*.16; |
| 129 | float gold=glow(d,.045),filament=glow(d-.09,.012),shadow=glow(d+.06,.1)*.2; |
| 130 | col+=paint(float(k)*.15+p.x*.02,f)*(gold*.9+filament*.65+shadow); |
| 131 | }return col; |
| 132 | } |
| 133 | NATIVE_EFFECT(gildedGroove) |
| 134 | |
| 135 | float3 auroraWaltz(Ctx c, constant NativeFrame &f) { |
| 136 | |
| 137 | float2 q=c.uv*2.4/c.size;float4 h=hexCell(q);float2 p=rot(h.xy,c.t*.2+h.z*.8); |
| 138 | float a=atan2(p.y,p.x),r=length(p), band=c.b[int(abs(h.z+h.w))%4]; |
| 139 | float flower=r-(.28+.055*cos(a*3+c.t*.7)+band*.06*sin(a*6)); |
| 140 | float petal=fill(flower,c.px*2),vein=line(sin(a*3),.06,c.px*2)*petal; |
| 141 | float highlight=pow(max(0.f,1-r*2),6.f); |
| 142 | return paint(h.z*.12+h.w*.09+a*.035,f)*(.13+petal*.55+vein*.35)+paint(.85,f)*highlight*.6; |
| 143 | } |
| 144 | NATIVE_EFFECT(auroraWaltz) |
| 145 | |
| 146 | float3 elasticAnthem(Ctx c, constant NativeFrame &f) { |
| 147 | |
| 148 | float2 q=c.uv*2.3/c.size;float4 v=voronoi(q,.85,c.t*.8); |
| 149 | float band=c.b[int(abs(v.z*2+v.w))%4],membrane=glow(v.y-v.x,.055+band*.05); |
| 150 | float bubble=exp(-v.x*v.x*(5+band*3)),rim=glow(v.x-.25-band*.05,.04); |
| 151 | float flow=.5+.5*sin(q.x*3+q.y*2+c.t*.4); |
| 152 | return paint(v.z*.16+v.w*.09,f)*(.14+membrane*.9+bubble*.45+rim*.4)+paint(.85,f)*bubble*flow*.2; |
| 153 | } |
| 154 | NATIVE_EFFECT(elasticAnthem) |
| 155 | |
| 156 | float3 crimsonCadence(Ctx c, constant NativeFrame &f) { |
| 157 | |
| 158 | float2 q=c.uv*1.8/c.size,id=floor(q),p=fract(q)-.5;float phase=id.x*.7+id.y*1.4; |
| 159 | float a=atan2(p.y,p.x)+c.t*.4+.15*sin(phase),r=length(p),band=c.b[int(abs(id.x+id.y))%4]; |
| 160 | float fan=pow(.5+.5*cos(a*9+r*5),3.f);float disc=fill(r-.43,c.px*2); |
| 161 | float ribs=line(sin(a*18+r*3+band*sin(a*9)),.075,c.px*3)*disc; |
| 162 | return paint(phase*.12+a*.03,f)*(.13+fan*disc*.65+ribs*.5)+paint(.85,f)*glow(r-.43,.025)*.6; |
| 163 | } |
| 164 | NATIVE_EFFECT(crimsonCadence) |
| 165 | |
| 166 | float3 sapphireStomp(Ctx c, constant NativeFrame &f) { |
| 167 | |
| 168 | float2 p=c.uv*2/c.size;float row=floor(p.y),y=fract(p.y)-.5; |
| 169 | float phase=c.t*.8+row*1.4,band=c.b[int(abs(row))%4]; |
| 170 | float zig=abs(fract(p.x*.8+phase*.15)-.5)*2-.5; |
| 171 | float wave=y-zig*(.4+band*.35)-.1*sin(p.x*5-phase); |
| 172 | float ridge=glow(wave,.07),face=exp(-abs(wave+.15)*4), seam=line(sin(p.x*PI*1.6+phase*.3),.07,c.px)*face; |
| 173 | return paint(row*.16+p.x*.035,f)*(.14+ridge+face*.45+seam*.35); |
| 174 | } |
| 175 | NATIVE_EFFECT(sapphireStomp) |
| 176 | |
| 177 | float3 coralCrescendo(Ctx c, constant NativeFrame &f) { |
| 178 | |
| 179 | float2 q=c.uv*1.7/c.size;float4 h=hexCell(q);float3 col=paint(h.z*.12+h.w*.08,f)*.15; |
| 180 | for(int k=0;k<6;++k){float a=float(k)*PI/3+c.t*.35+h.z*.4,band=c.b[k%4]; |
| 181 | float orbit=.29+.025*sin(c.t+h.w)+band*.04;float2 center=float2(cos(a),sin(a))*orbit; |
| 182 | float r=.115+band*.035,d=length(h.xy-center)-r; |
| 183 | float sphere=fill(d,c.px*2),normal=sqrt(max(0.f,1-pow(length(h.xy-center)/r,2.f))); |
| 184 | col+=paint(float(k)*.16+h.z*.1,f)*sphere*(.3+normal*.6)+paint(.85,f)*glow(d,.015)*.3; |
| 185 | }return col; |
| 186 | } |
| 187 | NATIVE_EFFECT(coralCrescendo) |
| 188 | |
| 189 | float3 electricEncore(Ctx c, constant NativeFrame &f) { |
| 190 | |
| 191 | float2 q=c.uv*2.6/c.size; |
| 192 | q+=float2(sin(q.y*1.4+c.t*.6),cos(q.x*1.6-c.t*.5))*(.18+c.b.y*.35); |
| 193 | float2 id=floor(q),p=fract(q)-.5;float phase=id.x*.7+id.y*1.1; |
| 194 | float wires=line(min(abs(p.x),abs(p.y)),.025,c.px*3),diagonal=line(p.x+p.y,.02,c.px*3); |
| 195 | float node=glow(length(p),.1+c.b[int(abs(id.x+id.y))%4]*.04); |
| 196 | float charge=.4+.6*pow(.5+.5*sin(phase+c.t*1.1),4.f); |
| 197 | return paint(phase*.12,f)*(.14+wires*.6+diagonal*.25+node*charge); |
| 198 | } |
| 199 | NATIVE_EFFECT(electricEncore) |
| 200 | |
| 201 | float3 luminousLockstep(Ctx c, constant NativeFrame &f) { |
| 202 | |
| 203 | float2 q=rot(c.uv*2/c.size,.12*sin(c.t*.3)),id=floor(q),p=fract(q)-.5; |
| 204 | float phase=id.x*.8+id.y*1.2,band=c.b[int(abs(id.x*2+id.y))%4]; |
| 205 | p=rot(p,.3*sin(c.t*.8+phase));float kite=abs(p.x)*1.3+abs(p.y)-(.42+band*.055); |
| 206 | float body=fill(kite,c.px*3),crease=line(p.x,.02,c.px*3)*body; |
| 207 | float facet=.3+.6*saturate(.5+p.x*1.7-p.y*.5),rim=glow(kite,.02); |
| 208 | return paint(phase*.14+p.x*.08,f)*(.14+body*facet+crease*.4+rim*.55); |
| 209 | } |
| 210 | NATIVE_EFFECT(luminousLockstep) |
| 211 | |
| 212 | float3 festivalFinale(Ctx c, constant NativeFrame &f) { |
| 213 | |
| 214 | float2 p=c.uv/c.size;float3 col=deep(.5,f)*.16; |
| 215 | for(int k=0;k<4;++k){float phase=float(k)*PI*.5;float2 q=rot(p,phase+c.t*.1); |
| 216 | float wave=sin(q.x*2.5+sin(q.y*1.7+c.t*.5+phase)*1.3)+cos(q.y*3-c.t*.7+phase); |
| 217 | wave+=c.b[k]*sin(q.x*7-q.y*4)*.65;float ribbon=glow(wave,.12),core=pow(max(0.f,cos(wave*4)),12.f); |
| 218 | col+=paint(float(k)*.23+wave*.05,f)*(ribbon*.65+core*.25); |
| 219 | }return col; |
| 220 | } |
| 221 | NATIVE_EFFECT(festivalFinale) |