clipoox-render 0.4.3 → 0.4.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +4 -3
- package/scripts/render-local.mjs +5160 -1446
- package/web/assets/FxEmbed-DbfuM8Yo.js +1 -0
- package/web/assets/MotionEmbed-CBQ-8Tzh.js +1 -0
- package/web/assets/PluginStore-OOEx0lP5.js +3 -0
- package/web/assets/ShotComposer-Cng515xa.js +287 -0
- package/web/assets/{ShotComposer-VixLbeMe.css → ShotComposer-deLi4grZ.css} +1 -1
- package/web/assets/TemplateEmbed-hjwM2b0o.js +2 -0
- package/web/assets/{TimelinePlugins-BYZ9y4m3.js → TimelinePlugins-D-NakABP.js} +4 -4
- package/web/assets/TimelineShotFx-D3kGhHN3.js +2 -0
- package/web/assets/TransitionEmbed-DR26yI3a.js +1 -0
- package/web/assets/{Whiteboard-BP_DvIAV.js → Whiteboard-BhxY0D0Z.js} +3 -3
- package/web/assets/aerial-BisYSXzG.js +2 -0
- package/web/assets/agentTools-CPFQeiDP.js +2 -0
- package/web/assets/aiInbetween-AOOM1e6p.js +2 -0
- package/web/assets/analyzerRun-Dtp2o7gT.js +1 -0
- package/web/assets/analyzerSandbox-BG_3Cea1.js +33 -0
- package/web/assets/api-BFN7blbw.js +3158 -0
- package/web/assets/auraTrack-D_gxHNVe.js +1 -0
- package/web/assets/breakthrough-0qFpZW-V.js +2 -0
- package/web/assets/{cameraPresets-CYw0OdM3.js → cameraPresets-eK3mP7qb.js} +1 -1
- package/web/assets/cameraTracker-BAQHuTV-.js +72 -0
- package/web/assets/captionLayout-CWPcbid-.js +1 -0
- package/web/assets/clientExport-DvpTTndR.js +1 -0
- package/web/assets/clientJobs-CIrYTMpn.js +2 -0
- package/web/assets/clientJobs-CuuUyhEy.js +1 -0
- package/web/assets/cutoutClean-CLYYAuXg.js +1 -0
- package/web/assets/depthEstimate-B7D7cGCl.js +1 -0
- package/web/assets/directorTools-CJD4Huqk.js +1 -0
- package/web/assets/distortFrames-BLt1icUb.js +2 -0
- package/web/assets/{distortGL-QalhICvi.js → distortGL-BA5molk-.js} +3 -3
- package/web/assets/draco_decoder-C32yEggz.wasm +0 -0
- package/web/assets/draco_decoder-Z1_iN-Ht.wasm +0 -0
- package/web/assets/draco_decoder-fzg4nYZr.js +34 -0
- package/web/assets/draco_wasm_wrapper-DxJM36Ib.js +117 -0
- package/web/assets/draco_wasm_wrapper-fZCQGLGb.js +116 -0
- package/web/assets/editTools-NKLsWZD1.js +1 -0
- package/web/assets/{engine-BedcnK45.js → engine-DioUF2mX.js} +1 -1
- package/web/assets/exportGlb-BOdI9cVS.js +2 -0
- package/web/assets/faceTracker-D7CbF-qX.js +1 -0
- package/web/assets/fightDirector-CYP8jxo8.js +1 -0
- package/web/assets/fightDrama-DIPcRKnc.js +2 -0
- package/web/assets/focusTool-vfabPqQ5.js +1 -0
- package/web/assets/{frameSink-DeM8xC8_.js → frameSink-DYs2gTzq.js} +3 -3
- package/web/assets/glTransitionSources.generated-DM5sRMX2.js +3695 -0
- package/web/assets/gltfLoader-U0Eebg7v.js +2 -0
- package/web/assets/{gpuCompose-CA3UmOl4.js → gpuCompose-DbnZuelB.js} +1 -1
- package/web/assets/gpuExport-CQ7ZhpsX.js +198 -0
- package/web/assets/handMatte-DIbMuqCu.js +1 -0
- package/web/assets/handTracker-DY_g5Xmg.js +2 -0
- package/web/assets/i18n-BJppIrtF.js +3 -0
- package/web/assets/index-BfrDwjDI.js +4247 -0
- package/web/assets/index-CKtv7gGE.js +9 -0
- package/web/assets/{index-D5oyVCRl.js → index-DxdDhmLR.js} +2 -2
- package/web/assets/layer-worker-DK67WH1a.js +5 -0
- package/web/assets/library-B6KsZUKq.js +1 -0
- package/web/assets/lottieLayer-C2YbiXhK.js +161 -0
- package/web/assets/{lottie_light_canvas-B-d7-ATe.js → lottie_light_canvas-DX9Wf-DS.js} +1 -1
- package/web/assets/main-B27kf5aL.css +1 -0
- package/web/assets/main-BKatDoGw.js +309 -0
- package/web/assets/mapBake-C-G7WpFM.js +1 -0
- package/web/assets/maskTrack-LMrwm5ub.js +1 -0
- package/web/assets/matteFixRun-B38CbeEt.js +1 -0
- package/web/assets/matteQuality-9X-jgJrH.js +1 -0
- package/web/assets/objectLocate-CKi3OTnL.js +1 -0
- package/web/assets/objectSegmenter-CziPuM61.js +1 -0
- package/web/assets/{objectTrack.worker-BlZkgpOX.js → objectTrack.worker-b7DJ-ub6.js} +196 -196
- package/web/assets/pathTracer-bqau16sX.js +2 -0
- package/web/assets/pendingMatte-CQb7jPg1.js +2 -0
- package/web/assets/personAi-CQntGDqK.js +2 -0
- package/web/assets/personHq-B1c0QVJT.js +2 -0
- package/web/assets/plateCamera-D7iLiNBy.js +1 -0
- package/web/assets/plateCameraMatch-BM88dx-a.js +2 -0
- package/web/assets/plateFollow-4iGUDTu1.js +2 -0
- package/web/assets/plateMatte-zTyuHHqh.js +2 -0
- package/web/assets/plugin-guide.en-DO_fHbzT.js +1 -0
- package/web/assets/plugin-guide.vi-CMJDxOhi.js +1 -0
- package/web/assets/pluginAutomation-DSg-sYLF.js +1 -0
- package/web/assets/poseTracker-DZl8l2qS.js +1 -0
- package/web/assets/productTools-B-jh8ukh.js +2 -0
- package/web/assets/remote-DJd9xWjn.js +963 -0
- package/web/assets/{rigTrack-urT3nDK0.js → rigTrack-XaMj1yaH.js} +1 -1
- package/web/assets/rotoMaskStore-DdpmT9C3.js +1 -0
- package/web/assets/{rotoMatte-C-2o3vv0.js → rotoMatte-i-cJTYmK.js} +1 -1
- package/web/assets/rotoscope-DqRSWmHR.js +1 -0
- package/web/assets/sceneTrack-Bbov7zET.js +1 -0
- package/web/assets/sceneTrack-DIPzBmMK.js +1 -0
- package/web/assets/{sceneTrack.worker-CT4uoTKn.js → sceneTrack.worker-Bav9h0pv.js} +180 -180
- package/web/assets/shot-worker-m-q77W9f.js +1 -0
- package/web/assets/{shotFxAgent-BFLkqs8v.js → shotFxAgent-DIMS7BGA.js} +2 -2
- package/web/assets/{skin-DY4QLaBI.js → skin-DrUzJE1u.js} +1 -1
- package/web/assets/{spark.module-DzziUgOj.js → spark.module-Y1SEI8Xz.js} +10 -10
- package/web/assets/spellDuel-DNnyQDVr.js +2 -0
- package/web/assets/store-GFMJzaWS.js +1 -0
- package/web/assets/surfaceLight-C--moyc9.js +1 -0
- package/web/assets/surfacePin-B4-1UqXD.js +2 -0
- package/web/assets/{textAnimators-DUZjhVGO.js → textAnimators-BVXTl8bU.js} +1 -1
- package/web/assets/{thumb-CS0ZuiGS.js → thumb-CTfDJgLp.js} +1 -1
- package/web/assets/timeline3d-Dn7PqmEe.js +2 -0
- package/web/assets/timeline3dExport-DCOr6ARB.js +1 -0
- package/web/assets/timelineComp-Dx_kED5V.js +1 -0
- package/web/assets/timelineOps-afzSo188.js +525 -0
- package/web/assets/timelineProps-eYgO6gs5.js +1 -0
- package/web/assets/timelineText-RKyRP988.js +1 -0
- package/web/assets/{titleArt-Drsrtfiv.js → titleArt-CUtA0C3I.js} +4 -4
- package/web/assets/{titleFrameBudget-CLZWaFHO.js → titleFrameBudget-X7HLSDre.js} +721 -704
- package/web/assets/titleFrames-aMG7HdVe.js +1 -0
- package/web/assets/{tool-DktQYmS6.js → tool-DpFjybaq.js} +1 -1
- package/web/assets/{tools-Co9aRDiT.js → tools-CeOU0p13.js} +1 -1
- package/web/assets/toonTools-DLmo37Z_.js +2 -0
- package/web/assets/trackAnchor-hAOtEhKO.js +1 -0
- package/web/assets/userFonts-1kuRjWOo.js +1 -0
- package/web/assets/{vfxAlpha-71tSN86T.js → vfxAlpha-DxS5-QwY.js} +2 -2
- package/web/assets/vfxBackground-CYpaQaTa.js +2 -0
- package/web/assets/videoExport-Cg4B2Nyh.js +1 -0
- package/web/assets/views-CUXyRb9x.js +1 -0
- package/web/assets/weaponDuel-nFECu9nk.js +1 -0
- package/web/assets/windowFrames-1wAkkWnv.js +1 -0
- package/web/layer-worker.html +3 -3
- package/web/shot-worker.html +41 -0
- package/web/assets/FxEmbed-BCmj9Q5C.js +0 -1
- package/web/assets/GLTFLoader-BHWu1lKg.js +0 -1
- package/web/assets/MotionEmbed-CEmbcq8Z.js +0 -1
- package/web/assets/PluginStore-C5hyahvG.js +0 -3
- package/web/assets/ShotComposer-0DUtMTVI.js +0 -287
- package/web/assets/TemplateEmbed-ANxSs7H5.js +0 -2
- package/web/assets/TimelineShotFx-q5PQwq-V.js +0 -2
- package/web/assets/TransitionEmbed-O6LInGWq.js +0 -1
- package/web/assets/aerial-CGLDKKtP.js +0 -2
- package/web/assets/agentTools-2Ghb80VH.js +0 -2
- package/web/assets/analyzerRun-DRgxrcJA.js +0 -1
- package/web/assets/analyzerSandbox-DuIVFnsk.js +0 -33
- package/web/assets/api-CJ8PdbfZ.js +0 -3168
- package/web/assets/auraTrack-DQw9sVU6.js +0 -1
- package/web/assets/breakthrough-BNj_iTDr.js +0 -2
- package/web/assets/captionLayout-DvDPTwO9.js +0 -1
- package/web/assets/clientExport-xhoXY6Dh.js +0 -1
- package/web/assets/depthEstimate-DEpeCojm.js +0 -1
- package/web/assets/directorTools-C5CpTmci.js +0 -1
- package/web/assets/distortFrames-Dia8O1NM.js +0 -2
- package/web/assets/editTools-CY_JrQfw.js +0 -1
- package/web/assets/exportEncode-QYsT9JBO.js +0 -1
- package/web/assets/exportGlb-TSj09XoV.js +0 -2
- package/web/assets/faceTracker-CnCWOwnJ.js +0 -1
- package/web/assets/fightDirector-DCI_FWTh.js +0 -1
- package/web/assets/fightDrama-Bg7uP_2Q.js +0 -2
- package/web/assets/gpuExport-D31azOQA.js +0 -198
- package/web/assets/handMatte-Dl-xVXFR.js +0 -1
- package/web/assets/handTracker-CplBsAFg.js +0 -2
- package/web/assets/layer-worker-DFuo32bk.js +0 -5
- package/web/assets/library-BufgA-Pl.js +0 -1
- package/web/assets/lottieLayer-DzbA3bHV.js +0 -158
- package/web/assets/main-Ca_CVxMz.css +0 -1
- package/web/assets/main-VVYiW8XD.js +0 -309
- package/web/assets/mapBake-BKOcEd0w.js +0 -1
- package/web/assets/maskTrack-CHGXtBRy.js +0 -1
- package/web/assets/matteFixRun-vgYrINet.js +0 -1
- package/web/assets/objectLocate-BJltm8Ob.js +0 -1
- package/web/assets/pendingMatte-BPyzzx4y.js +0 -2
- package/web/assets/personAi-gJu03SjU.js +0 -2
- package/web/assets/plateCamera-B2JvhjJw.js +0 -1
- package/web/assets/plateCameraMatch-ByB9nVQT.js +0 -2
- package/web/assets/plateFollow-C9S-l7RH.js +0 -2
- package/web/assets/plateMatte-J4qlNHnY.js +0 -2
- package/web/assets/plugin-guide.en-CGYh_9Su.js +0 -1
- package/web/assets/plugin-guide.vi-DMphSELb.js +0 -1
- package/web/assets/pluginAutomation-CkP3tA9r.js +0 -1
- package/web/assets/poseTracker-DGLbouqt.js +0 -1
- package/web/assets/productTools-CkaWF1bM.js +0 -2
- package/web/assets/remote-C7J0Tqhb.js +0 -1433
- package/web/assets/rotoMaskStore-DPziPKAN.js +0 -1
- package/web/assets/rotoscope-GvPFRUBg.js +0 -1
- package/web/assets/shot-worker-6dYkHPoL.js +0 -1
- package/web/assets/spellDuel-BD3m2ebA.js +0 -2
- package/web/assets/store-DW4E9xnW.js +0 -1
- package/web/assets/surfaceLight-aDSYU8Jg.js +0 -1
- package/web/assets/surfacePin-m83hCgGP.js +0 -2
- package/web/assets/timeline3d-DOw-CpZI.js +0 -2
- package/web/assets/timeline3dExport-BtYLU1pw.js +0 -1
- package/web/assets/timelineComp-B4GtoH2f.js +0 -1
- package/web/assets/timelineProps-D7MVutxu.js +0 -1
- package/web/assets/timelineText-BH09jfSM.js +0 -1
- package/web/assets/titleFrames-BI1DnLBn.js +0 -1
- package/web/assets/toonTools-CD9clJvN.js +0 -2
- package/web/assets/trackAnchor-sOjTtd3I.js +0 -1
- package/web/assets/userFonts-CwlKh9NR.js +0 -1
- package/web/assets/vfxBackground-Bq7lJvmZ.js +0 -2
- package/web/assets/videoExport-D4KbireJ.js +0 -1
- package/web/assets/views-ozVF4ABO.js +0 -1
- package/web/assets/weaponDuel-ZhX-tjGZ.js +0 -1
- package/web/assets/windowFrames-CpqX3kOM.js +0 -1
|
@@ -0,0 +1,3695 @@
|
|
|
1
|
+
import{bI as S,bJ as P}from"./api-BFN7blbw.js";import{j8 as R,j9 as M,hs as N,ht as U,ja as H,ai as j,iY as O}from"./titleFrameBudget-X7HLSDre.js";const q=Object.freeze({fisheye:.45,dispersion:.018,burst:.5,streak:.32,taps:8}),$=e=>[1+2.2*e,.88+1.8*e,.55+.9*e].map(t=>+t.toFixed(4));function z(e,t,o){const n=Math.max(e,Math.trunc(e*o/2)*2),a=Math.max(t,Math.trunc(t*o/2)*2);return{sw:n,sh:a,ox:Math.trunc((n-e)/2),oy:Math.trunc((a-t)/2)}}const Q=(e,t)=>({w:Math.max(2,Math.trunc(e/4)*2),h:Math.max(2,Math.trunc(t/4)*2)}),G=(e,t=q.taps)=>Array.from({length:t},(o,n)=>1+e*n/(t-1));function B(e){const t=+(q.fisheye*e).toFixed(4);let o=1+t;for(let n=0;n<20;n++)o-=(o*o*o-o*o-t)/(3*o*o-2*o);return{K:t,m:+o.toFixed(4)}}function x(e,t,o,n,a,i){const v=Math.max(0,Math.min(t-1.001,n)),f=Math.max(0,Math.min(o-1.001,a)),d=v|0,h=f|0,s=v-d,c=f-h,m=(h*t+d)*4+i,l=m+4,r=m+t*4,g=r+4;return(e[m]*(1-s)+e[l]*s)*(1-c)+(e[r]*(1-s)+e[g]*s)*c}const T=(e,t,o,n,a)=>[(n+e.ox+.5)*t/e.sw-.5,(a+e.oy+.5)*o/e.sh-.5];function _(e,t,o,n){const a=G(n).map(f=>z(t,o,f)),i=new Uint8ClampedArray(e.length),v=a.length;for(let f=0;f<o;f++)for(let d=0;d<t;d++){const h=(f*t+d)*4,s=[0,0,0,0];for(const c of a){const[m,l]=T(c,t,o,d,f);for(let r=0;r<4;r++)s[r]+=x(e,t,o,m,l,r)}for(let c=0;c<4;c++)i[h+c]=Math.round(s[c]/v)}return i}function ee(e,t,o,n,a){if(!(t>.001))return!1;const i=new Uint8ClampedArray(o);if(e==="fisheye"){const{K:v,m:f}=B(t),d=z(n,a,f),h=n/2,s=a/2,c=4/(n*n+a*a),m=new Uint8ClampedArray(i.length);for(let l=0;l<a;l++)for(let r=0;r<n;r++){const g=r-h,u=l-s,y=1+v*(g*g+u*u)*c,p=(l*n+r)*4,C=h+g*y+.5,A=s+u*y+.5;if(C>=0&&A>=0&&C<=n-1&&A<=a-1)for(let k=0;k<4;k++)m[p+k]=x(i,n,a,C,A,k)}for(let l=0;l<a;l++)for(let r=0;r<n;r++){const[g,u]=T(d,n,a,r,l),y=(l*n+r)*4;for(let p=0;p<4;p++)o[y+p]=x(m,n,a,g,u,p)}return!0}if(e==="dispersion"){const v=q.dispersion*t,f=z(n,a,1+2*v),d=z(n,a,1+v);for(let h=0;h<a;h++)for(let s=0;s<n;s++){const c=(h*n+s)*4,[m,l]=T(f,n,a,s,h),[r,g]=T(d,n,a,s,h);o[c]=x(i,n,a,m,l,0),o[c+1]=x(i,n,a,r,g,1)}return!0}return e==="zoom-streak"?(o.set(_(i,n,a,q.streak*t)),!0):!1}const w=new Map,I=new Map,D=new Map,E=new Set;async function ne(e){if(e.size>4e7)throw Error("File LUT tối đa 40 MB");const t=N(U(await e.text())),o=(t.title||e.name.replace(/\.cube$/i,"")).slice(0,80),n=await P({name:o,...H(t)});return w.set(n.id,t),E.forEach(a=>a()),n}function V(e){if(w.has(e))return Promise.resolve(w.get(e));let t=I.get(e);return t||(t=S(e).then(o=>{const n=R(o);return w.set(e,n),E.forEach(a=>a()),n}).finally(()=>I.delete(e)),I.set(e,t)),t}function K(e){const t=w.get(e.id);if(!t)return V(e.id).catch(()=>{}),null;const o=`${e.id}:${e.mix??1}`;let n=D.get(o);return n||(n=M(t,e.mix??1),D.set(o,n)),n}const b=new Map;function te(e){if(!e)return null;const t=e.lut?K(e.lut):null;if(e.lut&&!t)return null;if(!j(e.mixer))return t;const o=`${e.lut?`${e.lut.id}:${e.lut.mix??1}`:"-"}|${JSON.stringify(e.mixer)}`;let n=b.get(o);return n||(n=O(e.mixer,t),b.set(o,n),b.size>24&&b.delete(b.keys().next().value)),n}const L=Object.freeze({codec:"h264",quality:"recommended",container:"mp4"}),F={h264:{low:4,recommended:8,high:16},hevc:{low:2.5,recommended:5,high:10}};function X(e,{width:t,height:o,fps:n}){const a=e??L,i=t*o/(1920*1080)*(n/30);return Math.round(F[a.codec][a.quality]*1e6*Math.max(.2,i))}const oe=(e,t,o)=>Math.round((X(e,t)+16e4)*Math.max(0,o)/8),Y={low:.5,recommended:1,high:2};function ae(e,{width:t,height:o,fps:n},a){const i=e??L;return Math.round(Math.min(4e7,Math.max(5e5,a(t,o,n)*Y[i.quality]*(i.codec==="hevc"?F.hevc.recommended/F.h264.recommended:1))))}const re=Object.freeze({cube:`// Author: gre
|
|
2
|
+
// License: MIT
|
|
3
|
+
// Description: The two images are faces of a box that turns a quarter turn in perspective, the outgoing face darkening as it turns away, above a reflective floor
|
|
4
|
+
// Tags: 3d, cube, rotate, reflection
|
|
5
|
+
// @range(0, 1) Amount of perspective
|
|
6
|
+
const float persp = 0.7;
|
|
7
|
+
// @range(0, 1) How far the camera pulls back mid-turn, as a part of the frame
|
|
8
|
+
const float unzoom = 0.3;
|
|
9
|
+
// @range(0, 1) Strength of the reflection
|
|
10
|
+
const float reflection = 0.4;
|
|
11
|
+
// @range(0, 20) Gap between the box and its reflection, as a percentage of the frame height
|
|
12
|
+
const float floating = 3.0;
|
|
13
|
+
// @range(0, 1) How much the faces darken as they turn away, and the shadow on the floor
|
|
14
|
+
const float shading = 0.5;
|
|
15
|
+
|
|
16
|
+
const float PI = 3.141592653589793;
|
|
17
|
+
const float EDGE = 0.002;
|
|
18
|
+
|
|
19
|
+
// the ray (eye, dir) in the box's frame, the box turned by (c, s) around its vertical axis:
|
|
20
|
+
// returns (distance along the ray, horizontal position on the face, height, face) with face 0 for
|
|
21
|
+
// the outgoing image's face, 1 for the incoming one's, and a negative distance where it misses
|
|
22
|
+
vec4 hitBox(vec3 eye, vec3 dir, float w, float c, float s) {
|
|
23
|
+
vec2 pivot = vec2(0.5 * w);
|
|
24
|
+
vec2 e = eye.xz - pivot;
|
|
25
|
+
vec2 o = vec2(e.x * c + e.y * s, -e.x * s + e.y * c) + pivot;
|
|
26
|
+
vec2 d = vec2(dir.x * c + dir.z * s, -dir.x * s + dir.z * c);
|
|
27
|
+
vec2 inv = 1.0 / vec2(d.x < 0.0 ? min(d.x, -1e-6) : max(d.x, 1e-6), d.y < 0.0 ? min(d.y, -1e-6) : max(d.y, 1e-6));
|
|
28
|
+
vec2 t0 = (vec2(0.0) - o) * inv;
|
|
29
|
+
vec2 t1 = (vec2(w) - o) * inv;
|
|
30
|
+
vec2 tn = min(t0, t1);
|
|
31
|
+
vec2 tf = max(t0, t1);
|
|
32
|
+
float tin = max(tn.x, tn.y);
|
|
33
|
+
if (tin <= 0.0 || tin > min(tf.x, tf.y)) return vec4(-1.0);
|
|
34
|
+
vec2 hit = o + tin * d;
|
|
35
|
+
float y = eye.y + tin * dir.y;
|
|
36
|
+
if (y < 0.0 || y > 1.0) return vec4(-1.0);
|
|
37
|
+
// the face first entered: z = 0 is the outgoing face, x = 0 the incoming one, the others are hidden
|
|
38
|
+
if (tn.y >= tn.x) {
|
|
39
|
+
if (d.y <= 0.0) return vec4(-1.0);
|
|
40
|
+
return vec4(tin, hit.x / w, y, 0.0);
|
|
41
|
+
}
|
|
42
|
+
if (d.x <= 0.0) return vec4(-1.0);
|
|
43
|
+
return vec4(tin, 1.0 - hit.y / w, y, 1.0);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
vec4 transition(vec2 uv) {
|
|
47
|
+
float w = ratio;
|
|
48
|
+
float turn = progress * progress * (3.0 - 2.0 * progress);
|
|
49
|
+
float a = 0.5 * PI * turn;
|
|
50
|
+
float c = cos(a), s = sin(a);
|
|
51
|
+
if (progress >= 1.0) { c = 0.0; s = 1.0; }
|
|
52
|
+
// 0 at both ends, for exact images and hard edges there
|
|
53
|
+
float motion = sin(PI * clamp(progress, 0.0, 1.0));
|
|
54
|
+
float zoom = 1.0 + max(unzoom, 0.0) * motion;
|
|
55
|
+
|
|
56
|
+
// the front of the box is the screen: the camera keeps it framed, pulling back mid-turn
|
|
57
|
+
float dist = 0.8 * max(w, 1.0) / clamp(persp, 0.01, 1.0);
|
|
58
|
+
vec3 eye = vec3(0.5 * w, 0.5, -dist);
|
|
59
|
+
vec2 sp = (uv - 0.5) * zoom + 0.5;
|
|
60
|
+
vec3 dir = vec3(sp.x * w, sp.y, 0.0) - eye;
|
|
61
|
+
|
|
62
|
+
float px = EDGE * zoom * min(10.0 * motion, 1.0);
|
|
63
|
+
float shade0 = 1.0 - shading * (1.0 - c);
|
|
64
|
+
float shade1 = 1.0 - shading * (1.0 - s);
|
|
65
|
+
|
|
66
|
+
vec4 front = vec4(0.0);
|
|
67
|
+
vec4 b = hitBox(eye, dir, w, c, s);
|
|
68
|
+
if (b.x > 0.0) {
|
|
69
|
+
vec4 img = b.w < 0.5 ? getFromColor(vec2(b.y, b.z)) : getToColor(vec2(b.y, b.z));
|
|
70
|
+
float m = 1.0;
|
|
71
|
+
if (px > 0.0) {
|
|
72
|
+
float e = px * b.x;
|
|
73
|
+
vec3 n = b.w < 0.5 ? vec3(s, 0.0, -c) : vec3(-c, 0.0, -s);
|
|
74
|
+
float fore = max(abs(dot(n, normalize(dir))), 0.05);
|
|
75
|
+
float edge = b.w < 0.5 ? 1.0 - b.y : b.y;
|
|
76
|
+
m = clamp(min(b.z, 1.0 - b.z) / e, 0.0, 1.0)
|
|
77
|
+
* clamp(edge * w * fore / e, 0.0, 1.0);
|
|
78
|
+
}
|
|
79
|
+
// where the box covers the pixel, nothing behind it shows: the exact image at both ends
|
|
80
|
+
if (m >= 1.0 && img.a >= 1.0) {
|
|
81
|
+
return vec4(img.rgb * (b.w < 0.5 ? shade0 : shade1), img.a);
|
|
82
|
+
}
|
|
83
|
+
front = vec4(img.rgb * (b.w < 0.5 ? shade0 : shade1) * img.a, img.a) * m;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
vec4 ground = vec4(0.0);
|
|
87
|
+
float h = 0.005 * max(floating, 0.0);
|
|
88
|
+
if (dir.y < 0.0 && motion > 0.0) {
|
|
89
|
+
float tf = -(eye.y + h) / dir.y;
|
|
90
|
+
vec3 f = eye + tf * dir;
|
|
91
|
+
vec3 meye = vec3(eye.x, -2.0 * h - eye.y, eye.z);
|
|
92
|
+
vec3 mdir = vec3(dir.x, -dir.y, dir.z);
|
|
93
|
+
vec4 r = hitBox(meye, mdir, w, c, s);
|
|
94
|
+
if (r.x > 0.0) {
|
|
95
|
+
vec4 img = r.w < 0.5 ? getFromColor(vec2(r.y, r.z)) : getToColor(vec2(r.y, r.z));
|
|
96
|
+
float k = clamp(reflection, 0.0, 1.0) * (1.0 - r.z) * (1.0 - r.z);
|
|
97
|
+
ground = vec4(img.rgb * (r.w < 0.5 ? shade0 : shade1) * img.a, img.a) * k;
|
|
98
|
+
}
|
|
99
|
+
vec2 q = f.xz - vec2(0.5 * w);
|
|
100
|
+
vec2 l = vec2(q.x * c + q.y * s, -q.x * s + q.y * c);
|
|
101
|
+
float soft = 0.03 + 1.5 * h;
|
|
102
|
+
float sh = shading * 0.7 * exp(-length(max(abs(l) - vec2(0.5 * w), 0.0)) / soft);
|
|
103
|
+
// only as opaque as the bottom of the nearest face
|
|
104
|
+
vec2 bl = l + vec2(0.5 * w);
|
|
105
|
+
sh *= l.y < l.x
|
|
106
|
+
? getFromColor(vec2(clamp(bl.x / w, 0.0, 1.0), 0.0)).a
|
|
107
|
+
: getToColor(vec2(clamp(1.0 - bl.y / w, 0.0, 1.0), 0.0)).a;
|
|
108
|
+
ground = ground * (1.0 - sh) + vec4(0.0, 0.0, 0.0, sh);
|
|
109
|
+
ground *= min(6.0 * motion, 1.0);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
vec4 color = front + ground * (1.0 - front.a);
|
|
113
|
+
return color.a > 0.0 ? vec4(color.rgb / color.a, color.a) : vec4(0.0);
|
|
114
|
+
}`,"inside-cube":`// Author: gre
|
|
115
|
+
// License: MIT
|
|
116
|
+
// Description: The camera stands inside a cube: the outgoing image covers the wall in front of it and the view turns toward the next inner wall, so the outgoing image swings away in perspective as the incoming one turns into view, the walls darkening into the shaded inner corner between them
|
|
117
|
+
// Tags: 3d, cube, rotate, perspective, directional
|
|
118
|
+
|
|
119
|
+
// @param Direction the view turns toward, snapped to its main axis (left, right, up or down): the incoming image is on the wall on that side
|
|
120
|
+
const vec2 direction = vec2(1.0, 0.0);
|
|
121
|
+
// @range(60, 120) Field of view along the turn, in degrees: at 90 the camera stays at the center of the cube, a wider view makes the walls recede more
|
|
122
|
+
const float fov = 90.0;
|
|
123
|
+
// @range(0, 1) How much the walls darken as they turn away, and the shadow in the inner corners of the cube
|
|
124
|
+
const float shading = 0.6;
|
|
125
|
+
// @color Color of the other faces of the cube, seen where the two walls leave the frame uncovered during the turn
|
|
126
|
+
const vec4 background = vec4(0.09, 0.09, 0.1, 1.0);
|
|
127
|
+
|
|
128
|
+
const float PI = 3.141592653589793;
|
|
129
|
+
const float EDGE = 0.002;
|
|
130
|
+
|
|
131
|
+
vec4 premultiply(vec4 c) {
|
|
132
|
+
return vec4(c.rgb * c.a, c.a);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
float cornerShadow(float dist, float size) {
|
|
136
|
+
float k = 1.0 - smoothstep(0.0, size, dist);
|
|
137
|
+
return k * k;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// the image on a wall at the point l of the wall, in frame heights from its center (l.x along
|
|
141
|
+
// the turn, l.y across), premultiplied; s and vertical undo the mirroring and the swap of axes
|
|
142
|
+
// that transition() applies to the frame coordinates
|
|
143
|
+
vec4 wallColor(vec2 l, bool incoming, bool vertical, float s) {
|
|
144
|
+
vec2 h = vec2(l.x * s, l.y);
|
|
145
|
+
vec2 p = vertical ? h.yx : h;
|
|
146
|
+
vec2 st = clamp(p / vec2(ratio, 1.0) + 0.5, 0.0, 1.0);
|
|
147
|
+
return premultiply(incoming ? getToColor(st) : getFromColor(st));
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
vec4 transition(vec2 uv) {
|
|
151
|
+
bool vertical = abs(direction.y) > abs(direction.x);
|
|
152
|
+
float s = (vertical ? direction.y : direction.x) < 0.0 ? -1.0 : 1.0;
|
|
153
|
+
// q.x: along the turn, toward the incoming wall; q.y: across; in frame heights
|
|
154
|
+
vec2 p = (uv - 0.5) * vec2(ratio, 1.0);
|
|
155
|
+
vec2 q = vertical ? p.yx : p;
|
|
156
|
+
q.x *= s;
|
|
157
|
+
float A = vertical ? 0.5 : 0.5 * ratio;
|
|
158
|
+
float B = vertical ? 0.5 * ratio : 0.5;
|
|
159
|
+
// focal length: a wall exactly fills the frame when seen square from that distance
|
|
160
|
+
// (below about 53 degrees the camera would stand outside the cube)
|
|
161
|
+
float F = A / tan(radians(clamp(fov, 55.0, 170.0)) * 0.5);
|
|
162
|
+
|
|
163
|
+
float e = smoothstep(0.0, 1.0, progress);
|
|
164
|
+
float th = 0.5 * PI * e;
|
|
165
|
+
float c = cos(th);
|
|
166
|
+
float sn = sin(th);
|
|
167
|
+
float amount = max(sin(PI * e), 0.0); // 0 at both ends, so the images are untouched there
|
|
168
|
+
float aa = EDGE * min(1.0, 40.0 * amount) + 1e-6;
|
|
169
|
+
float shadow = shading * min(1.0, 4.0 * amount);
|
|
170
|
+
|
|
171
|
+
// in the plane of the turn (a: along, z: depth), the outgoing wall is z = F, a in [-A, A],
|
|
172
|
+
// the incoming wall is a = A, z in [F - 2A, F]; the camera starts in front of the center of
|
|
173
|
+
// the first one and ends in front of the center of the second one
|
|
174
|
+
vec2 cam = (A - F) * e * vec2(1.0, -1.0);
|
|
175
|
+
vec2 d = vec2(q.x * c + F * sn, F * c - q.x * sn);
|
|
176
|
+
|
|
177
|
+
vec2 P = vec2(A, F) - cam;
|
|
178
|
+
float sc = F * (P.x * c - P.y * sn) / max(P.x * sn + P.y * c, 1e-6);
|
|
179
|
+
|
|
180
|
+
float tf = d.y > 1e-6 ? (F - cam.y) / d.y : 1e6;
|
|
181
|
+
float af = cam.x + tf * d.x;
|
|
182
|
+
vec2 lf = vec2(af, q.y * tf);
|
|
183
|
+
float ti = d.x > 1e-6 ? (A - cam.x) / d.x : 1e6;
|
|
184
|
+
float ai = (F - A) - (cam.y + ti * d.y);
|
|
185
|
+
vec2 li = vec2(ai, q.y * ti);
|
|
186
|
+
|
|
187
|
+
float size = 0.8 * min(A, B);
|
|
188
|
+
float edgeF = cornerShadow(A - af, size) + 0.5 * cornerShadow(B - abs(lf.y), size);
|
|
189
|
+
float edgeI = cornerShadow(ai + A, size) + 0.5 * cornerShadow(B - abs(li.y), size);
|
|
190
|
+
float shadeF = (1.0 - shading * 0.8 * (1.0 - c)) * (1.0 - 0.7 * shadow * min(edgeF, 1.0));
|
|
191
|
+
float shadeI = (1.0 - shading * 0.8 * (1.0 - sn)) * (1.0 - 0.7 * shadow * min(edgeI, 1.0));
|
|
192
|
+
|
|
193
|
+
// how much of the pixel each wall covers, from distances on screen in frame heights: split at
|
|
194
|
+
// the corner line, cut across by the edges of the walls (lb = q.y * t), and at their far
|
|
195
|
+
// edges (along the wall, a moves F * t / d.depth times faster than q.x)
|
|
196
|
+
float wF = clamp(0.5 + (sc - q.x) / aa, 0.0, 1.0);
|
|
197
|
+
float covF = wF * clamp(0.5 + (B / tf - abs(q.y)) / aa, 0.0, 1.0)
|
|
198
|
+
* clamp(0.5 + (af + A) * d.y / (tf * F * aa), 0.0, 1.0);
|
|
199
|
+
float covI = (1.0 - wF) * clamp(0.5 + (B / ti - abs(q.y)) / aa, 0.0, 1.0)
|
|
200
|
+
* clamp(0.5 + (A - ai) * d.x / (ti * F * aa), 0.0, 1.0);
|
|
201
|
+
vec4 colF = covF > 0.0 ? wallColor(lf, false, vertical, s) : vec4(0.0);
|
|
202
|
+
vec4 colI = covI > 0.0 ? wallColor(li, true, vertical, s) : vec4(0.0);
|
|
203
|
+
colF.rgb *= shadeF;
|
|
204
|
+
colI.rgb *= shadeI;
|
|
205
|
+
|
|
206
|
+
vec4 bg = premultiply(background);
|
|
207
|
+
float cov = covF + covI;
|
|
208
|
+
if (cov < 1.0) {
|
|
209
|
+
float tb = min(B / max(abs(q.y), 1e-6), min(tf, ti));
|
|
210
|
+
vec2 fl = cam + tb * d;
|
|
211
|
+
float edgeB = cornerShadow(F - fl.y, size) + cornerShadow(A - fl.x, size);
|
|
212
|
+
bg.rgb *= 1.0 - 0.5 * shadow * min(edgeB, 1.0);
|
|
213
|
+
}
|
|
214
|
+
vec4 col = colF * covF + colI * covI + bg * (1.0 - cov);
|
|
215
|
+
return col.a > 0.0 ? vec4(col.rgb / col.a, col.a) : vec4(0.0);
|
|
216
|
+
}`,"cross-warp":`// Author: Eke Péter <peterekepeter@gmail.com>
|
|
217
|
+
// License: MIT
|
|
218
|
+
// Description: The outgoing image zooms in while the incoming one zooms out into place, sweeping from right to left
|
|
219
|
+
// Tags: warp, zoom, horizontal
|
|
220
|
+
vec4 transition(vec2 p) {
|
|
221
|
+
float x = progress;
|
|
222
|
+
x=smoothstep(.0,1.0,(x*2.0+p.x-1.0));
|
|
223
|
+
return mix(getFromColor((p-.5)*(1.-x)+.5), getToColor((p-.5)*x+.5), x);
|
|
224
|
+
}`,"cross-zoom":`// License: MIT
|
|
225
|
+
// Author: rectalogic
|
|
226
|
+
// Description: A crossfade through a strong zoom blur
|
|
227
|
+
// Tags: zoom, blur, blend
|
|
228
|
+
// ported by gre from https://gist.github.com/rectalogic/b86b90161503a0023231
|
|
229
|
+
|
|
230
|
+
// Converted from https://github.com/rectalogic/rendermix-basic-effects/blob/master/assets/com/rendermix/CrossZoom/CrossZoom.frag
|
|
231
|
+
// Which is based on https://github.com/evanw/glfx.js/blob/master/src/filters/blur/zoomblur.js
|
|
232
|
+
// With additional easing functions from https://github.com/rectalogic/rendermix-basic-effects/blob/master/assets/com/rendermix/Easing/Easing.glsllib
|
|
233
|
+
|
|
234
|
+
// @range(0, 1) Blur strength
|
|
235
|
+
const float strength = 0.4;
|
|
236
|
+
|
|
237
|
+
const float PI = 3.141592653589793;
|
|
238
|
+
|
|
239
|
+
float Linear_ease(in float begin, in float change, in float duration, in float time) {
|
|
240
|
+
return change * time / duration + begin;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
float Exponential_easeInOut(in float begin, in float change, in float duration, in float time) {
|
|
244
|
+
if (time == 0.0)
|
|
245
|
+
return begin;
|
|
246
|
+
else if (time == duration)
|
|
247
|
+
return begin + change;
|
|
248
|
+
time = time / (duration / 2.0);
|
|
249
|
+
if (time < 1.0)
|
|
250
|
+
return change / 2.0 * pow(2.0, 10.0 * (time - 1.0)) + begin;
|
|
251
|
+
return change / 2.0 * (-pow(2.0, -10.0 * (time - 1.0)) + 2.0) + begin;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
float Sinusoidal_easeInOut(in float begin, in float change, in float duration, in float time) {
|
|
255
|
+
return -change / 2.0 * (cos(PI * time / duration) - 1.0) + begin;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
float rand (vec2 co) {
|
|
259
|
+
return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453);
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
vec4 crossFade(in vec2 uv, in float dissolve) {
|
|
263
|
+
return mix(getFromColor(uv), getToColor(uv), dissolve);
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
vec4 transition(vec2 uv) {
|
|
267
|
+
vec2 texCoord = uv.xy / vec2(1.0).xy;
|
|
268
|
+
|
|
269
|
+
vec2 center = vec2(Linear_ease(0.25, 0.5, 1.0, progress), 0.5);
|
|
270
|
+
float dissolve = Exponential_easeInOut(0.0, 1.0, 1.0, progress);
|
|
271
|
+
|
|
272
|
+
// Mirrored sinusoidal loop. 0->strength then strength->0
|
|
273
|
+
float strength = Sinusoidal_easeInOut(0.0, strength, 0.5, progress);
|
|
274
|
+
|
|
275
|
+
vec4 color = vec4(0.0);
|
|
276
|
+
float total = 0.0;
|
|
277
|
+
vec2 toCenter = center - texCoord;
|
|
278
|
+
|
|
279
|
+
/* randomize the lookup values to hide the fixed number of samples */
|
|
280
|
+
float offset = rand(uv);
|
|
281
|
+
|
|
282
|
+
for (float t = 0.0; t <= 40.0; t++) {
|
|
283
|
+
float percent = (t + offset) / 40.0;
|
|
284
|
+
float weight = 4.0 * (percent - percent * percent);
|
|
285
|
+
color += crossFade(texCoord + toCenter * percent * strength, dissolve) * weight;
|
|
286
|
+
total += weight;
|
|
287
|
+
}
|
|
288
|
+
return color / total;
|
|
289
|
+
}`,doorway:`// Author: gre
|
|
290
|
+
// License: MIT
|
|
291
|
+
// Description: The outgoing image opens like double doors swinging toward the viewer, as the incoming one comes forward from the dark room behind, with a floor reflection
|
|
292
|
+
// Tags: doors, 3d, reflection
|
|
293
|
+
|
|
294
|
+
// @range(0, 1) Strength of the floor reflection under the incoming image
|
|
295
|
+
const float reflection = 0.4;
|
|
296
|
+
// @range(0, 1) Amount of perspective on the swinging doors
|
|
297
|
+
const float perspective = 0.4;
|
|
298
|
+
// @range(1, 10) How far back the incoming image starts (1: no distance)
|
|
299
|
+
const float depth = 3.0;
|
|
300
|
+
|
|
301
|
+
const float PI = 3.141592653589793;
|
|
302
|
+
|
|
303
|
+
// cast the view ray of screen point x (aspect units, the frame is 0..w) onto a leaf of
|
|
304
|
+
// width w/2 hinged on the left edge and turned toward the viewer by angle a.
|
|
305
|
+
// The eye is at (w/2, 0.5, -eye) and the frame at z = 0; returns (t, distance along the leaf)
|
|
306
|
+
// where t scales the ray so that t = 1 is the frame plane
|
|
307
|
+
vec2 leafHit (float x, float w, float eye, float a) {
|
|
308
|
+
float c = cos(a), s = sin(a);
|
|
309
|
+
float t = (eye * c - 0.5 * w * s) / (s * (x - 0.5 * w) + eye * c);
|
|
310
|
+
vec2 hit = vec2(0.5 * w + t * (x - 0.5 * w), eye * (t - 1.0));
|
|
311
|
+
return vec2(t, hit.x * c - hit.y * s);
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
float project (vec2 p, float w, float eye) {
|
|
315
|
+
return 0.5 * w + (p.x - 0.5 * w) * eye / (eye + p.y);
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
float easeInOut (float t) {
|
|
319
|
+
return t < 0.5 ? 4.0 * t * t * t : 1.0 - 4.0 * (1.0 - t) * (1.0 - t) * (1.0 - t);
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
vec4 room (vec2 uv, float x, float edgeL, float edgeR, float close, float dolly) {
|
|
323
|
+
float size = mix(max(depth, 1.0), 1.0, dolly);
|
|
324
|
+
vec2 p = (uv - 0.5) * size + 0.5;
|
|
325
|
+
// soft border while it is far, exactly sharp once it fills the frame
|
|
326
|
+
float soft = 0.004 * (size - 1.0) + 1e-6;
|
|
327
|
+
vec2 m = smoothstep(-soft, soft, p) * smoothstep(-soft, soft, 1.0 - p);
|
|
328
|
+
vec4 c = getToColor(clamp(p, 0.0, 1.0)) * (m.x * m.y);
|
|
329
|
+
if (p.y < 0.0) {
|
|
330
|
+
vec2 r = vec2(p.x, -1.2 * p.y - 0.02);
|
|
331
|
+
float f = reflection * (1.0 - r.y) * m.x * smoothstep(0.0, 0.01, r.y);
|
|
332
|
+
c += getToColor(clamp(r, 0.0, 1.0)) * f * (1.0 - m.y);
|
|
333
|
+
}
|
|
334
|
+
float wl = 0.03 + 0.12 * close;
|
|
335
|
+
float shadow = (1.0 - smoothstep(0.0, wl, x - edgeL)) + (1.0 - smoothstep(0.0, wl, edgeR - x));
|
|
336
|
+
float light = (1.0 + 0.6 * close * close) * (1.0 - 0.7 * close * min(shadow, 1.0));
|
|
337
|
+
return vec4(min(c.rgb * light, vec3(c.a)), c.a);
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
vec4 transition (vec2 uv) {
|
|
341
|
+
float w = ratio;
|
|
342
|
+
float x = uv.x * w;
|
|
343
|
+
// camera distance: the leaves always stay in front of it
|
|
344
|
+
float eye = max(w, 1.0) * (0.5 + 0.2 / max(perspective, 0.01));
|
|
345
|
+
float swing = progress * progress * (3.0 - 2.0 * progress);
|
|
346
|
+
float a = min(atan(2.0 * eye / w) + 0.1, 0.5 * PI) * swing;
|
|
347
|
+
float dolly = mix(easeInOut(progress), progress, 0.3);
|
|
348
|
+
float hw = 0.5 * w;
|
|
349
|
+
vec2 front = hw * vec2(cos(a), -sin(a));
|
|
350
|
+
float thick = 0.02 * w * (1.0 - smoothstep(0.8, 1.0, swing));
|
|
351
|
+
float edgeL = project(front, w, eye);
|
|
352
|
+
float backL = project(front + thick * vec2(sin(a), cos(a)), w, eye);
|
|
353
|
+
float close = 1.0 - swing;
|
|
354
|
+
vec4 back = room(uv, x, backL, w - backL, close, dolly);
|
|
355
|
+
// the leaf on this side of the frame (each one stays in its own half)
|
|
356
|
+
bool left = x < hw;
|
|
357
|
+
float lx = left ? x : w - x;
|
|
358
|
+
vec2 hit = leafHit(lx, w, eye, a);
|
|
359
|
+
float s = clamp(hit.y, 0.0, hw);
|
|
360
|
+
float v = 0.5 + (uv.y - 0.5) * hit.x;
|
|
361
|
+
vec4 leaf = getFromColor(clamp(vec2(left ? s / w : 1.0 - s / w, v), 0.0, 1.0));
|
|
362
|
+
leaf.rgb *= 1.0 - 0.5 * (1.0 - cos(a)) - 0.25 * sin(a) * (s / hw);
|
|
363
|
+
vec4 side = getFromColor(clamp(vec2(left ? 0.499 : 0.501, v), 0.0, 1.0));
|
|
364
|
+
side.rgb = min(side.rgb * 1.5, vec3(side.a));
|
|
365
|
+
// sharp at both ends, so that nothing of the doors is left at the start and the end
|
|
366
|
+
float aa = 0.003 * min(1.0, 20.0 * min(a, close)) + 1e-6;
|
|
367
|
+
vec4 c = mix(back, side, smoothstep(-aa, aa, backL - lx));
|
|
368
|
+
return mix(c, leaf, smoothstep(-aa, aa, edgeL - lx));
|
|
369
|
+
}`,dreamy:`// Author: mikolalysenko
|
|
370
|
+
// License: MIT
|
|
371
|
+
// Description: A crossfade with a gentle wavy distortion
|
|
372
|
+
// Tags: wave, blend
|
|
373
|
+
|
|
374
|
+
vec2 offset(float progress, float x, float theta) {
|
|
375
|
+
float phase = progress*progress + progress + theta;
|
|
376
|
+
float shifty = 0.03*progress*cos(10.0*(progress+x));
|
|
377
|
+
return vec2(0, shifty);
|
|
378
|
+
}
|
|
379
|
+
vec4 transition(vec2 p) {
|
|
380
|
+
return mix(getFromColor(p + offset(progress, p.x, 0.0)), getToColor(p + offset(1.0-progress, p.x, 3.14)), progress);
|
|
381
|
+
}`,"dreamy-zoom":`// Author: Zeh Fernando
|
|
382
|
+
// License: MIT
|
|
383
|
+
// Description: Zooms and rotates into a bright flash, then out to the incoming image
|
|
384
|
+
// Tags: zoom, rotate, flash
|
|
385
|
+
|
|
386
|
+
#define DEG2RAD 0.03926990816987241548078304229099
|
|
387
|
+
|
|
388
|
+
|
|
389
|
+
// In degrees
|
|
390
|
+
const float rotation = 6.0;
|
|
391
|
+
|
|
392
|
+
// Multiplier
|
|
393
|
+
const float scale = 1.2;
|
|
394
|
+
|
|
395
|
+
|
|
396
|
+
vec4 transition(vec2 uv) {
|
|
397
|
+
float phase = progress < 0.5 ? progress * 2.0 : (progress - 0.5) * 2.0;
|
|
398
|
+
float angleOffset = progress < 0.5 ? mix(0.0, rotation * DEG2RAD, phase) : mix(-rotation * DEG2RAD, 0.0, phase);
|
|
399
|
+
float newScale = progress < 0.5 ? mix(1.0, scale, phase) : mix(scale, 1.0, phase);
|
|
400
|
+
|
|
401
|
+
vec2 center = vec2(0, 0);
|
|
402
|
+
|
|
403
|
+
vec2 assumedCenter = vec2(0.5, 0.5);
|
|
404
|
+
vec2 p = (uv.xy - vec2(0.5, 0.5)) / newScale * vec2(ratio, 1.0);
|
|
405
|
+
|
|
406
|
+
float angle = atan(p.y, p.x) + angleOffset;
|
|
407
|
+
float dist = distance(center, p);
|
|
408
|
+
p.x = cos(angle) * dist / ratio + 0.5;
|
|
409
|
+
p.y = sin(angle) * dist + 0.5;
|
|
410
|
+
vec4 c = progress < 0.5 ? getFromColor(p) : getToColor(p);
|
|
411
|
+
|
|
412
|
+
// The flash lights up the image, not the transparent areas around it.
|
|
413
|
+
return vec4(c.rgb + (progress < 0.5 ? mix(0.0, 1.0, phase) : mix(1.0, 0.0, phase)), c.a);
|
|
414
|
+
}`,ripple:`// Author: gre
|
|
415
|
+
// License: MIT
|
|
416
|
+
// Description: Ripples spread from the center while crossfading
|
|
417
|
+
// Tags: ripple, wave, blend
|
|
418
|
+
// @param Frequency of the ripples
|
|
419
|
+
const float amplitude = 100.0;
|
|
420
|
+
// @param Speed of the ripples
|
|
421
|
+
const float speed = 50.0;
|
|
422
|
+
|
|
423
|
+
vec4 transition (vec2 uv) {
|
|
424
|
+
vec2 dir = uv - vec2(.5);
|
|
425
|
+
float dist = length(dir);
|
|
426
|
+
vec2 offset = dir * (sin(progress * dist * amplitude - progress * speed) + .5) / 30. * progress;
|
|
427
|
+
return mix(
|
|
428
|
+
getFromColor(uv + offset),
|
|
429
|
+
getToColor(uv),
|
|
430
|
+
smoothstep(0.2, 1.0, progress)
|
|
431
|
+
);
|
|
432
|
+
}`,"water-drop":`// Author: Paweł Płóciennik
|
|
433
|
+
// License: MIT
|
|
434
|
+
// Description: A drop falls into the image like into still water: round ripples spread out from where it hits, bending the image with glints on their slopes, the incoming image shows up inside the leading ripple, and the water calms down
|
|
435
|
+
// Tags: ripple, water, refraction, circle
|
|
436
|
+
// @range(10, 80) Frequency of the ripples: higher makes them closer together
|
|
437
|
+
const float amplitude = 30.0;
|
|
438
|
+
// @range(0, 80) Speed of the ripples as they run outward through the spreading rings
|
|
439
|
+
const float speed = 30.0;
|
|
440
|
+
// @param Where the drop falls, in texture coordinates
|
|
441
|
+
const vec2 center = vec2(0.5, 0.5);
|
|
442
|
+
// @range(0, 0.08) How far the ripples bend the image, in frame heights
|
|
443
|
+
const float refraction = 0.015;
|
|
444
|
+
// @range(0, 1) Brightness of the glints on the ripples
|
|
445
|
+
const float highlight = 0.5;
|
|
446
|
+
|
|
447
|
+
vec2 mirror(vec2 v) {
|
|
448
|
+
return 1.0 - abs(1.0 - mod(v, 2.0));
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
// height of the water, from -1 to 1, at a distance s inside the front
|
|
452
|
+
float wave(float s, float k, float lambda, float t) {
|
|
453
|
+
float env = smoothstep(-0.3 * lambda, 0.6 * lambda, s) * exp(-s / (3.5 * lambda));
|
|
454
|
+
// the ripples run out through the train, faster than the train itself spreads
|
|
455
|
+
return env * sin(k * s + speed * t);
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
vec4 transition(vec2 uv) {
|
|
459
|
+
float k = 2.0 * max(amplitude, 1.0);
|
|
460
|
+
float lambda = 6.2831853 / k;
|
|
461
|
+
// measured in square pixels, so the ripples are round
|
|
462
|
+
vec2 q = (uv - center) * vec2(ratio, 1.0);
|
|
463
|
+
float r = length(q);
|
|
464
|
+
vec2 dir = r > 0.0 ? q / r : vec2(0.0);
|
|
465
|
+
vec2 far = max(center, 1.0 - center) * vec2(ratio, 1.0);
|
|
466
|
+
float R = length(far);
|
|
467
|
+
|
|
468
|
+
float edge = 0.35 * lambda;
|
|
469
|
+
float soft = 0.1 * lambda;
|
|
470
|
+
// the front spreads out, slowing down a little, from just before the drop hits until
|
|
471
|
+
// its revealed area is past the farthest corner
|
|
472
|
+
float t = progress;
|
|
473
|
+
float e = mix(t, 1.0 - (1.0 - t) * (1.0 - t), 0.4);
|
|
474
|
+
float front = mix(-0.3 * lambda, R + edge + soft + 0.01, e);
|
|
475
|
+
float s = front - r;
|
|
476
|
+
|
|
477
|
+
float calm = 1.0 - smoothstep(0.55, 1.0, t);
|
|
478
|
+
calm *= calm;
|
|
479
|
+
// slope of the water along the radius, normalized to at most about 1
|
|
480
|
+
// (one-sided at the very center)
|
|
481
|
+
float d = 0.02 * lambda;
|
|
482
|
+
float r0 = max(r - d, 0.0);
|
|
483
|
+
float slope = calm * (wave(front - r - d, k, lambda, t) - wave(front - r0, k, lambda, t)) / ((r + d - r0) * k);
|
|
484
|
+
vec2 offset = dir * slope * refraction / vec2(ratio, 1.0);
|
|
485
|
+
|
|
486
|
+
vec4 ca = getFromColor(mirror(uv - offset));
|
|
487
|
+
vec4 cb = getToColor(mirror(uv - offset));
|
|
488
|
+
float m = smoothstep(edge - soft, edge + soft, s);
|
|
489
|
+
// mixed premultiplied, so transparent images do not bleed their color
|
|
490
|
+
vec4 c = mix(vec4(ca.rgb * ca.a, ca.a), vec4(cb.rgb * cb.a, cb.a), m);
|
|
491
|
+
|
|
492
|
+
float h = calm * wave(s, k, lambda, t);
|
|
493
|
+
float lit = -dot(dir, normalize(vec2(-0.6, 0.8))) * slope;
|
|
494
|
+
float glint = highlight * (0.2 * h + 0.6 * smoothstep(0.2, 0.9, lit) - 0.3 * smoothstep(0.2, 0.9, -lit));
|
|
495
|
+
c.rgb = clamp(c.rgb + glint * c.a, 0.0, c.a);
|
|
496
|
+
return c.a > 0.0 ? vec4(c.rgb / c.a, c.a) : vec4(0.0);
|
|
497
|
+
}`,shockwave:`// Author: Gilad Levi, github @Giladx
|
|
498
|
+
// License: MIT
|
|
499
|
+
// Description: A diagonal shockwave breaks the outgoing image into tiny falling glass tiles. Each tile slips away with a brief chromatic split and neon edge glow, revealing the incoming image beneath it.
|
|
500
|
+
// Tags: diagonal, mosaic, pixel, cascade, glass, prism, chromatic, neon, cinematic
|
|
501
|
+
|
|
502
|
+
// @range(0.012, 0.10) Size of each square tile relative to slide height
|
|
503
|
+
const float tileSize = 0.035;
|
|
504
|
+
// @range(0.0, 1.5) How far the tiles slide and fall
|
|
505
|
+
const float scatter = 0.85;
|
|
506
|
+
// @range(0.0, 1.0) 0 is a horizontal sweep; 1 is a strongly diagonal sweep
|
|
507
|
+
const float diagonal = 0.9;
|
|
508
|
+
// @range(0.0, 1.0) Amount of red/blue optical separation at the moving edges
|
|
509
|
+
const float prism = 0.65;
|
|
510
|
+
// @range(0.0, 1.0) Brightness of the colored edges around moving tiles
|
|
511
|
+
const float glow = 0.75;
|
|
512
|
+
|
|
513
|
+
float toseeHash(vec2 p) {
|
|
514
|
+
return fract(sin(dot(p, vec2(127.1, 311.7))) * 43758.5453123);
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
vec4 transition(vec2 uv) {
|
|
518
|
+
float size = max(tileSize, 0.008);
|
|
519
|
+
vec2 grid = max(vec2(1.0), floor(vec2(ratio, 1.0) / size));
|
|
520
|
+
vec2 cell = floor(uv * grid);
|
|
521
|
+
vec2 cellUV = fract(uv * grid);
|
|
522
|
+
vec2 centerUV = (cell + 0.5) / grid;
|
|
523
|
+
|
|
524
|
+
float sweep = mix(
|
|
525
|
+
centerUV.x,
|
|
526
|
+
0.64 * centerUV.x + 0.36 * (1.0 - centerUV.y),
|
|
527
|
+
clamp(diagonal, 0.0, 1.0)
|
|
528
|
+
);
|
|
529
|
+
|
|
530
|
+
float noise = toseeHash(cell);
|
|
531
|
+
float start = 0.62 * sweep + 0.07 * noise;
|
|
532
|
+
float t = clamp((progress - start) / 0.29, 0.0, 1.0);
|
|
533
|
+
float movement = t * clamp(scatter, 0.0, 1.5);
|
|
534
|
+
|
|
535
|
+
float wobble = toseeHash(cell + vec2(19.3, 7.7)) * 2.0 - 1.0;
|
|
536
|
+
vec2 drift = vec2(0.65 * wobble, -0.95) * movement;
|
|
537
|
+
vec2 movingCellUV = cellUV - drift;
|
|
538
|
+
|
|
539
|
+
float inside =
|
|
540
|
+
step(0.012, movingCellUV.x) *
|
|
541
|
+
step(movingCellUV.x, 0.988) *
|
|
542
|
+
step(0.012, movingCellUV.y) *
|
|
543
|
+
step(movingCellUV.y, 0.988);
|
|
544
|
+
|
|
545
|
+
float tileShape = mix(1.0, inside, smoothstep(0.0, 0.13, t));
|
|
546
|
+
float oldVisibility = 1.0 - smoothstep(0.48, 0.87, t);
|
|
547
|
+
float oldMask = tileShape * oldVisibility;
|
|
548
|
+
|
|
549
|
+
vec2 oldUV = clamp(uv - drift / grid, 0.0, 1.0);
|
|
550
|
+
vec4 oldColor = getFromColor(oldUV);
|
|
551
|
+
|
|
552
|
+
float flare = sin(3.14159265 * t);
|
|
553
|
+
vec2 shift = vec2(0.006, -0.002) * prism * flare;
|
|
554
|
+
vec4 offsetColor = getFromColor(
|
|
555
|
+
clamp(oldUV + shift, 0.0, 1.0)
|
|
556
|
+
);
|
|
557
|
+
oldColor.r = offsetColor.r;
|
|
558
|
+
|
|
559
|
+
vec4 result = mix(getToColor(uv), oldColor, oldMask);
|
|
560
|
+
|
|
561
|
+
float edgeDistance = min(
|
|
562
|
+
min(movingCellUV.x, 1.0 - movingCellUV.x),
|
|
563
|
+
min(movingCellUV.y, 1.0 - movingCellUV.y)
|
|
564
|
+
);
|
|
565
|
+
|
|
566
|
+
float edge =
|
|
567
|
+
(1.0 - smoothstep(0.0, 0.10, edgeDistance)) * inside;
|
|
568
|
+
|
|
569
|
+
vec3 cyan = vec3(0.12, 0.95, 1.0);
|
|
570
|
+
vec3 pink = vec3(1.0, 0.20, 0.65);
|
|
571
|
+
|
|
572
|
+
vec3 rimColor = mix(
|
|
573
|
+
cyan,
|
|
574
|
+
pink,
|
|
575
|
+
toseeHash(cell + vec2(5.4, 28.6))
|
|
576
|
+
);
|
|
577
|
+
|
|
578
|
+
result.rgb = clamp(
|
|
579
|
+
result.rgb + rimColor * edge * flare * glow * oldMask * 0.60,
|
|
580
|
+
0.0,
|
|
581
|
+
1.0
|
|
582
|
+
);
|
|
583
|
+
|
|
584
|
+
return result;
|
|
585
|
+
}`,kaleidoscope:`// Author: nwoeanhinnogaehr
|
|
586
|
+
// License: MIT
|
|
587
|
+
// Description: A crossfade through a spinning kaleidoscope
|
|
588
|
+
// Tags: kaleidoscope, distort, blend
|
|
589
|
+
|
|
590
|
+
const float speed = 1.0;
|
|
591
|
+
const float angle = 1.0;
|
|
592
|
+
const float power = 1.5;
|
|
593
|
+
|
|
594
|
+
vec4 transition(vec2 uv) {
|
|
595
|
+
vec2 p = uv.xy / vec2(1.0).xy;
|
|
596
|
+
vec2 q = p;
|
|
597
|
+
float t = pow(progress, power)*speed;
|
|
598
|
+
p = p -0.5;
|
|
599
|
+
for (int i = 0; i < 7; i++) {
|
|
600
|
+
p = vec2(sin(t)*p.x + cos(t)*p.y, sin(t)*p.y - cos(t)*p.x);
|
|
601
|
+
t += angle;
|
|
602
|
+
p = abs(mod(p, 2.0) - 1.0);
|
|
603
|
+
}
|
|
604
|
+
abs(mod(p, 1.0));
|
|
605
|
+
return mix(
|
|
606
|
+
mix(getFromColor(q), getToColor(q), progress),
|
|
607
|
+
mix(getFromColor(p), getToColor(p), progress), 1.0 - 2.0*abs(progress - 0.5));
|
|
608
|
+
}`,morph:`// Author: paniq
|
|
609
|
+
// License: MIT
|
|
610
|
+
// Description: A crossfade in which each image is displaced by the other's colors, like a morph
|
|
611
|
+
// Tags: morph, distort, blend
|
|
612
|
+
// @param Strength of the displacement
|
|
613
|
+
const float strength = 0.1;
|
|
614
|
+
|
|
615
|
+
vec4 transition(vec2 p) {
|
|
616
|
+
vec4 ca = getFromColor(p);
|
|
617
|
+
vec4 cb = getToColor(p);
|
|
618
|
+
|
|
619
|
+
vec2 oa = (((ca.rg+ca.b)*0.5)*2.0-1.0);
|
|
620
|
+
vec2 ob = (((cb.rg+cb.b)*0.5)*2.0-1.0);
|
|
621
|
+
vec2 oc = mix(oa,ob,0.5)*strength;
|
|
622
|
+
|
|
623
|
+
float w0 = progress;
|
|
624
|
+
float w1 = 1.0-w0;
|
|
625
|
+
return mix(getFromColor(p+oc*w0), getToColor(p-oc*w1), progress);
|
|
626
|
+
}`,mosaic:`// License: MIT
|
|
627
|
+
// Author: Xaychru
|
|
628
|
+
// Description: The view pans across a mosaic of rotated tiles from both images and settles on the incoming one
|
|
629
|
+
// Tags: mosaic, tiles, zoom
|
|
630
|
+
// ported by gre from https://gist.github.com/Xaychru/130bb7b7affedbda9df5
|
|
631
|
+
|
|
632
|
+
#define PI 3.14159265358979323
|
|
633
|
+
#define POW2(X) X*X
|
|
634
|
+
#define POW3(X) X*X*X
|
|
635
|
+
const int endx = 2;
|
|
636
|
+
const int endy = -1;
|
|
637
|
+
|
|
638
|
+
float Rand(vec2 v) {
|
|
639
|
+
return fract(sin(dot(v.xy ,vec2(12.9898,78.233))) * 43758.5453);
|
|
640
|
+
}
|
|
641
|
+
vec2 Rotate(vec2 v, float a) {
|
|
642
|
+
mat2 rm = mat2(cos(a), -sin(a),
|
|
643
|
+
sin(a), cos(a));
|
|
644
|
+
return rm*v;
|
|
645
|
+
}
|
|
646
|
+
float CosInterpolation(float x) {
|
|
647
|
+
return -cos(x*PI)/2.+.5;
|
|
648
|
+
}
|
|
649
|
+
vec4 transition(vec2 uv) {
|
|
650
|
+
vec2 p = uv.xy / vec2(1.0).xy - .5;
|
|
651
|
+
vec2 rp = p;
|
|
652
|
+
float rpr = (progress*2.-1.);
|
|
653
|
+
float z = -(rpr*rpr*2.) + 3.;
|
|
654
|
+
float az = abs(z);
|
|
655
|
+
rp *= az;
|
|
656
|
+
rp += mix(vec2(.5, .5), vec2(float(endx) + .5, float(endy) + .5), POW2(CosInterpolation(progress)));
|
|
657
|
+
vec2 mrp = mod(rp, 1.);
|
|
658
|
+
vec2 crp = rp;
|
|
659
|
+
bool onEnd = int(floor(crp.x))==endx&&int(floor(crp.y))==endy;
|
|
660
|
+
if(!onEnd) {
|
|
661
|
+
float ang = float(int(Rand(floor(crp))*4.))*.5*PI;
|
|
662
|
+
mrp = vec2(.5) + Rotate(mrp-vec2(.5), ang);
|
|
663
|
+
}
|
|
664
|
+
if(onEnd || Rand(floor(crp))>.5) {
|
|
665
|
+
return getToColor(mrp);
|
|
666
|
+
} else {
|
|
667
|
+
return getFromColor(mrp);
|
|
668
|
+
}
|
|
669
|
+
}`,hexagonalize:`// Author: Fernando Kuteken
|
|
670
|
+
// License: MIT
|
|
671
|
+
// Description: Both images turn into hexagons, crossfade, then sharpen again
|
|
672
|
+
// Tags: pixelate, hexagon, blend
|
|
673
|
+
// Hexagonal math from: http://www.redblobgames.com/grids/hexagons/
|
|
674
|
+
|
|
675
|
+
const int steps = 50;
|
|
676
|
+
// @param Number of hexagons across
|
|
677
|
+
const float horizontalHexagons = 20.0;
|
|
678
|
+
|
|
679
|
+
struct Hexagon {
|
|
680
|
+
float q;
|
|
681
|
+
float r;
|
|
682
|
+
float s;
|
|
683
|
+
};
|
|
684
|
+
|
|
685
|
+
Hexagon createHexagon(float q, float r){
|
|
686
|
+
Hexagon hex;
|
|
687
|
+
hex.q = q;
|
|
688
|
+
hex.r = r;
|
|
689
|
+
hex.s = -q - r;
|
|
690
|
+
return hex;
|
|
691
|
+
}
|
|
692
|
+
|
|
693
|
+
Hexagon roundHexagon(Hexagon hex){
|
|
694
|
+
|
|
695
|
+
float q = floor(hex.q + 0.5);
|
|
696
|
+
float r = floor(hex.r + 0.5);
|
|
697
|
+
float s = floor(hex.s + 0.5);
|
|
698
|
+
|
|
699
|
+
float deltaQ = abs(q - hex.q);
|
|
700
|
+
float deltaR = abs(r - hex.r);
|
|
701
|
+
float deltaS = abs(s - hex.s);
|
|
702
|
+
|
|
703
|
+
if (deltaQ > deltaR && deltaQ > deltaS)
|
|
704
|
+
q = -r - s;
|
|
705
|
+
else if (deltaR > deltaS)
|
|
706
|
+
r = -q - s;
|
|
707
|
+
else
|
|
708
|
+
s = -q - r;
|
|
709
|
+
|
|
710
|
+
return createHexagon(q, r);
|
|
711
|
+
}
|
|
712
|
+
|
|
713
|
+
Hexagon hexagonFromPoint(vec2 point, float size) {
|
|
714
|
+
|
|
715
|
+
point.y /= ratio;
|
|
716
|
+
point = (point - 0.5) / size;
|
|
717
|
+
|
|
718
|
+
float q = (sqrt(3.0) / 3.0) * point.x + (-1.0 / 3.0) * point.y;
|
|
719
|
+
float r = 0.0 * point.x + 2.0 / 3.0 * point.y;
|
|
720
|
+
|
|
721
|
+
Hexagon hex = createHexagon(q, r);
|
|
722
|
+
return roundHexagon(hex);
|
|
723
|
+
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
vec2 pointFromHexagon(Hexagon hex, float size) {
|
|
727
|
+
|
|
728
|
+
float x = (sqrt(3.0) * hex.q + (sqrt(3.0) / 2.0) * hex.r) * size + 0.5;
|
|
729
|
+
float y = (0.0 * hex.q + (3.0 / 2.0) * hex.r) * size + 0.5;
|
|
730
|
+
|
|
731
|
+
return vec2(x, y * ratio);
|
|
732
|
+
}
|
|
733
|
+
|
|
734
|
+
vec4 transition (vec2 uv) {
|
|
735
|
+
|
|
736
|
+
float dist = 2.0 * min(progress, 1.0 - progress);
|
|
737
|
+
dist = steps > 0 ? ceil(dist * float(steps)) / float(steps) : dist;
|
|
738
|
+
|
|
739
|
+
float size = (sqrt(3.0) / 3.0) * dist / horizontalHexagons;
|
|
740
|
+
|
|
741
|
+
vec2 point = dist > 0.0 ? pointFromHexagon(hexagonFromPoint(uv, size), size) : uv;
|
|
742
|
+
|
|
743
|
+
return mix(getFromColor(point), getToColor(point), progress);
|
|
744
|
+
|
|
745
|
+
}`,honeycomb:`// Author: gre
|
|
746
|
+
// License: MIT
|
|
747
|
+
// Description: The image splits into hexagons that spin and shrink away in a wave from the center, uncovering the incoming image
|
|
748
|
+
// Tags: hexagon, tiles, rotate, radial
|
|
749
|
+
|
|
750
|
+
// @range(2, 30) Number of hexagons across the shorter side
|
|
751
|
+
const float size = 6.0;
|
|
752
|
+
|
|
753
|
+
// Distance to the center of a pointy-top hexagon, 0.5 on the edges of a cell
|
|
754
|
+
float hexDist(vec2 p) {
|
|
755
|
+
p = abs(p);
|
|
756
|
+
return max(p.x, dot(p, vec2(0.5, 0.8660254)));
|
|
757
|
+
}
|
|
758
|
+
|
|
759
|
+
mat2 rotation(float a) {
|
|
760
|
+
return mat2(cos(a), sin(a), -sin(a), cos(a));
|
|
761
|
+
}
|
|
762
|
+
|
|
763
|
+
// Coverage of a hexagon turned by a and scaled by s inside its cell, with soft edges of width e
|
|
764
|
+
// (unturned at s = 1, it covers its whole cell)
|
|
765
|
+
float hexMask(vec2 local, float s, float a, float e) {
|
|
766
|
+
float r = (0.52 + e) * s;
|
|
767
|
+
return 1.0 - smoothstep(r - e, r, hexDist(rotation(-a) * local));
|
|
768
|
+
}
|
|
769
|
+
|
|
770
|
+
vec2 hexUv(vec2 uv, vec2 local, vec2 cellToUv, float s, float a) {
|
|
771
|
+
return uv + cellToUv * (rotation(-a) * local / max(s, 0.001) - local);
|
|
772
|
+
}
|
|
773
|
+
|
|
774
|
+
vec4 transition(vec2 uv) {
|
|
775
|
+
// nearest hexagon center, on two interleaved rectangular grids (centers 1 apart)
|
|
776
|
+
vec2 toCells = vec2(ratio, 1.0) * size / min(ratio, 1.0);
|
|
777
|
+
vec2 p = (uv - 0.5) * toCells;
|
|
778
|
+
const vec2 grid = vec2(1.0, 1.7320508);
|
|
779
|
+
vec2 a = (floor(p / grid) + 0.5) * grid;
|
|
780
|
+
vec2 b = (floor((p - 0.5 * grid) / grid) + 1.0) * grid;
|
|
781
|
+
vec2 center = dot(p - a, p - a) < dot(p - b, p - b) ? a : b;
|
|
782
|
+
vec2 local = p - center;
|
|
783
|
+
|
|
784
|
+
float d = min(length(center / toCells * vec2(ratio, 1.0)) / (0.5 * length(vec2(ratio, 1.0))), 1.0);
|
|
785
|
+
float t = clamp((progress - 0.6 * d) / 0.4, 0.0, 1.0);
|
|
786
|
+
|
|
787
|
+
float s = 1.0 - smoothstep(0.1, 1.0, t);
|
|
788
|
+
float turn = 1.8 * t * (2.0 - t);
|
|
789
|
+
vec4 fromTile = getFromColor(hexUv(uv, local, 1.0 / toCells, s, turn));
|
|
790
|
+
fromTile.rgb *= 1.0 - 0.3 * t;
|
|
791
|
+
vec4 below = getToColor(uv);
|
|
792
|
+
below.rgb *= 1.0 - 0.5 * hexMask(local - vec2(0.06, -0.08) * s, s, turn, 0.2);
|
|
793
|
+
return mix(below, fromTile, hexMask(local, s, turn, 0.03));
|
|
794
|
+
}`,puzzle:`// Author: gre
|
|
795
|
+
// License: MIT
|
|
796
|
+
// Description: The image is cut into jigsaw puzzle pieces that lift one after another and fall away, revealing the incoming image
|
|
797
|
+
// Tags: tiles, shadow, rotate, fragments
|
|
798
|
+
|
|
799
|
+
// @range(2, 12) Number of pieces across the shorter side
|
|
800
|
+
const float pieces = 5.0;
|
|
801
|
+
// @range(0, 1) Darkness of the shadows of the lifted pieces
|
|
802
|
+
const float shadow = 0.6;
|
|
803
|
+
|
|
804
|
+
// Hash of a cell, without sin, in [0, 1)
|
|
805
|
+
float hash(vec2 c) {
|
|
806
|
+
vec2 p = fract(c * vec2(0.1031, 0.1030));
|
|
807
|
+
p += dot(p, p.yx + 33.33);
|
|
808
|
+
return fract((p.x + p.y) * p.x);
|
|
809
|
+
}
|
|
810
|
+
|
|
811
|
+
float boxDist(vec2 p, vec2 halfSize) {
|
|
812
|
+
vec2 q = abs(p) - halfSize;
|
|
813
|
+
return length(max(q, 0.0)) + min(max(q.x, q.y), 0.0);
|
|
814
|
+
}
|
|
815
|
+
|
|
816
|
+
// Signed distance of a point, relative to the center of piece c, to that piece (cell units).
|
|
817
|
+
// Each edge has a knob (a round head on a neck): a tab for one piece, a blank for its neighbor; border edges are flat.
|
|
818
|
+
float pieceDist(vec2 p, vec2 c, vec2 grid, float aspect) {
|
|
819
|
+
vec2 halfSize = vec2(0.5 * aspect, 0.5);
|
|
820
|
+
float d = boxDist(p, halfSize);
|
|
821
|
+
float tabs = 1e3;
|
|
822
|
+
for (int e = 0; e < 4; e++) {
|
|
823
|
+
// right, left, top, bottom: the edge key is the cell on its left or below
|
|
824
|
+
vec2 dir = e == 0 ? vec2(1.0, 0.0) : e == 1 ? vec2(-1.0, 0.0) : e == 2 ? vec2(0.0, 1.0) : vec2(0.0, -1.0);
|
|
825
|
+
vec2 key = c + min(dir, 0.0);
|
|
826
|
+
vec2 next = c + dir;
|
|
827
|
+
if (next.x >= 0.0 && next.y >= 0.0 && next.x < grid.x && next.y < grid.y) {
|
|
828
|
+
float h = hash(key + (e < 2 ? vec2(0.0) : vec2(71.0, 37.0)));
|
|
829
|
+
// the knob points right or up from the key cell when h < 0.5
|
|
830
|
+
bool tab = (h < 0.5) == (dir.x + dir.y > 0.0);
|
|
831
|
+
vec2 out1 = dir * (tab ? 1.0 : -1.0);
|
|
832
|
+
vec2 along = vec2(abs(dir.y), abs(dir.x));
|
|
833
|
+
vec2 edge = dir * halfSize + along * (fract(h * 2.0) - 0.5) * 0.16;
|
|
834
|
+
float k = min(
|
|
835
|
+
length(p - edge - out1 * 0.15) - 0.125,
|
|
836
|
+
boxDist(p - edge - out1 * 0.06, abs(dir) * 0.08 + along * 0.085));
|
|
837
|
+
if (tab) tabs = min(tabs, k);
|
|
838
|
+
else d = max(d, -k);
|
|
839
|
+
}
|
|
840
|
+
}
|
|
841
|
+
return min(d, tabs);
|
|
842
|
+
}
|
|
843
|
+
|
|
844
|
+
vec4 transition(vec2 uv) {
|
|
845
|
+
// a grid of nearly square cells that fits the frame exactly
|
|
846
|
+
float rows = ratio < 1.0 ? floor(pieces / ratio + 0.5) : pieces;
|
|
847
|
+
float cols = ratio < 1.0 ? pieces : floor(pieces * ratio + 0.5);
|
|
848
|
+
vec2 grid = vec2(cols, rows);
|
|
849
|
+
float aspect = ratio * rows / cols;
|
|
850
|
+
vec2 g = uv * grid;
|
|
851
|
+
vec2 cell = floor(g);
|
|
852
|
+
|
|
853
|
+
const float aa = 0.01; // soft edges, in cells
|
|
854
|
+
float boardSum = 0.0;
|
|
855
|
+
float allSum = 0.0;
|
|
856
|
+
float prio1 = -1.0, prio2 = -1.0, cov1 = 0.0, cov2 = 0.0, shade1 = 1.0, shade2 = 1.0;
|
|
857
|
+
vec2 uv1 = uv, uv2 = uv;
|
|
858
|
+
float shadowAll = 0.0;
|
|
859
|
+
float seam = 1.0;
|
|
860
|
+
for (int i = 0; i < 9; i++) {
|
|
861
|
+
vec2 c = cell + vec2(mod(float(i), 3.0), floor(float(i) / 3.0)) - 1.0;
|
|
862
|
+
if (c.x < 0.0 || c.y < 0.0 || c.x >= cols || c.y >= rows) continue;
|
|
863
|
+
vec2 center = c + 0.5;
|
|
864
|
+
vec2 local = (g - center) * vec2(aspect, 1.0);
|
|
865
|
+
float h = hash(c + vec2(13.0, 7.0));
|
|
866
|
+
float diag = (c.x / max(cols - 1.0, 1.0) + (rows - 1.0 - c.y) / max(rows - 1.0, 1.0)) * 0.5;
|
|
867
|
+
float delay = (diag + 1.2 * (h - 0.5) * diag * (1.0 - diag)) * 0.6;
|
|
868
|
+
float t = clamp((progress - delay) / 0.4, 0.0, 1.0);
|
|
869
|
+
|
|
870
|
+
float d0 = pieceDist(local, c, grid, aspect);
|
|
871
|
+
float w = 1.0 - smoothstep(-aa, aa, d0);
|
|
872
|
+
allSum += w;
|
|
873
|
+
if (t <= 0.0) {
|
|
874
|
+
boardSum += w;
|
|
875
|
+
seam = min(seam, abs(d0));
|
|
876
|
+
continue;
|
|
877
|
+
}
|
|
878
|
+
float lift = smoothstep(0.0, 0.25, t);
|
|
879
|
+
boardSum += w * (1.0 - smoothstep(0.0, 0.1, t));
|
|
880
|
+
float fall = clamp((t - 0.2) / 0.8, 0.0, 1.0);
|
|
881
|
+
fall *= fall;
|
|
882
|
+
float s = max(1.0 - fall, 0.001);
|
|
883
|
+
float a = (h - 0.5) * 3.0 * fall;
|
|
884
|
+
vec2 off = vec2(0.0, -1.2 * fall);
|
|
885
|
+
mat2 rot = mat2(cos(a), -sin(a), sin(a), cos(a));
|
|
886
|
+
vec2 pl = rot * (local - off) / s;
|
|
887
|
+
float dp = pieceDist(pl, c, grid, aspect);
|
|
888
|
+
float cov = (1.0 - smoothstep(-aa, aa, dp * s)) * min(s * 20.0, 1.0); // fades when tiny
|
|
889
|
+
float shade = (1.0 - 0.5 * fall) * (1.0 - 0.3 * lift * (1.0 - smoothstep(0.0, 0.035, -dp)));
|
|
890
|
+
vec2 puv = (center + pl / vec2(aspect, 1.0)) / grid;
|
|
891
|
+
vec2 sl = rot * (local - off - vec2(0.08, -0.1) * lift) / s;
|
|
892
|
+
float sh = (1.0 - smoothstep(-0.05, 0.12, pieceDist(sl, c, grid, aspect) * s)) * lift * (1.0 - fall) * shadow;
|
|
893
|
+
shadowAll = max(shadowAll, max(sh, w * lift * (1.0 - smoothstep(0.2, 0.5, t)) * shadow));
|
|
894
|
+
float prio = delay;
|
|
895
|
+
if (cov > 0.0 && prio > prio1) {
|
|
896
|
+
prio2 = prio1; cov2 = cov1; uv2 = uv1; shade2 = shade1;
|
|
897
|
+
prio1 = prio; cov1 = cov; uv1 = puv; shade1 = shade;
|
|
898
|
+
} else if (cov > 0.0 && prio > prio2) {
|
|
899
|
+
prio2 = prio; cov2 = cov; uv2 = puv; shade2 = shade;
|
|
900
|
+
}
|
|
901
|
+
}
|
|
902
|
+
vec4 base = mix(getToColor(uv), getFromColor(uv), boardSum / max(allSum, 0.001));
|
|
903
|
+
base.rgb *= (1.0 - shadowAll) * (1.0 - 0.4 * smoothstep(0.0, 0.1, progress) * (1.0 - smoothstep(0.0, 0.015, seam)));
|
|
904
|
+
vec4 p2 = getFromColor(uv2);
|
|
905
|
+
p2.rgb *= shade2;
|
|
906
|
+
vec4 p1 = getFromColor(uv1);
|
|
907
|
+
p1.rgb *= shade1;
|
|
908
|
+
return mix(mix(base, p2, cov2), p1, cov1);
|
|
909
|
+
}`,shatter:`// Author: lbl
|
|
910
|
+
// License: MIT
|
|
911
|
+
// Description: The outgoing image cracks like a pane of glass from an impact point, then its shards break loose from the impact outward, tumbling in 3D and falling away with gravity to reveal the incoming image behind
|
|
912
|
+
// Tags: shatter, fragments, glass, 3d
|
|
913
|
+
|
|
914
|
+
// @param Impact point where the cracks start, from (0, 0) at the bottom left to (1, 1) at the top right
|
|
915
|
+
const vec2 center = vec2(0.5, 0.5);
|
|
916
|
+
// @range(3, 8) Approximate number of rows of shards across the height of the frame
|
|
917
|
+
const float shards = 6.0;
|
|
918
|
+
// @range(0.5, 3) Strength of the gravity: the shards fall faster, and break loose over a longer time
|
|
919
|
+
const float gravity = 1.0;
|
|
920
|
+
// @param Random seed: another value gives other shards, tumbling another way
|
|
921
|
+
const float seed = 0.0;
|
|
922
|
+
|
|
923
|
+
// distance from the camera to the pane, as a part of the frame's height
|
|
924
|
+
const float EYE = 2.5;
|
|
925
|
+
// how far the corners of the shards are moved from a regular grid, as a part of a cell
|
|
926
|
+
const float JITTER = 0.32;
|
|
927
|
+
// width of the anti-aliased edges, the crack lines and the bevels, as a part of the frame's height
|
|
928
|
+
const float EDGE = 0.0012;
|
|
929
|
+
const float CRACK_WIDTH = 0.0025;
|
|
930
|
+
const float BEVEL = 0.006;
|
|
931
|
+
|
|
932
|
+
vec3 hash32(vec2 p) {
|
|
933
|
+
vec3 p3 = fract(vec3(p.xyx) * vec3(0.1031, 0.1030, 0.0973));
|
|
934
|
+
p3 += dot(p3, p3.yxz + 33.33);
|
|
935
|
+
return fract((p3.xxy + p3.yzz) * p3.zyx);
|
|
936
|
+
}
|
|
937
|
+
|
|
938
|
+
float cellSize() {
|
|
939
|
+
return 1.0 / clamp(shards, 3.0, 8.0);
|
|
940
|
+
}
|
|
941
|
+
|
|
942
|
+
vec2 seedOffset() {
|
|
943
|
+
return vec2(37.0, 17.0) * floor(seed);
|
|
944
|
+
}
|
|
945
|
+
|
|
946
|
+
vec2 corner(vec2 p) {
|
|
947
|
+
return (p + JITTER * (2.0 * hash32(p + seedOffset()).xy - 1.0)) * cellSize();
|
|
948
|
+
}
|
|
949
|
+
|
|
950
|
+
// signed distance from q to the line a -> b, positive on its left
|
|
951
|
+
float side(vec2 q, vec2 a, vec2 b) {
|
|
952
|
+
vec2 d = b - a;
|
|
953
|
+
return (d.x * (q.y - a.y) - d.y * (q.x - a.x)) / length(d);
|
|
954
|
+
}
|
|
955
|
+
|
|
956
|
+
bool diagonalUp(vec2 c) {
|
|
957
|
+
return hash32(c + seedOffset() + 0.5).z > 0.5;
|
|
958
|
+
}
|
|
959
|
+
|
|
960
|
+
// distance from q to the edges of the triangle p0 p1 p2 (counterclockwise), positive inside
|
|
961
|
+
float triangleDist(vec2 q, vec2 p0, vec2 p1, vec2 p2) {
|
|
962
|
+
return min(min(side(q, p0, p1), side(q, p1, p2)), side(q, p2, p0));
|
|
963
|
+
}
|
|
964
|
+
|
|
965
|
+
// the shard that contains q on the unbroken pane: (its cell, its triangle, the distance from q to its nearest crack)
|
|
966
|
+
vec4 locate(vec2 q) {
|
|
967
|
+
vec2 c = floor(q / cellSize());
|
|
968
|
+
// the cells' sides are not straight: step to the neighbor cell when q is beyond one of them
|
|
969
|
+
vec2 a, b, cc, d;
|
|
970
|
+
for (int i = 0; i < 2; i++) {
|
|
971
|
+
a = corner(c);
|
|
972
|
+
b = corner(c + vec2(1.0, 0.0));
|
|
973
|
+
cc = corner(c + 1.0);
|
|
974
|
+
d = corner(c + vec2(0.0, 1.0));
|
|
975
|
+
c.x += side(q, d, a) < 0.0 ? -1.0 : (side(q, b, cc) < 0.0 ? 1.0 : 0.0);
|
|
976
|
+
a = corner(c);
|
|
977
|
+
b = corner(c + vec2(1.0, 0.0));
|
|
978
|
+
cc = corner(c + 1.0);
|
|
979
|
+
d = corner(c + vec2(0.0, 1.0));
|
|
980
|
+
c.y += side(q, a, b) < 0.0 ? -1.0 : (side(q, cc, d) < 0.0 ? 1.0 : 0.0);
|
|
981
|
+
}
|
|
982
|
+
a = corner(c);
|
|
983
|
+
b = corner(c + vec2(1.0, 0.0));
|
|
984
|
+
cc = corner(c + 1.0);
|
|
985
|
+
d = corner(c + vec2(0.0, 1.0));
|
|
986
|
+
bool up = diagonalUp(c);
|
|
987
|
+
float d0 = up ? triangleDist(q, a, b, cc) : triangleDist(q, a, b, d);
|
|
988
|
+
float d1 = up ? triangleDist(q, a, cc, d) : triangleDist(q, b, cc, d);
|
|
989
|
+
return vec4(c, d1 > d0 ? 1.0 : 0.0, abs(max(d0, d1)));
|
|
990
|
+
}
|
|
991
|
+
|
|
992
|
+
// Rodrigues' rotation of v around the unit axis k
|
|
993
|
+
vec3 rotate(vec3 v, vec3 k, float angle) {
|
|
994
|
+
float c = cos(angle), s = sin(angle);
|
|
995
|
+
return v * c + cross(k, v) * s + k * dot(k, v) * (1.0 - c);
|
|
996
|
+
}
|
|
997
|
+
|
|
998
|
+
vec2 impact() {
|
|
999
|
+
return clamp(center, 0.0, 1.0) * vec2(ratio, 1.0);
|
|
1000
|
+
}
|
|
1001
|
+
|
|
1002
|
+
float reach() {
|
|
1003
|
+
vec2 c = impact();
|
|
1004
|
+
return length(max(c, vec2(ratio, 1.0) - c));
|
|
1005
|
+
}
|
|
1006
|
+
|
|
1007
|
+
float fallMargin() {
|
|
1008
|
+
return 0.1 + 1.5 * cellSize();
|
|
1009
|
+
}
|
|
1010
|
+
|
|
1011
|
+
// the time a shard breaks loose: the nearer the impact the sooner, and late enough to fall out of the frame by the end
|
|
1012
|
+
// (dn: its distance to the impact, as a part of the reach)
|
|
1013
|
+
float releaseTime(vec2 mid, float dn, float h, float g, float margin) {
|
|
1014
|
+
float latest = max(0.98 - sqrt(2.0 * (mid.y + margin) / g), 0.04);
|
|
1015
|
+
return 0.04 + (latest - 0.04) * (0.8 * pow(dn, 0.8) + 0.2 * h);
|
|
1016
|
+
}
|
|
1017
|
+
|
|
1018
|
+
float flash(vec2 q) {
|
|
1019
|
+
float f = sin(3.141592653589793 * clamp(progress / 0.12, 0.0, 1.0));
|
|
1020
|
+
vec2 d = q - impact();
|
|
1021
|
+
return 0.6 * f * exp(-dot(d, d) / (0.004 + 0.02 * progress));
|
|
1022
|
+
}
|
|
1023
|
+
|
|
1024
|
+
vec4 transition(vec2 uv) {
|
|
1025
|
+
float s = cellSize();
|
|
1026
|
+
vec2 a = vec2(uv.x * ratio, uv.y);
|
|
1027
|
+
vec3 eye = vec3(0.5 * ratio, 0.5, -EYE);
|
|
1028
|
+
vec3 ray = vec3(a, 0.0) - eye;
|
|
1029
|
+
vec3 light = normalize(vec3(-0.35, 0.55, -1.0));
|
|
1030
|
+
vec3 halfway = normalize(light - normalize(ray));
|
|
1031
|
+
float g = 12.0 * clamp(gravity, 0.5, 3.0);
|
|
1032
|
+
vec2 imp = impact();
|
|
1033
|
+
float rch = reach();
|
|
1034
|
+
float margin = fallMargin();
|
|
1035
|
+
// the cracks run from the impact to the farthest corner, before the last shards break loose
|
|
1036
|
+
float crackTime = clamp(0.6 * (0.94 - sqrt(2.0 * (1.0 + margin) / g)), 0.05, 0.22);
|
|
1037
|
+
|
|
1038
|
+
vec4 pane = vec4(0.0);
|
|
1039
|
+
float paneDepth = 1e9;
|
|
1040
|
+
vec4 here = locate(a);
|
|
1041
|
+
vec2 hc = here.xy;
|
|
1042
|
+
vec2 ha = corner(hc), hb = corner(hc + vec2(1.0, 0.0)), hcc = corner(hc + 1.0), hd = corner(hc + vec2(0.0, 1.0));
|
|
1043
|
+
bool hup = diagonalUp(hc);
|
|
1044
|
+
vec2 hcenter = here.z < 0.5 ? (hup ? ha + hb + hcc : ha + hb + hd) : (hup ? ha + hcc + hd : hb + hcc + hd);
|
|
1045
|
+
vec3 hh = hash32(hc + vec2(0.31, 0.57) * (here.z + 1.0) + seedOffset());
|
|
1046
|
+
hcenter /= 3.0;
|
|
1047
|
+
if (progress < releaseTime(hcenter, clamp(length(hcenter - imp) / rch, 0.0, 1.0), hh.x, g, margin)) {
|
|
1048
|
+
vec4 col = getFromColor(uv);
|
|
1049
|
+
float crack = clamp((progress - crackTime * length(a - imp) / rch) / 0.03, 0.0, 1.0);
|
|
1050
|
+
// cracked shards settle at slightly different angles (no change while flat: dot(n, light) = -light.z)
|
|
1051
|
+
vec3 n = rotate(vec3(0.0, 0.0, -1.0), normalize(vec3(hh.yz - 0.5, 0.0) + 1e-4), 0.06 * crack * (hh.x - 0.5));
|
|
1052
|
+
col.rgb *= 1.0 + 1.2 * (dot(n, light) + light.z);
|
|
1053
|
+
col.rgb += crack * 0.35 * pow(max(dot(n, halfway), 0.0), 400.0) * col.a;
|
|
1054
|
+
float line = crack * (1.0 - smoothstep(0.0, CRACK_WIDTH, here.w));
|
|
1055
|
+
col.rgb = mix(col.rgb, vec3(0.95, 0.98, 1.0) * col.a, 0.85 * line);
|
|
1056
|
+
pane = col;
|
|
1057
|
+
paneDepth = 1.0;
|
|
1058
|
+
}
|
|
1059
|
+
|
|
1060
|
+
// the two nearest loose shards: depth along the ray, color, coverage
|
|
1061
|
+
float t1 = 1e9, t2 = 1e9;
|
|
1062
|
+
vec4 c1 = vec4(0.0), c2 = vec4(0.0);
|
|
1063
|
+
float a1 = 0.0, a2 = 0.0;
|
|
1064
|
+
float shadow = 0.0;
|
|
1065
|
+
|
|
1066
|
+
// the shards that broke loose, searched in the cells around and above the pixel since they fall,
|
|
1067
|
+
// looking a bit toward the impact and the middle since they drift away and grow toward the camera
|
|
1068
|
+
vec2 look = a - 0.06 * progress * (a - imp) / rch - (a - eye.xy) * 0.06 * progress;
|
|
1069
|
+
vec2 g0 = floor(look / s) - 1.0;
|
|
1070
|
+
float rows = ceil(1.0 / s);
|
|
1071
|
+
for (int ri = 0; ri < 11; ri++) {
|
|
1072
|
+
float j = g0.y + float(ri);
|
|
1073
|
+
if (j > rows) break;
|
|
1074
|
+
if (j < -1.0) continue;
|
|
1075
|
+
for (int ci = 0; ci < 3; ci++) {
|
|
1076
|
+
vec2 c = vec2(g0.x + float(ci), j);
|
|
1077
|
+
vec2 ca = corner(c), cb = corner(c + vec2(1.0, 0.0)), ccc = corner(c + 1.0), cd = corner(c + vec2(0.0, 1.0));
|
|
1078
|
+
bool up = diagonalUp(c);
|
|
1079
|
+
for (int k = 0; k < 2; k++) {
|
|
1080
|
+
vec2 p0 = (k == 1 && !up) ? cb : ca;
|
|
1081
|
+
vec2 p1 = k == 0 ? cb : ccc;
|
|
1082
|
+
vec2 p2 = (k == 0 && up) ? ccc : cd;
|
|
1083
|
+
vec2 mid = (p0 + p1 + p2) / 3.0;
|
|
1084
|
+
vec3 h1 = hash32(c + vec2(0.31, 0.57) * float(k + 1) + seedOffset());
|
|
1085
|
+
vec2 away = mid - imp;
|
|
1086
|
+
float dist = length(away);
|
|
1087
|
+
float dn = clamp(dist / rch, 0.0, 1.0);
|
|
1088
|
+
float e = progress - releaseTime(mid, dn, h1.x, g, margin);
|
|
1089
|
+
if (e <= 0.0) continue;
|
|
1090
|
+
vec3 h2 = hash32(c + vec2(0.73, 0.19) * float(k + 1) + seedOffset());
|
|
1091
|
+
float near = 1.0 - dn;
|
|
1092
|
+
vec3 vel = vec3(away / max(dist, 1e-3) * (0.03 + 0.08 * h1.y) * (0.4 + near), -(0.05 + 0.2 * near * h1.z));
|
|
1093
|
+
vec3 pos = vec3(mid, 0.0) + vel * e - vec3(0.0, 0.5 * g * e * e, 0.0);
|
|
1094
|
+
if (pos.y + 1.5 * s < -0.05) continue;
|
|
1095
|
+
vec3 axis = normalize(vec3(h2.x - 0.5, h2.y - 0.5, 0.3 * (h2.z - 0.5)) + 1e-4);
|
|
1096
|
+
float angle = (3.0 + 5.0 * h2.z) * (h2.x < 0.5 ? -1.0 : 1.0) * e;
|
|
1097
|
+
vec3 n = rotate(vec3(0.0, 0.0, -1.0), axis, angle);
|
|
1098
|
+
float rel = smoothstep(0.0, 0.04, e);
|
|
1099
|
+
|
|
1100
|
+
float den = dot(ray, n);
|
|
1101
|
+
float t = dot(pos - eye, n) / (abs(den) > 1e-4 ? den : 1e-4);
|
|
1102
|
+
vec2 q = mid + rotate(eye + t * ray - pos, axis, -angle).xy;
|
|
1103
|
+
float border = min(min(q.x, ratio - q.x), min(q.y, 1.0 - q.y));
|
|
1104
|
+
float inside = triangleDist(q, p0, p1, p2);
|
|
1105
|
+
float ed = min(inside, border);
|
|
1106
|
+
if (t > 0.0 && t < t2 && t < paneDepth && ed > 0.0) {
|
|
1107
|
+
vec3 nf = den > 0.0 ? -n : n;
|
|
1108
|
+
vec4 col = getFromColor(vec2(q.x / ratio, q.y));
|
|
1109
|
+
col.rgb *= mix(1.0, clamp(dot(nf, light) / -light.z, 0.45, 1.1), rel);
|
|
1110
|
+
float glint = max(dot(nf, halfway), 0.0);
|
|
1111
|
+
col.rgb += rel * 0.3 * pow(glint, 60.0) * col.a;
|
|
1112
|
+
float line = 0.85 * (1.0 - smoothstep(0.0, CRACK_WIDTH, inside)) * (1.0 - rel);
|
|
1113
|
+
float bevel = 0.8 * rel * (1.0 - smoothstep(0.0, BEVEL, ed)) * (0.3 + 0.7 * pow(glint, 6.0));
|
|
1114
|
+
col.rgb = mix(col.rgb, vec3(0.92, 0.97, 0.97) * col.a, max(line, bevel));
|
|
1115
|
+
float cover = mix(1.0, smoothstep(0.0, 2.0 * EDGE, ed), rel);
|
|
1116
|
+
if (t < t1) {
|
|
1117
|
+
t2 = t1; c2 = c1; a2 = a1;
|
|
1118
|
+
t1 = t; c1 = col; a1 = cover;
|
|
1119
|
+
} else {
|
|
1120
|
+
t2 = t; c2 = col; a2 = cover;
|
|
1121
|
+
}
|
|
1122
|
+
}
|
|
1123
|
+
|
|
1124
|
+
float lden = dot(light, n);
|
|
1125
|
+
float ts = dot(pos - vec3(a, 0.0), n) / (abs(lden) > 1e-4 ? lden : 1e-4);
|
|
1126
|
+
vec2 qs = mid + rotate(vec3(a, 0.0) + ts * light - pos, axis, -angle).xy;
|
|
1127
|
+
float eds = min(triangleDist(qs, p0, p1, p2), min(min(qs.x, ratio - qs.x), min(qs.y, 1.0 - qs.y)));
|
|
1128
|
+
if (ts > 0.0 && eds > 0.0) {
|
|
1129
|
+
shadow = max(shadow, rel * smoothstep(0.0, 0.004 + 0.08 * ts, eds) * 0.45 * (1.0 - smoothstep(0.1, 0.9, ts)));
|
|
1130
|
+
}
|
|
1131
|
+
}
|
|
1132
|
+
}
|
|
1133
|
+
}
|
|
1134
|
+
|
|
1135
|
+
// the incoming image behind, then the pane still in place, then the loose shards in front
|
|
1136
|
+
vec4 back = getToColor(uv);
|
|
1137
|
+
back.rgb *= 1.0 - shadow;
|
|
1138
|
+
pane.rgb *= 1.0 - shadow;
|
|
1139
|
+
if (paneDepth == 1.0) back = pane;
|
|
1140
|
+
vec4 color = c1 * a1 + c2 * min(a2, 1.0 - a1) + back * max(1.0 - a1 - a2, 0.0);
|
|
1141
|
+
color.rgb += flash(a) * color.a;
|
|
1142
|
+
return color;
|
|
1143
|
+
}`,"tile-blast":`// Author: gre
|
|
1144
|
+
// License: MIT
|
|
1145
|
+
// Description: The outgoing image breaks into square tiles that blast toward the viewer from a point, the nearest ones first, each one tumbling and growing in perspective as it flies out past the frame, uncovering the incoming image behind them
|
|
1146
|
+
// Tags: 3d, tiles, explode, fragments
|
|
1147
|
+
|
|
1148
|
+
// @range(3, 12, 1) Number of rows of tiles
|
|
1149
|
+
const int rows = 6;
|
|
1150
|
+
// @param Point the tiles blast away from, in texture coordinates
|
|
1151
|
+
const vec2 center = vec2(0.5, 0.5);
|
|
1152
|
+
// @range(0, 1) How much the tiles spin and tumble as they fly
|
|
1153
|
+
const float spin = 0.6;
|
|
1154
|
+
// @range(0, 1) How much the tiles darken as they turn from the light, and the shadows they cast
|
|
1155
|
+
const float shading = 0.6;
|
|
1156
|
+
|
|
1157
|
+
// distance of the eye, and depth reached by a tile at the end of its flight, in frame heights
|
|
1158
|
+
const float EYE = 2.0;
|
|
1159
|
+
const float ZEND = 1.6;
|
|
1160
|
+
// how far a tile drifts away from the blast point while it flies, in frame heights
|
|
1161
|
+
const float DRIFT = 0.3;
|
|
1162
|
+
// a tile leaves after WAVE times its distance to the blast point (plus up to JITTER) and flies for FLIGHT,
|
|
1163
|
+
// or faster after FINAL so that every tile is gone at the end
|
|
1164
|
+
const float WAVE = 0.75;
|
|
1165
|
+
const float JITTER = 0.06;
|
|
1166
|
+
const float FLIGHT = 0.45;
|
|
1167
|
+
const float FINAL = 0.75;
|
|
1168
|
+
const float EDGE = 0.0015;
|
|
1169
|
+
// direction toward the light, upper left, and the half vector between it and the eye
|
|
1170
|
+
const vec3 L = vec3(-0.32, 0.4, 0.86);
|
|
1171
|
+
const vec3 HV = vec3(-0.1659, 0.2073, 0.9641);
|
|
1172
|
+
|
|
1173
|
+
vec4 hash4(vec2 p) {
|
|
1174
|
+
vec4 q = fract(vec4(p.xyxy) * vec4(0.1031, 0.1030, 0.0973, 0.1099));
|
|
1175
|
+
q += dot(q, q.wzxy + 33.33);
|
|
1176
|
+
return fract((q.xxyz + q.yzzw) * q.zywx);
|
|
1177
|
+
}
|
|
1178
|
+
|
|
1179
|
+
// how far the tile of cell g is along its flight, 0 at rest to 1 gone: a kick, then it speeds up toward the eye
|
|
1180
|
+
float flight(vec2 g, vec2 size, vec2 c, float dmax) {
|
|
1181
|
+
float d = clamp((length((g + 0.5) * size - c) - 0.7 * size.y) / dmax, 0.0, 1.0);
|
|
1182
|
+
float t = (progress - WAVE * d - JITTER * hash4(g).x) / FLIGHT;
|
|
1183
|
+
t = clamp(max(t, (progress - FINAL) / (1.0 - FINAL)), 0.0, 1.0);
|
|
1184
|
+
return t * (0.55 + 0.45 * t);
|
|
1185
|
+
}
|
|
1186
|
+
|
|
1187
|
+
vec2 flyDir(vec2 g, vec2 size, vec2 c) {
|
|
1188
|
+
vec2 v = (g + 0.5) * size - c;
|
|
1189
|
+
float l = length(v);
|
|
1190
|
+
// a tile right on the blast point flies off in a direction of its own
|
|
1191
|
+
vec2 a = 6.2831853 * hash4(g + 7.0).xy;
|
|
1192
|
+
return l > 0.02 * size.y ? v / l : vec2(cos(a.x), sin(a.x));
|
|
1193
|
+
}
|
|
1194
|
+
|
|
1195
|
+
// Rodrigues rotation of v around the unit axis k, by the angle of cosine cb and sine sb
|
|
1196
|
+
vec3 turn(vec3 v, vec3 k, float cb, float sb) {
|
|
1197
|
+
return v * cb + cross(k, v) * sb + k * dot(k, v) * (1.0 - cb);
|
|
1198
|
+
}
|
|
1199
|
+
|
|
1200
|
+
vec4 transition(vec2 uv) {
|
|
1201
|
+
vec2 aspect = vec2(ratio, 1.0);
|
|
1202
|
+
vec2 P = uv * aspect;
|
|
1203
|
+
vec2 c = clamp(center, 0.0, 1.0) * aspect;
|
|
1204
|
+
float n = clamp(float(rows), 1.0, 12.0);
|
|
1205
|
+
vec2 grid = vec2(max(1.0, floor(ratio * n + 0.5)), n);
|
|
1206
|
+
vec2 size = aspect / grid;
|
|
1207
|
+
// from the blast point to the farthest tile center, beyond the tiles that leave first
|
|
1208
|
+
float dmax = max(length(max(c, aspect - c) - 0.5 * size) - 0.7 * size.y, 1e-3);
|
|
1209
|
+
float spinAmt = clamp(spin, 0.0, 1.0);
|
|
1210
|
+
float shadeAmt = clamp(shading, 0.0, 1.0);
|
|
1211
|
+
vec3 eye = vec3(c, EYE);
|
|
1212
|
+
vec3 ray = vec3(P - c, -EYE);
|
|
1213
|
+
|
|
1214
|
+
// the two nearest tiles seen here: depth, cell, image point, coverage, shading
|
|
1215
|
+
float z1 = 1e9, z2 = 1e9;
|
|
1216
|
+
vec2 g1 = vec2(-1e4), g2 = vec2(-1e4);
|
|
1217
|
+
vec2 q1 = P, q2 = P;
|
|
1218
|
+
float m1 = 0.0, m2 = 0.0, s1 = 1.0, s2 = 1.0;
|
|
1219
|
+
float lift1 = 0.0, lift2 = 0.0;
|
|
1220
|
+
|
|
1221
|
+
// march along the flight: for each step, find where a tile seen here at that step would have started,
|
|
1222
|
+
// first along the line from the blast point, then along the flight of the tile found there,
|
|
1223
|
+
// and test the 2x2 cells nearest to it
|
|
1224
|
+
// the steps move the start point by less than half a tile
|
|
1225
|
+
float dw = max(0.4 * size.y / (length(P - c) * ZEND / EYE + DRIFT), 1.0 / 31.0);
|
|
1226
|
+
vec2 lastCell = vec2(-1e4), lastSide = vec2(0.0);
|
|
1227
|
+
for (int k = 0; k < 32; k++) {
|
|
1228
|
+
float wk = float(k) * dw;
|
|
1229
|
+
if (wk > 1.0 + dw) break;
|
|
1230
|
+
wk = min(wk, 1.0);
|
|
1231
|
+
vec2 back = c + (P - c) * (EYE - ZEND * wk) / EYE;
|
|
1232
|
+
vec2 home = back - DRIFT * wk * flyDir(floor(back / size), size, c);
|
|
1233
|
+
home = back - DRIFT * wk * flyDir(floor(home / size), size, c);
|
|
1234
|
+
vec2 f = home / size;
|
|
1235
|
+
vec2 cell = floor(f);
|
|
1236
|
+
vec2 side = step(0.5, fract(f)) * 2.0 - 1.0;
|
|
1237
|
+
// consecutive steps often land on the same cells
|
|
1238
|
+
if (cell == lastCell && side == lastSide) continue;
|
|
1239
|
+
lastCell = cell;
|
|
1240
|
+
lastSide = side;
|
|
1241
|
+
for (int j = 0; j < 4; j++) {
|
|
1242
|
+
vec2 g = cell + vec2(j == 1 || j == 3 ? side.x : 0.0, j >= 2 ? side.y : 0.0);
|
|
1243
|
+
if (g.x < 0.0 || g.y < 0.0 || g.x >= grid.x || g.y >= grid.y) continue;
|
|
1244
|
+
if (g == g1 || g == g2) continue;
|
|
1245
|
+
float u = flight(g, size, c, dmax);
|
|
1246
|
+
if (u >= 1.0) continue;
|
|
1247
|
+
vec4 h = hash4(g + 31.0);
|
|
1248
|
+
vec2 dir = flyDir(g, size, c);
|
|
1249
|
+
vec2 h0 = (g + 0.5) * size;
|
|
1250
|
+
vec3 tc = vec3(h0 + dir * DRIFT * u, ZEND * u);
|
|
1251
|
+
float a = spinAmt * 2.4 * (h.x - 0.5) * u;
|
|
1252
|
+
float b = spinAmt * (0.5 + 0.7 * h.y) * (h.z < 0.5 ? -1.0 : 1.0) * 1.8 * u;
|
|
1253
|
+
vec3 ax = normalize(vec3(-dir.y + 0.4 * (h.w - 0.5), dir.x, 0.0));
|
|
1254
|
+
float ca = cos(a), sa = sin(a), cb = cos(b), sb = sin(b);
|
|
1255
|
+
vec3 a1 = turn(vec3(ca, sa, 0.0), ax, cb, sb);
|
|
1256
|
+
vec3 a2 = turn(vec3(-sa, ca, 0.0), ax, cb, sb);
|
|
1257
|
+
vec3 nrm = turn(vec3(0.0, 0.0, 1.0), ax, cb, sb);
|
|
1258
|
+
float den = dot(ray, nrm);
|
|
1259
|
+
if (abs(den) < 1e-5) continue;
|
|
1260
|
+
float lam = dot(tc - eye, nrm) / den;
|
|
1261
|
+
if (lam <= 0.0 || lam >= z2) continue;
|
|
1262
|
+
vec3 hit = eye + lam * ray - tc;
|
|
1263
|
+
vec2 l = vec2(dot(hit, a1), dot(hit, a2));
|
|
1264
|
+
// anti-aliased edges, scaled to the screen; at rest the edges are hard, so that the tiles join without seams
|
|
1265
|
+
vec2 box = 0.5 * size - abs(l);
|
|
1266
|
+
float e = min(box.x, box.y) * EYE / (EYE - tc.z) * max(abs(nrm.z), 0.15);
|
|
1267
|
+
float m = clamp(e / (2.0 * EDGE) + 0.5 + 0.5 * (1.0 - smoothstep(0.0, 0.06, u)), 0.0, 1.0);
|
|
1268
|
+
if (m <= 0.0) continue;
|
|
1269
|
+
vec3 nf = den < 0.0 ? nrm : -nrm;
|
|
1270
|
+
float lit = 1.0 - 0.6 * shadeAmt * (1.0 - clamp(dot(nf, L) / L.z, 0.0, 1.0));
|
|
1271
|
+
float lift = smoothstep(0.0, 0.15, u);
|
|
1272
|
+
lit += shadeAmt * lift * (0.2 * pow(max(dot(nf, HV), 0.0), 60.0) + 0.3 * (1.0 - smoothstep(0.0, 0.003, e)));
|
|
1273
|
+
if (den >= 0.0) lit *= 0.55;
|
|
1274
|
+
if (lam < z1) {
|
|
1275
|
+
z2 = z1; g2 = g1; q2 = q1; m2 = m1; s2 = s1; lift2 = lift1;
|
|
1276
|
+
z1 = lam; g1 = g; q1 = h0 + l; m1 = m; s1 = lit; lift1 = lift;
|
|
1277
|
+
} else {
|
|
1278
|
+
z2 = lam; g2 = g; q2 = h0 + l; m2 = m; s2 = lit; lift2 = lift;
|
|
1279
|
+
}
|
|
1280
|
+
}
|
|
1281
|
+
}
|
|
1282
|
+
|
|
1283
|
+
float shTo = 0.0, sh1 = 0.0, sh2 = 0.0;
|
|
1284
|
+
if (shadeAmt > 0.0) {
|
|
1285
|
+
vec2 base = floor(P / size);
|
|
1286
|
+
for (int y = -1; y <= 1; y++) {
|
|
1287
|
+
for (int x = -1; x <= 1; x++) {
|
|
1288
|
+
vec2 g = base + vec2(float(x), float(y));
|
|
1289
|
+
if (g.x < 0.0 || g.y < 0.0 || g.x >= grid.x || g.y >= grid.y) continue;
|
|
1290
|
+
float u = flight(g, size, c, dmax);
|
|
1291
|
+
float z = ZEND * u;
|
|
1292
|
+
// the shadow fades before it can reach beyond the next tile
|
|
1293
|
+
float w = smoothstep(0.0, 0.03, u) * (1.0 - smoothstep(0.1 * size.y, 0.7 * size.y, z));
|
|
1294
|
+
if (w <= 0.0) continue;
|
|
1295
|
+
vec2 o = P + L.xy / L.z * z - ((g + 0.5) * size + flyDir(g, size, c) * DRIFT * u);
|
|
1296
|
+
float blur = 0.004 + 0.25 * z;
|
|
1297
|
+
vec2 sb = 0.5 * size - abs(o) + 0.5 * blur;
|
|
1298
|
+
float sh = smoothstep(0.0, blur, sb.x) * smoothstep(0.0, blur, sb.y) * w;
|
|
1299
|
+
// a tile casts no shadow on itself
|
|
1300
|
+
shTo = max(shTo, sh);
|
|
1301
|
+
if (g != g1) sh1 = max(sh1, sh);
|
|
1302
|
+
if (g != g2) sh2 = max(sh2, sh);
|
|
1303
|
+
}
|
|
1304
|
+
}
|
|
1305
|
+
}
|
|
1306
|
+
float dark = 0.5 * shadeAmt;
|
|
1307
|
+
|
|
1308
|
+
float settle = 1.0 - progress;
|
|
1309
|
+
vec2 tq = c + (P - c) / (1.0 + 0.06 * settle * settle);
|
|
1310
|
+
vec4 col = getToColor(tq / aspect);
|
|
1311
|
+
col.rgb *= (1.0 - dark * shTo) * (1.0 - 0.25 * shadeAmt * (1.0 - smoothstep(0.2, 0.9, progress)));
|
|
1312
|
+
if (m2 > 0.0) {
|
|
1313
|
+
vec4 img = getFromColor(clamp(q2 / aspect, 0.0, 1.0));
|
|
1314
|
+
img.rgb *= s2 * mix(1.0 - dark * sh2, 1.0, lift2);
|
|
1315
|
+
col = mix(col, img, m2);
|
|
1316
|
+
}
|
|
1317
|
+
if (m1 > 0.0) {
|
|
1318
|
+
vec4 img = getFromColor(clamp(q1 / aspect, 0.0, 1.0));
|
|
1319
|
+
img.rgb *= s1 * mix(1.0 - dark * sh1, 1.0, lift1);
|
|
1320
|
+
col = mix(col, img, m1);
|
|
1321
|
+
}
|
|
1322
|
+
return col;
|
|
1323
|
+
}`,tunnel:`// Author: gre
|
|
1324
|
+
// License: MIT
|
|
1325
|
+
// Description: The camera flies down a tunnel lined with the outgoing image toward the incoming one, which opens at its far end and grows to fill the frame
|
|
1326
|
+
// Tags: zoom, 3d, warp, radial
|
|
1327
|
+
|
|
1328
|
+
// @range(0.5, 10) How far and fast the camera flies down the tunnel
|
|
1329
|
+
const float speed = 6.0;
|
|
1330
|
+
// @range(-2, 2) How much the walls spiral as they rush by
|
|
1331
|
+
const float twist = 0.5;
|
|
1332
|
+
|
|
1333
|
+
vec2 rotate(vec2 v, float a) {
|
|
1334
|
+
float c = cos(a);
|
|
1335
|
+
float s = sin(a);
|
|
1336
|
+
return vec2(c * v.x - s * v.y, s * v.x + c * v.y);
|
|
1337
|
+
}
|
|
1338
|
+
|
|
1339
|
+
vec4 transition(vec2 uv) {
|
|
1340
|
+
vec2 aspect = vec2(ratio, 1.0);
|
|
1341
|
+
vec2 c = (uv - 0.5) * aspect;
|
|
1342
|
+
float r = length(c);
|
|
1343
|
+
// A tube as wide as the frame's corners runs from the camera to an end wall
|
|
1344
|
+
// at depth \`far\`; the outgoing image is projected onto it from the starting
|
|
1345
|
+
// point of view, so it looks flat at first. The camera flies to one unit
|
|
1346
|
+
// before the end wall, where the incoming image hangs.
|
|
1347
|
+
float R = length(0.5 * aspect);
|
|
1348
|
+
float far = 1.0 + speed;
|
|
1349
|
+
// the distance to the end wall shrinks geometrically, so the end grows evenly
|
|
1350
|
+
float e = mix(progress, progress * progress * (3.0 - 2.0 * progress), 0.7);
|
|
1351
|
+
float d = pow(far, 1.0 - e);
|
|
1352
|
+
float t = far - d; // distance flown
|
|
1353
|
+
float k = r * d < R ? d / far : R / (R + t * r); // image scale at that point
|
|
1354
|
+
float a = twist * min(t * r / R, t / d); // spiral, continuous at the end wall
|
|
1355
|
+
vec4 walls = getFromColor(0.5 + rotate(c * k, a) / aspect);
|
|
1356
|
+
walls.rgb *= 0.4 + 0.6 * sqrt(k); // darker where the walls are close
|
|
1357
|
+
float open = smoothstep(0.0, 0.6, progress);
|
|
1358
|
+
vec2 q = 0.5 + (uv - 0.5) * d / max(open, 1e-4);
|
|
1359
|
+
vec2 inside = step(0.0, q) * step(q, vec2(1.0));
|
|
1360
|
+
return mix(walls, getToColor(q), inside.x * inside.y * step(r * d, R));
|
|
1361
|
+
}`,vortex:`// Author: gre
|
|
1362
|
+
// License: MIT
|
|
1363
|
+
// Description: The outgoing image breaks into hundreds of small squares that a tornado carries away along a spiral around the center, from the eye outward, uncovering the incoming image
|
|
1364
|
+
// Tags: tiles, spiral, rotation, shatter
|
|
1365
|
+
|
|
1366
|
+
// @range(4, 40, 1) Number of rows of squares
|
|
1367
|
+
const int grid = 24;
|
|
1368
|
+
// Center of the tornado
|
|
1369
|
+
const vec2 center = vec2(0.5, 0.5);
|
|
1370
|
+
// @range(-4, 4) Turns each square makes around the center as it flies away (negative turns clockwise)
|
|
1371
|
+
const float spin = 1.0;
|
|
1372
|
+
// @range(0, 1) How randomly the squares leave: 0 from the center outward, 1 in any order
|
|
1373
|
+
const float randomness = 0.2;
|
|
1374
|
+
|
|
1375
|
+
// the squares leave in GROUPS waves, each one flying for DURATION of the transition
|
|
1376
|
+
const int GROUPS = 24;
|
|
1377
|
+
const float DURATION = 0.25;
|
|
1378
|
+
const float AA = 0.0015;
|
|
1379
|
+
const float TAU = 6.2831853;
|
|
1380
|
+
|
|
1381
|
+
float hash(vec2 n) {
|
|
1382
|
+
return fract(sin(dot(n, vec2(12.9898, 78.233))) * 43758.5453);
|
|
1383
|
+
}
|
|
1384
|
+
|
|
1385
|
+
int groupOf(vec2 n, float h, vec2 c, float maxR) {
|
|
1386
|
+
float r = min(length((n + 0.5) * h - c) / (0.85 * maxR), 1.0);
|
|
1387
|
+
float key = clamp(mix(r * sqrt(r), hash(n), clamp(randomness, 0.0, 1.0)), 0.0, 0.9999);
|
|
1388
|
+
return int(floor(key * float(GROUPS)));
|
|
1389
|
+
}
|
|
1390
|
+
|
|
1391
|
+
// local time of a wave's flight, 0 before it leaves, 1 once it has vanished
|
|
1392
|
+
float flight(int g) {
|
|
1393
|
+
float delay = float(g) / float(GROUPS) * (1.0 - DURATION);
|
|
1394
|
+
return clamp((progress - delay) / DURATION, 0.0, 1.0);
|
|
1395
|
+
}
|
|
1396
|
+
|
|
1397
|
+
vec4 premultiplied(vec4 c) {
|
|
1398
|
+
return vec4(c.rgb * c.a, c.a);
|
|
1399
|
+
}
|
|
1400
|
+
|
|
1401
|
+
vec4 transition(vec2 uv) {
|
|
1402
|
+
vec2 aspect = vec2(ratio, 1.0);
|
|
1403
|
+
vec2 p = uv * aspect;
|
|
1404
|
+
vec2 c = center * aspect;
|
|
1405
|
+
float maxR = max(max(length(c), length(c - vec2(ratio, 0.0))), max(length(c - vec2(0.0, 1.0)), length(c - aspect)));
|
|
1406
|
+
float h = 1.0 / float(grid < 1 ? 1 : grid);
|
|
1407
|
+
float reach = 0.7 * maxR;
|
|
1408
|
+
|
|
1409
|
+
vec2 n0 = floor(p / h);
|
|
1410
|
+
// (it shows once the square above it has started to move away, so their edges never let it through at rest)
|
|
1411
|
+
float k = smoothstep(0.0, 0.05, flight(groupOf(n0, h, c, maxR)));
|
|
1412
|
+
vec4 col = k <= 0.0 ? premultiplied(getFromColor(uv)) : k >= 1.0 ? premultiplied(getToColor(uv)) : mix(premultiplied(getFromColor(uv)), premultiplied(getToColor(uv)), k);
|
|
1413
|
+
|
|
1414
|
+
// the flying squares, painted from the last wave to leave (lowest) to the first (highest)
|
|
1415
|
+
for (int k = 0; k < GROUPS; k++) {
|
|
1416
|
+
int g = GROUPS - 1 - k;
|
|
1417
|
+
float s = flight(g);
|
|
1418
|
+
if (s <= 0.0 || s >= 1.0) continue;
|
|
1419
|
+
float e = s * s;
|
|
1420
|
+
// like in a tornado, the squares near the eye (the first to leave) spin much faster than
|
|
1421
|
+
// the outer ones; all of them orbit before they are flung out
|
|
1422
|
+
float angle = spin * TAU * e * 2.0 / (1.0 + 6.0 * float(g) / float(GROUPS));
|
|
1423
|
+
float push = reach * e * s;
|
|
1424
|
+
float size = (1.0 + 0.35 * sin(3.1415927 * s)) * (1.0 - s * s * s);
|
|
1425
|
+
float ca = cos(angle);
|
|
1426
|
+
float sa = sin(angle);
|
|
1427
|
+
mat2 rot = mat2(ca, sa, -sa, ca);
|
|
1428
|
+
// undo the wave's spiral to guess which square lands here, then test its neighbors exactly
|
|
1429
|
+
vec2 u = (p - c) * rot;
|
|
1430
|
+
float ru = length(u);
|
|
1431
|
+
vec2 guess = c + (ru > 0.0 ? u / ru : vec2(0.0)) * max(ru - push, 0.0);
|
|
1432
|
+
vec2 ng = floor(guess / h);
|
|
1433
|
+
for (int j = -1; j <= 1; j++) {
|
|
1434
|
+
for (int i = -1; i <= 1; i++) {
|
|
1435
|
+
vec2 n = ng + vec2(float(i), float(j));
|
|
1436
|
+
if (groupOf(n, h, c, maxR) != g) continue;
|
|
1437
|
+
vec2 home = (n + 0.5) * h;
|
|
1438
|
+
vec2 rel = home - c;
|
|
1439
|
+
float rr = length(rel);
|
|
1440
|
+
vec2 dir = rr > 0.0 ? rel / rr : vec2(0.0);
|
|
1441
|
+
vec2 pos = c + rot * (dir * (rr + push));
|
|
1442
|
+
float tumble = angle + (hash(n + 17.0) - 0.5) * 3.0 * e * sign(spin);
|
|
1443
|
+
float ct = cos(tumble);
|
|
1444
|
+
float st = sin(tumble);
|
|
1445
|
+
vec2 d = ((p - pos) * mat2(ct, st, -st, ct)) / max(size, 1e-4);
|
|
1446
|
+
float edge = 0.5 * h - max(abs(d.x), abs(d.y));
|
|
1447
|
+
float cov = clamp(edge * size / (2.0 * AA) + 0.5, 0.0, 1.0);
|
|
1448
|
+
vec2 src = home + d;
|
|
1449
|
+
if (cov <= 0.0 || src.x < 0.0 || src.y < 0.0 || src.x > ratio || src.y > 1.0) continue;
|
|
1450
|
+
vec4 piece = premultiplied(getFromColor(src / aspect)) * cov;
|
|
1451
|
+
col = piece + col * (1.0 - piece.a);
|
|
1452
|
+
}
|
|
1453
|
+
}
|
|
1454
|
+
}
|
|
1455
|
+
return col.a > 0.0 ? vec4(col.rgb / col.a, col.a) : vec4(0.0);
|
|
1456
|
+
}`,"warp-speed":`// Author: gre
|
|
1457
|
+
// License: MIT
|
|
1458
|
+
// Description: The camera jumps to light speed: star streaks shoot out from the center and stretch longer and longer while the outgoing image is pulled into a radial smear, then after a flash the incoming image emerges from the center as the streaks shrink back
|
|
1459
|
+
// Tags: zoom, radial, light, motion-blur, space
|
|
1460
|
+
|
|
1461
|
+
// @param Point the camera flies toward, from (0, 0) at the bottom left to (1, 1) at the top right
|
|
1462
|
+
const vec2 center = vec2(0.5, 0.5);
|
|
1463
|
+
// @range(20, 400) Number of star streaks around the center
|
|
1464
|
+
const float streaks = 160.0;
|
|
1465
|
+
// @color Color of the streaks and of the flash, added as light
|
|
1466
|
+
const vec4 streakColor = vec4(0.78, 0.88, 1.0, 1.0);
|
|
1467
|
+
// @range(0, 1) Length of the streaks and of the radial smear
|
|
1468
|
+
const float strength = 0.6;
|
|
1469
|
+
// @range(0, 1) Brightness of the flash at the peak of the jump
|
|
1470
|
+
const float flash = 0.5;
|
|
1471
|
+
|
|
1472
|
+
const float PI = 3.141592653589793;
|
|
1473
|
+
const int TAPS = 12;
|
|
1474
|
+
|
|
1475
|
+
float hash(vec2 p) {
|
|
1476
|
+
vec3 p3 = fract(vec3(p.xyx) * 0.1031);
|
|
1477
|
+
p3 += dot(p3, p3.yzx + 33.33);
|
|
1478
|
+
return fract((p3.x + p3.y) * p3.z);
|
|
1479
|
+
}
|
|
1480
|
+
|
|
1481
|
+
// one layer of stars: one per angular cell, flying outward and stretched along its ray
|
|
1482
|
+
float stars(float a, float r, float n, float layer, float travel, float speed, float reach) {
|
|
1483
|
+
float cell = floor(a * n);
|
|
1484
|
+
float h1 = hash(vec2(cell, layer));
|
|
1485
|
+
float h2 = hash(vec2(cell, layer + 17.0));
|
|
1486
|
+
float h3 = hash(vec2(cell, layer + 31.0));
|
|
1487
|
+
float life = fract(h1 + travel * (0.6 + 0.8 * h2));
|
|
1488
|
+
float head = reach * (0.05 + 1.05 * pow(life, 1.4));
|
|
1489
|
+
float tail = head * (1.0 - min(0.9, speed * (0.15 + 0.5 * h3)));
|
|
1490
|
+
float along = clamp((r - tail) / max(head - tail, 1e-4), 0.0, 1.0);
|
|
1491
|
+
float inside = step(tail, r) * (1.0 - smoothstep(head - 0.006, head, r));
|
|
1492
|
+
float profile = inside * along * along;
|
|
1493
|
+
// thin across the ray, a bit wider away from the center, with a faint halo,
|
|
1494
|
+
// faded out before the edges of the cell so that no seam shows between cells
|
|
1495
|
+
float f = fract(a * n);
|
|
1496
|
+
float cellWidth = 2.0 * PI * r / n;
|
|
1497
|
+
float offset = 0.3 + 0.4 * h3;
|
|
1498
|
+
float across = (f - offset) * cellWidth;
|
|
1499
|
+
float width = min(0.0014 + 0.002 * r / reach, 0.15 * cellWidth);
|
|
1500
|
+
float x = across * across / (width * width);
|
|
1501
|
+
float line = (exp(-x) + 0.25 * exp(-x / 9.0)) * smoothstep(0.0, 0.2, min(f, 1.0 - f));
|
|
1502
|
+
float fade = smoothstep(0.0, 0.2, life) * (1.0 - smoothstep(0.9, 1.0, life));
|
|
1503
|
+
return profile * line * fade * (0.4 + 0.6 * h2) * step(0.25, hash(vec2(cell, layer + 43.0)));
|
|
1504
|
+
}
|
|
1505
|
+
|
|
1506
|
+
// an image pulled into a radial smear toward the center: scaled by k, blurred over a fraction b
|
|
1507
|
+
vec4 smear(vec2 uv, float k, float b, float jitter, bool incoming) {
|
|
1508
|
+
if (b <= 0.0 && k >= 1.0) {
|
|
1509
|
+
vec4 c = incoming ? getToColor(uv) : getFromColor(uv);
|
|
1510
|
+
return vec4(c.rgb * c.a, c.a);
|
|
1511
|
+
}
|
|
1512
|
+
vec4 sum = vec4(0.0);
|
|
1513
|
+
for (int i = 0; i < TAPS; i++) {
|
|
1514
|
+
float s = k * (1.0 - b * (float(i) + jitter) / float(TAPS));
|
|
1515
|
+
vec2 q = center + (uv - center) * s;
|
|
1516
|
+
vec4 c = incoming ? getToColor(q) : getFromColor(q);
|
|
1517
|
+
sum += vec4(c.rgb * c.a, c.a);
|
|
1518
|
+
}
|
|
1519
|
+
return sum / float(TAPS);
|
|
1520
|
+
}
|
|
1521
|
+
|
|
1522
|
+
vec4 transition(vec2 uv) {
|
|
1523
|
+
float p = progress;
|
|
1524
|
+
vec2 aspect = vec2(ratio, 1.0);
|
|
1525
|
+
vec2 d = (uv - center) * aspect;
|
|
1526
|
+
float r = length(d);
|
|
1527
|
+
// (nudged off zero, where atan is undefined)
|
|
1528
|
+
float a = atan(d.y, d.x + 1e-6) / (2.0 * PI) + 0.5;
|
|
1529
|
+
vec2 far = max(center, 1.0 - center) * aspect;
|
|
1530
|
+
float reach = length(far);
|
|
1531
|
+
|
|
1532
|
+
float speed = sin(PI * p);
|
|
1533
|
+
speed *= speed;
|
|
1534
|
+
float travel = 3.0 * (p - sin(2.0 * PI * p) / (2.0 * PI));
|
|
1535
|
+
float jitter = hash(floor(uv * aspect * 997.0));
|
|
1536
|
+
|
|
1537
|
+
float goOut = smoothstep(0.0, 0.55, p);
|
|
1538
|
+
float goIn = 1.0 - smoothstep(0.45, 1.0, p);
|
|
1539
|
+
float soft = 0.35 * reach;
|
|
1540
|
+
float edge = mix(-soft, reach + soft, smoothstep(0.42, 0.78, p));
|
|
1541
|
+
float m = 1.0 - smoothstep(edge - soft, edge, r);
|
|
1542
|
+
vec4 before = vec4(0.0);
|
|
1543
|
+
vec4 after = vec4(0.0);
|
|
1544
|
+
if (m < 1.0) before = smear(uv, 1.0 - 0.3 * strength * goOut * goOut, 0.6 * strength * goOut, jitter, false);
|
|
1545
|
+
if (m > 0.0) after = smear(uv, 1.0 - 0.3 * strength * goIn * goIn, 0.6 * strength * goIn, jitter, true);
|
|
1546
|
+
vec4 c = mix(before, after, m);
|
|
1547
|
+
float dark = p < 0.5 ? speed : speed * speed * speed;
|
|
1548
|
+
c.rgb *= 1.0 - 0.65 * (0.5 + 0.5 * strength) * dark;
|
|
1549
|
+
|
|
1550
|
+
float n = max(floor(streaks), 1.0);
|
|
1551
|
+
float len = speed * (0.5 + 1.5 * strength);
|
|
1552
|
+
float s = stars(a, r, n, 1.0, travel, len, reach);
|
|
1553
|
+
s += stars(fract(a + 0.37), r, max(floor(n * 0.71), 1.0), 2.0, travel * 1.3, len, reach);
|
|
1554
|
+
float core = r / (0.35 * reach);
|
|
1555
|
+
float peak = (p - 0.5) * 9.0;
|
|
1556
|
+
float glow = flash * exp(-peak * peak) * speed * (0.35 + 0.9 * exp(-core * core));
|
|
1557
|
+
vec3 light = streakColor.rgb * streakColor.a * (2.2 * s * speed + glow);
|
|
1558
|
+
// light is added to the image, but adds no opacity
|
|
1559
|
+
return c.a > 0.0 ? vec4(clamp(c.rgb / c.a + light, 0.0, 1.0), c.a) : vec4(0.0);
|
|
1560
|
+
}`,"gravity-lens":`// Author: gre
|
|
1561
|
+
// License: MIT
|
|
1562
|
+
// Description: A black disk appears and grows, bending the outgoing image around it like a heavy mass bends light: the image is stretched into a bright ring at the disk's edge and swallowed until the frame is black, then the disk shrinks back, unbending the incoming image
|
|
1563
|
+
// Tags: distort, lens, space, circular, dark
|
|
1564
|
+
|
|
1565
|
+
// Center of the disk
|
|
1566
|
+
const vec2 center = vec2(0.5, 0.5);
|
|
1567
|
+
// @range(0, 1.5) How strongly the light bends: radius of the lensed ring beyond the disk's edge, in disk radii
|
|
1568
|
+
const float strength = 0.6;
|
|
1569
|
+
// @range(0, 1) Brightness of the lensed ring and of the thin ring of light hugging the disk's edge
|
|
1570
|
+
const float glow = 0.6;
|
|
1571
|
+
// @color Color of the disk
|
|
1572
|
+
const vec4 hole = vec4(0.0, 0.0, 0.0, 1.0);
|
|
1573
|
+
|
|
1574
|
+
// how far past the farthest corner the disk grows, so the frame is fully covered for a brief moment
|
|
1575
|
+
const float OVERSHOOT = 0.12;
|
|
1576
|
+
// moment the frame is black: the swallow takes a little longer than the release
|
|
1577
|
+
const float PEAK = 0.55;
|
|
1578
|
+
const float AA = 0.002;
|
|
1579
|
+
const vec3 WARM = vec3(1.0, 0.86, 0.68);
|
|
1580
|
+
|
|
1581
|
+
// fold the coordinates back into the frame, so the image stays filled without smearing its border
|
|
1582
|
+
vec2 mirrored(vec2 v) {
|
|
1583
|
+
vec2 m = mod(v, 2.0);
|
|
1584
|
+
return mix(m, 2.0 - m, step(1.0, m));
|
|
1585
|
+
}
|
|
1586
|
+
|
|
1587
|
+
vec4 transition(vec2 uv) {
|
|
1588
|
+
// the disk grows with an accelerating swallow, then shrinks back a little faster: exactly 0 at both ends
|
|
1589
|
+
bool swallowing = progress < PEAK;
|
|
1590
|
+
float u = swallowing ? progress / PEAK : (1.0 - progress) / (1.0 - PEAK);
|
|
1591
|
+
float u2 = u * u;
|
|
1592
|
+
float k = u2 * (0.6 + 0.4 * u2);
|
|
1593
|
+
|
|
1594
|
+
vec2 aspect = vec2(ratio, 1.0);
|
|
1595
|
+
vec2 far = max(center, 1.0 - center) * aspect;
|
|
1596
|
+
float rh = length(far) * (1.0 + OVERSHOOT) * k;
|
|
1597
|
+
// radius where the light coming from right behind the disk shows up as a ring
|
|
1598
|
+
float re = rh * (1.0 + max(strength, 0.0));
|
|
1599
|
+
|
|
1600
|
+
vec2 d = (uv - center) * aspect;
|
|
1601
|
+
float r = max(length(d), 1e-5);
|
|
1602
|
+
// a point mass deflects the light by an angle falling off as 1/r
|
|
1603
|
+
vec2 q = mirrored(center + d * (1.0 - re * re / (r * r)) / aspect);
|
|
1604
|
+
vec4 c = swallowing ? getFromColor(q) : getToColor(q);
|
|
1605
|
+
// the shading fades in with the disk, so it is exactly 0 at both ends
|
|
1606
|
+
float amount = smoothstep(0.0, 0.04, rh);
|
|
1607
|
+
float inner = clamp((r - rh) / (re - rh + 1e-4), 0.0, 1.0);
|
|
1608
|
+
c.rgb *= 1.0 - 0.7 * amount * (1.0 - inner * inner * (3.0 - 2.0 * inner));
|
|
1609
|
+
|
|
1610
|
+
float g = max(glow, 0.0) * amount;
|
|
1611
|
+
float einstein = (r - re) / (0.3 * (re - rh) + 0.01);
|
|
1612
|
+
float photon = max(r - rh, 0.0) / (0.006 + 0.012 * rh);
|
|
1613
|
+
float light = g * (0.7 * exp(-einstein * einstein) + 1.6 * exp(-photon * photon));
|
|
1614
|
+
c.rgb = min(c.rgb * (1.0 + light) + WARM * (0.35 * light * c.a), vec3(1.0));
|
|
1615
|
+
|
|
1616
|
+
// antialiased horizon, kept inside the disk so it vanishes with it
|
|
1617
|
+
float cov = clamp((rh - r) / (2.0 * AA), 0.0, 1.0);
|
|
1618
|
+
return mix(c, hole, cov);
|
|
1619
|
+
}`,fisheye:`// Author: gre
|
|
1620
|
+
// License: MIT
|
|
1621
|
+
// Description: The outgoing image bulges toward the viewer through a strong fisheye lens, then the incoming one flattens back into place
|
|
1622
|
+
// Tags: lens, distort, zoom, blend
|
|
1623
|
+
|
|
1624
|
+
// @range(0, 1) Strength of the lens at its peak
|
|
1625
|
+
const float strength = 0.8;
|
|
1626
|
+
|
|
1627
|
+
vec4 transition(vec2 uv) {
|
|
1628
|
+
// lens amount: grows, peaks in the middle, then relaxes, eased so that
|
|
1629
|
+
// the magnification of the center (1 / (1 - k)) changes at an even pace
|
|
1630
|
+
float h = smoothstep(0.0, 1.0, 1.0 - abs(2.0 * progress - 1.0));
|
|
1631
|
+
float k = 1.0 - pow(max(1.0 - strength, 0.01), h);
|
|
1632
|
+
// round lens: aspect-corrected coordinates, 1.0 at the corners
|
|
1633
|
+
vec2 aspect = vec2(ratio, 1.0);
|
|
1634
|
+
vec2 c = (uv - 0.5) * aspect;
|
|
1635
|
+
float r = length(c) / length(0.5 * aspect);
|
|
1636
|
+
// barrel mapping that keeps the corners in place: the center is magnified,
|
|
1637
|
+
// the edges squeezed, and every sample stays inside the image
|
|
1638
|
+
vec2 q = 0.5 + (uv - 0.5) * (1.0 - k + k * r * r);
|
|
1639
|
+
return mix(getFromColor(q), getToColor(q), smoothstep(0.38, 0.62, progress));
|
|
1640
|
+
}`,"film-burn":`// Author: Anastasia Dunbar
|
|
1641
|
+
// License: MIT
|
|
1642
|
+
// Description: Glowing film-burn light leaks wash over the image and reveal the incoming one
|
|
1643
|
+
// Tags: burn, film, light-leak
|
|
1644
|
+
// @param Random seed
|
|
1645
|
+
const float Seed = 2.31;
|
|
1646
|
+
float sigmoid(float x, float a) {
|
|
1647
|
+
float b = pow(x*2.,a)/2.;
|
|
1648
|
+
if (x > .5) {
|
|
1649
|
+
b = 1.-pow(2.-(x*2.),a)/2.;
|
|
1650
|
+
}
|
|
1651
|
+
return b;
|
|
1652
|
+
}
|
|
1653
|
+
float rand(float co){
|
|
1654
|
+
return fract(sin((co*24.9898)+Seed)*43758.5453);
|
|
1655
|
+
}
|
|
1656
|
+
float rand(vec2 co){
|
|
1657
|
+
return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453);
|
|
1658
|
+
}
|
|
1659
|
+
float apow(float a,float b) { return pow(abs(a),b)*sign(b); }
|
|
1660
|
+
vec3 pow3(vec3 a,vec3 b) { return vec3(apow(a.r,b.r),apow(a.g,b.g),apow(a.b,b.b)); }
|
|
1661
|
+
float smooth_mix(float a,float b,float c) { return mix(a,b,sigmoid(c,2.)); }
|
|
1662
|
+
float random(vec2 co, float shft){
|
|
1663
|
+
co += 10.;
|
|
1664
|
+
return smooth_mix(fract(sin(dot(co.xy ,vec2(12.9898+(floor(shft)*.5),78.233+Seed))) * 43758.5453),fract(sin(dot(co.xy ,vec2(12.9898+(floor(shft+1.)*.5),78.233+Seed))) * 43758.5453),fract(shft));
|
|
1665
|
+
}
|
|
1666
|
+
float smooth_random(vec2 co, float shft) {
|
|
1667
|
+
return smooth_mix(smooth_mix(random(floor(co),shft),random(floor(co+vec2(1.,0.)),shft),fract(co.x)),smooth_mix(random(floor(co+vec2(0.,1.)),shft),random(floor(co+vec2(1.,1.)),shft),fract(co.x)),fract(co.y));
|
|
1668
|
+
}
|
|
1669
|
+
vec4 blendedColor(vec2 p) {
|
|
1670
|
+
return mix(getFromColor(p), getToColor(p), sigmoid(progress,10.));
|
|
1671
|
+
}
|
|
1672
|
+
#define pi 3.14159265358979323
|
|
1673
|
+
#define clamps(x) clamp(x,0.,1.)
|
|
1674
|
+
|
|
1675
|
+
vec4 transition(vec2 p) {
|
|
1676
|
+
vec3 f = vec3(0.);
|
|
1677
|
+
for (float i = 0.; i < 13.; i++) {
|
|
1678
|
+
f += sin(((p.x*rand(i)*6.)+(progress*8.))+rand(i+1.43))*sin(((p.y*rand(i+4.4)*6.)+(progress*6.))+rand(i+2.4));
|
|
1679
|
+
f += 1.-clamps(length(p-vec2(smooth_random(vec2(progress*1.3),i+1.),smooth_random(vec2(progress*.5),i+6.25)))*mix(20.,70.,rand(i)));
|
|
1680
|
+
}
|
|
1681
|
+
f += 4.;
|
|
1682
|
+
f /= 11.;
|
|
1683
|
+
f = pow3(f*vec3(1.,0.7,0.6),vec3(1.,2.-sin(progress*pi),1.3));
|
|
1684
|
+
f *= sin(progress*pi);
|
|
1685
|
+
|
|
1686
|
+
p -= .5;
|
|
1687
|
+
p *= 1.+(smooth_random(vec2(progress*5.),6.3)*sin(progress*pi)*.05);
|
|
1688
|
+
p += .5;
|
|
1689
|
+
|
|
1690
|
+
vec4 blurred_image = vec4(0.);
|
|
1691
|
+
float bluramount = sin(progress*pi)*.03;
|
|
1692
|
+
#define repeats 50.
|
|
1693
|
+
for (float i = 0.; i < repeats; i++) {
|
|
1694
|
+
vec2 q = vec2(cos(degrees((i/repeats)*360.)),sin(degrees((i/repeats)*360.))) * (rand(vec2(i,p.x+p.y))+bluramount);
|
|
1695
|
+
vec2 uv2 = p+(q*bluramount);
|
|
1696
|
+
blurred_image += blendedColor(uv2);
|
|
1697
|
+
}
|
|
1698
|
+
blurred_image /= repeats;
|
|
1699
|
+
|
|
1700
|
+
return blurred_image+vec4(f,0.);
|
|
1701
|
+
}`,"film-strip":`// Author: gre
|
|
1702
|
+
// License: MIT
|
|
1703
|
+
// Description: The picture slips like film in a projector gate: it shrinks to show the sprocket holes, the strip runs down with motion blur and a slight weave, then the incoming frame lands in place
|
|
1704
|
+
// Tags: retro, vertical, motion-blur, film
|
|
1705
|
+
|
|
1706
|
+
// @range(1, 6, 1) Number of frames that slip by
|
|
1707
|
+
const int frames = 2;
|
|
1708
|
+
// @range(0, 0.4) How much the picture shrinks during the slip, showing the film's edges
|
|
1709
|
+
const float shrink = 0.2;
|
|
1710
|
+
// @range(0, 1) Length of the motion blur at full speed
|
|
1711
|
+
const float blur = 0.5;
|
|
1712
|
+
// @range(0, 1) Amount of horizontal weave and vertical jitter
|
|
1713
|
+
const float weave = 0.5;
|
|
1714
|
+
// @color Color of the film around the pictures and of the line between frames
|
|
1715
|
+
const vec4 filmColor = vec4(0.06, 0.05, 0.05, 1.0);
|
|
1716
|
+
// @color Color of the light through the sprocket holes
|
|
1717
|
+
const vec4 holeColor = vec4(0.96, 0.93, 0.85, 1.0);
|
|
1718
|
+
|
|
1719
|
+
const float FRAME_LINE = 0.08;
|
|
1720
|
+
const float HOLES = 4.0;
|
|
1721
|
+
const int SAMPLES = 16;
|
|
1722
|
+
|
|
1723
|
+
float dither(vec2 cell) {
|
|
1724
|
+
return fract(52.9829189 * fract(dot(cell, vec2(0.06711056, 0.00583715))));
|
|
1725
|
+
}
|
|
1726
|
+
|
|
1727
|
+
// the film at (x, y): x across it (0 to 1 over the picture), y along it from the start of frame
|
|
1728
|
+
// number base, in frame heights; holes fades the sprocket holes in
|
|
1729
|
+
vec4 film(float x, float y, float base, float n, float aa, float holeX, vec2 holeSize, float holes) {
|
|
1730
|
+
float pitch = 1.0 + FRAME_LINE;
|
|
1731
|
+
float jy = floor(y / pitch);
|
|
1732
|
+
float j = base + jy;
|
|
1733
|
+
float fy = y - jy * pitch;
|
|
1734
|
+
vec4 c = filmColor;
|
|
1735
|
+
if (x >= 0.0 && x <= 1.0 && fy <= 1.0) {
|
|
1736
|
+
vec2 q = vec2(x, fy);
|
|
1737
|
+
c = j < n ? getFromColor(q) : getToColor(q);
|
|
1738
|
+
}
|
|
1739
|
+
// soft edges for the picture during the slip (none at rest, where it fills the frame)
|
|
1740
|
+
float inside = min(min(x, 1.0 - x) * ratio, min(fy, 1.0 - fy));
|
|
1741
|
+
c = mix(filmColor, c, clamp(inside / aa + 0.5, 0.0, 1.0));
|
|
1742
|
+
float hy = mod(y, pitch / HOLES) - 0.5 * pitch / HOLES;
|
|
1743
|
+
float hx = (abs(x - 0.5) - holeX) * ratio;
|
|
1744
|
+
vec2 dd = abs(vec2(hx, hy)) - holeSize + 0.3 * holeSize.x;
|
|
1745
|
+
float sd = length(max(dd, 0.0)) + min(max(dd.x, dd.y), 0.0) - 0.3 * holeSize.x;
|
|
1746
|
+
return mix(c, holeColor, clamp(0.5 - sd / aa, 0.0, 1.0) * holes);
|
|
1747
|
+
}
|
|
1748
|
+
|
|
1749
|
+
vec4 transition(vec2 uv) {
|
|
1750
|
+
float n = max(float(frames), 1.0);
|
|
1751
|
+
float pitch = 1.0 + FRAME_LINE;
|
|
1752
|
+
float p = progress;
|
|
1753
|
+
float env = smoothstep(0.0, 0.3, p) * (1.0 - smoothstep(0.7, 1.0, p));
|
|
1754
|
+
float k = 1.0 - shrink * env;
|
|
1755
|
+
float x0 = clamp((p - 0.15) / 0.7, 0.0, 1.0);
|
|
1756
|
+
float slip = x0 * x0 * x0 * (x0 * (x0 * 6.0 - 15.0) + 10.0);
|
|
1757
|
+
float speed = 30.0 * x0 * x0 * (1.0 - x0) * (1.0 - x0) / 0.7; // d(slip)/d(progress), up to ~2.7
|
|
1758
|
+
float wob = weave * env;
|
|
1759
|
+
// (the weave stays within the film's margin)
|
|
1760
|
+
float dx = wob * smoothstep(0.0, 0.1, shrink) * (0.006 * sin(p * 47.0) + 0.004 * sin(p * 113.0 + 1.3));
|
|
1761
|
+
float dy = wob * 0.012 * sin(p * 71.0 + 0.4) * (1.0 - speed / 2.7);
|
|
1762
|
+
|
|
1763
|
+
float frameSlip = slip * n;
|
|
1764
|
+
float base = floor(frameSlip);
|
|
1765
|
+
float x = (uv.x - 0.5) / k + 0.5 + dx;
|
|
1766
|
+
float y = (uv.y - 0.5) / k + 0.5 + dy + (frameSlip - base) * pitch;
|
|
1767
|
+
// anti-aliasing width, in frame heights: none at rest or without margin
|
|
1768
|
+
float aa = 0.002 * min(1.0, 10.0 * env) * min(1.0, 20.0 * shrink) + 1e-4;
|
|
1769
|
+
float margin = 0.5 * shrink / max(1.0 - shrink, 0.01);
|
|
1770
|
+
float holeX = 0.5 + 0.5 * margin;
|
|
1771
|
+
vec2 holeSize = vec2(0.28 * margin * ratio, 0.11 * pitch / HOLES);
|
|
1772
|
+
float holes = smoothstep(0.0, 0.02, margin);
|
|
1773
|
+
|
|
1774
|
+
// motion blur along the strip, dithered to hide the steps
|
|
1775
|
+
float len = blur * 0.06 * speed * n;
|
|
1776
|
+
vec4 color = vec4(0.0);
|
|
1777
|
+
if (len < 1e-5) {
|
|
1778
|
+
color = film(x, y, base, n, aa, holeX, holeSize, holes);
|
|
1779
|
+
} else {
|
|
1780
|
+
// averaged with premultiplied colors, so transparent parts don't darken the others
|
|
1781
|
+
float jitter = dither(floor(uv * vec2(ratio, 1.0) * 540.0));
|
|
1782
|
+
for (int i = 0; i < SAMPLES; i++) {
|
|
1783
|
+
float t = (float(i) + jitter) / float(SAMPLES) - 0.5;
|
|
1784
|
+
vec4 c = film(x, y + t * len, base, n, aa, holeX, holeSize, holes);
|
|
1785
|
+
color += vec4(c.rgb * c.a, c.a);
|
|
1786
|
+
}
|
|
1787
|
+
color /= float(SAMPLES);
|
|
1788
|
+
color.rgb = color.a > 0.0 ? color.rgb / color.a : vec3(0.0);
|
|
1789
|
+
}
|
|
1790
|
+
color.rgb *= 1.0 - 0.08 * wob * (0.5 + 0.5 * sin(p * 157.0));
|
|
1791
|
+
return color;
|
|
1792
|
+
}`,"glitch-memories":`// Author: Gunnar Roth
|
|
1793
|
+
// based on work from natewave
|
|
1794
|
+
// License: MIT
|
|
1795
|
+
// Description: A crossfade with glitchy, color-shifted blocks
|
|
1796
|
+
// Tags: glitch, chromatic, blend
|
|
1797
|
+
vec4 transition(vec2 p) {
|
|
1798
|
+
vec2 block = floor(p.xy / vec2(16));
|
|
1799
|
+
vec2 uv_noise = block / vec2(64);
|
|
1800
|
+
uv_noise += floor(vec2(progress) * vec2(1200.0, 3500.0)) / vec2(64);
|
|
1801
|
+
vec2 dist = (fract(uv_noise) - 0.5) * 0.3 * (1.0 - progress) * smoothstep(0.0, 0.05, progress);
|
|
1802
|
+
vec2 red = p + dist * 0.2;
|
|
1803
|
+
vec2 green = p + dist * .3;
|
|
1804
|
+
vec2 blue = p + dist * .5;
|
|
1805
|
+
|
|
1806
|
+
vec4 center = mix(getFromColor(green), getToColor(green), progress);
|
|
1807
|
+
return vec4(mix(getFromColor(red), getToColor(red), progress).r, center.g, mix(getFromColor(blue), getToColor(blue), progress).b, center.a);
|
|
1808
|
+
}`,datamosh:`// Author: bread
|
|
1809
|
+
// License: MIT
|
|
1810
|
+
// Description: A datamosh glitch: torn strips, chroma shifts and scan noise drag the outgoing image into the incoming one
|
|
1811
|
+
// Tags: glitch, datamosh, chromatic
|
|
1812
|
+
|
|
1813
|
+
const float strength = 1.0;
|
|
1814
|
+
const float horizontalBars = 42.0;
|
|
1815
|
+
const float verticalSlits = 18.0;
|
|
1816
|
+
const float tear = 0.18;
|
|
1817
|
+
const float chroma = 0.032;
|
|
1818
|
+
const float residue = 0.62;
|
|
1819
|
+
const float noiseAmount = 0.16;
|
|
1820
|
+
const float scanAmount = 0.13;
|
|
1821
|
+
const float flashAmount = 0.20;
|
|
1822
|
+
|
|
1823
|
+
const float PI = 3.141592653589793;
|
|
1824
|
+
|
|
1825
|
+
float hash(float n) {
|
|
1826
|
+
return fract(sin(n) * 43758.5453123);
|
|
1827
|
+
}
|
|
1828
|
+
|
|
1829
|
+
float hash(vec2 p) {
|
|
1830
|
+
return fract(sin(dot(p, vec2(127.1, 311.7))) * 43758.5453123);
|
|
1831
|
+
}
|
|
1832
|
+
|
|
1833
|
+
float sat(float v) {
|
|
1834
|
+
return clamp(v, 0.0, 1.0);
|
|
1835
|
+
}
|
|
1836
|
+
|
|
1837
|
+
float burst() {
|
|
1838
|
+
return pow(max(0.0, sin(progress * PI)), 0.42) * strength;
|
|
1839
|
+
}
|
|
1840
|
+
|
|
1841
|
+
vec2 safeUv(vec2 uv) {
|
|
1842
|
+
return clamp(uv, vec2(0.0), vec2(1.0));
|
|
1843
|
+
}
|
|
1844
|
+
|
|
1845
|
+
float stripeY(vec2 uv, float density, float seed, float minWidth, float maxWidth) {
|
|
1846
|
+
float y = uv.y * density + seed * 0.137;
|
|
1847
|
+
float id = floor(y);
|
|
1848
|
+
float f = fract(y);
|
|
1849
|
+
float c = hash(vec2(id, seed));
|
|
1850
|
+
float w = mix(minWidth, maxWidth, hash(vec2(id + 9.17, seed + 2.31)));
|
|
1851
|
+
return 1.0 - smoothstep(w, w + 0.018, abs(f - c));
|
|
1852
|
+
}
|
|
1853
|
+
|
|
1854
|
+
float stripeX(vec2 uv, float density, float seed, float minWidth, float maxWidth) {
|
|
1855
|
+
float x = uv.x * density + seed * 0.091;
|
|
1856
|
+
float id = floor(x);
|
|
1857
|
+
float f = fract(x);
|
|
1858
|
+
float c = hash(vec2(id, seed + 41.0));
|
|
1859
|
+
float w = mix(minWidth, maxWidth, hash(vec2(id + 4.7, seed + 8.9)));
|
|
1860
|
+
return 1.0 - smoothstep(w, w + 0.012, abs(f - c));
|
|
1861
|
+
}
|
|
1862
|
+
|
|
1863
|
+
float brokenGate(vec2 uv, float row, float rnd, float frame) {
|
|
1864
|
+
float segs = mix(1.0, 9.0, hash(vec2(row, frame + 44.0)));
|
|
1865
|
+
float seg = floor(uv.x * segs);
|
|
1866
|
+
return step(0.16, hash(vec2(seg, row + frame * 3.0 + rnd)));
|
|
1867
|
+
}
|
|
1868
|
+
|
|
1869
|
+
float horizontalMask(vec2 uv, float frame) {
|
|
1870
|
+
float r1 = floor((uv.y + hash(frame) * 0.031) * horizontalBars * 0.38);
|
|
1871
|
+
float r2 = floor((uv.y + hash(frame + 2.0) * 0.013) * horizontalBars);
|
|
1872
|
+
float r3 = floor((uv.y + hash(frame + 7.0) * 0.006) * horizontalBars * 3.4);
|
|
1873
|
+
|
|
1874
|
+
float thick = stripeY(uv, horizontalBars * 0.38, frame + 1.0, 0.035, 0.22);
|
|
1875
|
+
float mid = stripeY(uv, horizontalBars, frame + 4.0, 0.014, 0.11);
|
|
1876
|
+
float hair = stripeY(uv, horizontalBars * 3.4, frame + 9.0, 0.004, 0.035);
|
|
1877
|
+
|
|
1878
|
+
thick *= step(0.42, hash(vec2(r1, frame + 10.0)));
|
|
1879
|
+
mid *= step(0.48, hash(vec2(r2, frame + 20.0)));
|
|
1880
|
+
hair *= step(0.62, hash(vec2(r3, frame + 30.0)));
|
|
1881
|
+
|
|
1882
|
+
thick *= brokenGate(uv, r1, hash(vec2(r1, frame)), frame);
|
|
1883
|
+
mid *= brokenGate(uv, r2, hash(vec2(r2, frame)), frame + 3.0);
|
|
1884
|
+
|
|
1885
|
+
return sat(max(thick, max(mid, hair)));
|
|
1886
|
+
}
|
|
1887
|
+
|
|
1888
|
+
float verticalMask(vec2 uv, float frame) {
|
|
1889
|
+
float col = floor((uv.x + hash(frame + 12.0) * 0.017) * verticalSlits);
|
|
1890
|
+
float slit = stripeX(uv, verticalSlits, frame + 13.0, 0.01, 0.075);
|
|
1891
|
+
slit *= step(0.66, hash(vec2(col, frame + 19.0)));
|
|
1892
|
+
return sat(slit);
|
|
1893
|
+
}
|
|
1894
|
+
|
|
1895
|
+
vec4 chromaFrom(vec2 uv, vec2 s) {
|
|
1896
|
+
uv = safeUv(uv);
|
|
1897
|
+
vec4 center = getFromColor(uv);
|
|
1898
|
+
return vec4(
|
|
1899
|
+
getFromColor(safeUv(uv + s)).r,
|
|
1900
|
+
center.g,
|
|
1901
|
+
getFromColor(safeUv(uv - s)).b,
|
|
1902
|
+
center.a
|
|
1903
|
+
);
|
|
1904
|
+
}
|
|
1905
|
+
|
|
1906
|
+
vec4 chromaTo(vec2 uv, vec2 s) {
|
|
1907
|
+
uv = safeUv(uv);
|
|
1908
|
+
vec4 center = getToColor(uv);
|
|
1909
|
+
return vec4(
|
|
1910
|
+
getToColor(safeUv(uv - s)).r,
|
|
1911
|
+
center.g,
|
|
1912
|
+
getToColor(safeUv(uv + s)).b,
|
|
1913
|
+
center.a
|
|
1914
|
+
);
|
|
1915
|
+
}
|
|
1916
|
+
|
|
1917
|
+
vec2 distortUv(vec2 uv, float dir, float b, float h, float v, float frame) {
|
|
1918
|
+
float row = floor(uv.y * horizontalBars);
|
|
1919
|
+
float col = floor(uv.x * verticalSlits);
|
|
1920
|
+
|
|
1921
|
+
float rowRnd = hash(vec2(row, frame));
|
|
1922
|
+
float colRnd = hash(vec2(col, frame + 27.0));
|
|
1923
|
+
|
|
1924
|
+
float xTear = (rowRnd - 0.5) * 2.0 * tear * b * h;
|
|
1925
|
+
xTear += sin(uv.y * 120.0 + progress * 95.0) * 0.006 * b;
|
|
1926
|
+
|
|
1927
|
+
float yDrag = (colRnd - 0.5) * 0.13 * b * v;
|
|
1928
|
+
float micro = (hash(vec2(row, col + frame)) - 0.5) * 0.018 * b * max(h, v);
|
|
1929
|
+
|
|
1930
|
+
return uv + vec2(xTear * dir + micro, yDrag);
|
|
1931
|
+
}
|
|
1932
|
+
|
|
1933
|
+
vec4 transition(vec2 uv) {
|
|
1934
|
+
float b = burst();
|
|
1935
|
+
float frame = floor(progress * 30.0);
|
|
1936
|
+
|
|
1937
|
+
float h = horizontalMask(uv, frame);
|
|
1938
|
+
float v = verticalMask(uv, frame);
|
|
1939
|
+
float glitch = sat(max(h, v * 0.75));
|
|
1940
|
+
|
|
1941
|
+
float row = floor(uv.y * horizontalBars);
|
|
1942
|
+
float rowRnd = hash(vec2(row, frame + 5.0));
|
|
1943
|
+
|
|
1944
|
+
float bandDelay = (rowRnd - 0.5) * 0.30 * h;
|
|
1945
|
+
float reveal = smoothstep(0.18, 0.84, progress + bandDelay);
|
|
1946
|
+
|
|
1947
|
+
vec2 split = vec2(chroma * b * (1.0 + 1.7 * glitch), chroma * 0.22 * b * v);
|
|
1948
|
+
|
|
1949
|
+
vec2 fromUv = distortUv(uv, 1.0, b, h, v, frame);
|
|
1950
|
+
vec2 toUv = distortUv(uv, -1.0, b, h, v, frame);
|
|
1951
|
+
|
|
1952
|
+
vec4 color = mix(
|
|
1953
|
+
chromaFrom(fromUv, split),
|
|
1954
|
+
chromaTo(toUv, split),
|
|
1955
|
+
reveal
|
|
1956
|
+
);
|
|
1957
|
+
|
|
1958
|
+
vec2 smearUv = uv;
|
|
1959
|
+
smearUv.x += (rowRnd - 0.5) * 0.46 * b * h;
|
|
1960
|
+
smearUv.y += (hash(vec2(row, frame + 31.0)) - 0.5) * 0.045 * b * h;
|
|
1961
|
+
|
|
1962
|
+
float sliceReveal = smoothstep(0.28, 0.78, progress + (rowRnd - 0.5) * 0.22);
|
|
1963
|
+
vec4 sliceColor = mix(
|
|
1964
|
+
chromaFrom(smearUv, split * 1.65),
|
|
1965
|
+
chromaTo(smearUv - vec2((rowRnd - 0.5) * 0.18 * b, 0.0), split * 1.65),
|
|
1966
|
+
sliceReveal
|
|
1967
|
+
);
|
|
1968
|
+
|
|
1969
|
+
color = mix(color, sliceColor, h * b * residue);
|
|
1970
|
+
|
|
1971
|
+
float hairLine = stripeY(uv, 190.0, frame + 55.0, 0.002, 0.012);
|
|
1972
|
+
hairLine *= step(0.70, hash(vec2(floor(uv.y * 190.0), frame + 56.0)));
|
|
1973
|
+
color.rgb += vec3(0.72, 0.90, 1.0) * hairLine * b * 0.28;
|
|
1974
|
+
|
|
1975
|
+
float scan = 0.5 + 0.5 * sin(uv.y * 980.0 + progress * 130.0);
|
|
1976
|
+
color.rgb *= 1.0 - scanAmount * b * scan;
|
|
1977
|
+
|
|
1978
|
+
vec2 nCell = floor(uv * vec2(360.0 * ratio, 210.0));
|
|
1979
|
+
float n = hash(nCell + vec2(frame * 7.0, frame * 13.0));
|
|
1980
|
+
color.rgb += (n - 0.5) * noiseAmount * b * (0.55 + glitch);
|
|
1981
|
+
|
|
1982
|
+
float luma = dot(color.rgb, vec3(0.299, 0.587, 0.114));
|
|
1983
|
+
color.rgb = mix(color.rgb, vec3(luma), 0.18 * b * glitch);
|
|
1984
|
+
|
|
1985
|
+
float strobe = step(0.78, hash(vec2(frame, 3.14))) * pow(b, 1.65);
|
|
1986
|
+
color.rgb += vec3(strobe * flashAmount);
|
|
1987
|
+
|
|
1988
|
+
return vec4(clamp(color.rgb, vec3(0.0), vec3(1.0)), color.a);
|
|
1989
|
+
}`,"vhs-tracking":`// Author: gre
|
|
1990
|
+
// License: MIT
|
|
1991
|
+
// Description: Tape-tracking bands of white snow roll down the frame, tearing the lines around them, with smeared color, wobbling lines, a jittering strip at the bottom and a dropout flash, as the incoming image is recorded over the outgoing one under the densest band
|
|
1992
|
+
// Tags: retro, glitch, noise, tape, scanlines
|
|
1993
|
+
|
|
1994
|
+
// @range(1, 4, 1) Number of noise bands rolling down (the first one carries the cut)
|
|
1995
|
+
const int bands = 3;
|
|
1996
|
+
// @range(0, 1) Amount of snow and tearing in the bands
|
|
1997
|
+
const float noise = 0.6;
|
|
1998
|
+
// @range(0, 1) How far the color smears to the right of the picture
|
|
1999
|
+
const float bleed = 0.5;
|
|
2000
|
+
// @range(0, 1) How much the lines wobble sideways
|
|
2001
|
+
const float wobble = 0.5;
|
|
2002
|
+
|
|
2003
|
+
const float LINES = 220.0; // tape lines over the frame height
|
|
2004
|
+
const float FRAMES = 40.0; // the noise changes this many times over the transition
|
|
2005
|
+
const float BAND = 0.11;
|
|
2006
|
+
const float STRIP = 0.06;
|
|
2007
|
+
const int TAPS = 6;
|
|
2008
|
+
|
|
2009
|
+
float hash12(vec2 v) {
|
|
2010
|
+
vec3 v3 = fract(vec3(v.xyx) * 0.1031);
|
|
2011
|
+
v3 += dot(v3, v3.yzx + 33.33);
|
|
2012
|
+
return fract((v3.x + v3.y) * v3.z);
|
|
2013
|
+
}
|
|
2014
|
+
|
|
2015
|
+
vec2 mirror(vec2 v) {
|
|
2016
|
+
return 1.0 - abs(1.0 - mod(v, 2.0));
|
|
2017
|
+
}
|
|
2018
|
+
|
|
2019
|
+
// the tape image on the outgoing (or, once re-recorded, incoming) side, premultiplied
|
|
2020
|
+
vec4 tape(vec2 p, bool fresh) {
|
|
2021
|
+
p = mirror(p);
|
|
2022
|
+
vec4 c = fresh ? getToColor(p) : getFromColor(p);
|
|
2023
|
+
return vec4(c.rgb * c.a, c.a);
|
|
2024
|
+
}
|
|
2025
|
+
|
|
2026
|
+
float luma(vec3 c) {
|
|
2027
|
+
return dot(c, vec3(0.299, 0.587, 0.114));
|
|
2028
|
+
}
|
|
2029
|
+
|
|
2030
|
+
// how dense a band centered at y = c of half height w is on line y, with ragged edges
|
|
2031
|
+
float bandDensity(float y, float c, float w, float jitter) {
|
|
2032
|
+
float d = abs(y - c) / w + 0.35 * jitter;
|
|
2033
|
+
return 1.0 - smoothstep(0.0, 1.0, d);
|
|
2034
|
+
}
|
|
2035
|
+
|
|
2036
|
+
vec4 transition(vec2 uv) {
|
|
2037
|
+
// the effects build up quickly and settle at the end: exactly 0 at both ends
|
|
2038
|
+
float h = clamp(2.5 * (1.0 - abs(2.0 * progress - 1.0)), 0.0, 1.0);
|
|
2039
|
+
float env = h * h * (3.0 - 2.0 * h);
|
|
2040
|
+
float f = clamp(1.0 - abs(progress - 0.5) / 0.04, 0.0, 1.0);
|
|
2041
|
+
float flash = f * f * (3.0 - 2.0 * f);
|
|
2042
|
+
|
|
2043
|
+
float frame = floor(progress * FRAMES);
|
|
2044
|
+
float line = floor(uv.y * LINES);
|
|
2045
|
+
float jitter = hash12(vec2(line, frame + 7.0)) - 0.5;
|
|
2046
|
+
|
|
2047
|
+
// the main band rolls from above the frame to below it; the incoming image is above it
|
|
2048
|
+
float c0 = mix(1.0 + 1.2 * BAND, -1.2 * BAND, progress);
|
|
2049
|
+
bool fresh = uv.y > c0 + 0.8 * BAND * jitter;
|
|
2050
|
+
float dens = bandDensity(uv.y, c0, BAND, jitter);
|
|
2051
|
+
float tear = 1.0 - smoothstep(0.0, 1.0, abs(uv.y - c0) / (2.5 * BAND));
|
|
2052
|
+
for (int i = 1; i < 4; i++) {
|
|
2053
|
+
if (i < bands) {
|
|
2054
|
+
float k = float(i);
|
|
2055
|
+
float w = BAND * (0.35 + 0.2 * hash12(vec2(k, 3.0)));
|
|
2056
|
+
float speed = 1.3 + 0.9 * k;
|
|
2057
|
+
float cy = -w + (1.0 + 2.0 * w) * fract(hash12(vec2(k, 5.0)) - speed * progress);
|
|
2058
|
+
dens = max(dens, 0.6 * bandDensity(uv.y, cy, w, jitter));
|
|
2059
|
+
tear = max(tear, 0.5 * (1.0 - smoothstep(0.0, 1.0, abs(uv.y - cy) / (2.5 * w))));
|
|
2060
|
+
}
|
|
2061
|
+
}
|
|
2062
|
+
dens *= env;
|
|
2063
|
+
tear *= env;
|
|
2064
|
+
|
|
2065
|
+
float rowTear = hash12(vec2(floor(uv.y * LINES * 0.5), frame + 31.0)) - 0.5;
|
|
2066
|
+
float dx = wobble * env * (0.006 * sin(uv.y * 7.0 + progress * 23.0) + 0.004 * jitter);
|
|
2067
|
+
dx += (0.3 + 0.7 * noise) * tear * 0.18 * rowTear;
|
|
2068
|
+
float strip = env * (1.0 - smoothstep(0.0, STRIP, uv.y));
|
|
2069
|
+
dx += strip * (0.03 + 0.06 * (1.0 - uv.y / STRIP)) * (0.6 + 0.8 * hash12(vec2(frame, 41.0)));
|
|
2070
|
+
vec2 q = vec2(uv.x + dx, uv.y);
|
|
2071
|
+
|
|
2072
|
+
vec4 c = tape(q, fresh);
|
|
2073
|
+
if (c.a <= 0.0) return vec4(0.0);
|
|
2074
|
+
float len = bleed * (0.02 + 0.05 * dens) * env;
|
|
2075
|
+
vec4 avg = c;
|
|
2076
|
+
if (len > 0.0) {
|
|
2077
|
+
avg = vec4(0.0);
|
|
2078
|
+
for (int i = 0; i < TAPS; i++) {
|
|
2079
|
+
float u = (float(i) + 0.5) / float(TAPS);
|
|
2080
|
+
avg += tape(q - vec2(len * (0.4 + u), 0.0), fresh);
|
|
2081
|
+
}
|
|
2082
|
+
avg /= float(TAPS);
|
|
2083
|
+
}
|
|
2084
|
+
vec3 chroma = (avg.rgb - luma(avg.rgb)) / max(avg.a, 1e-5);
|
|
2085
|
+
vec3 rgb = luma(c.rgb) + chroma * c.a; // premultiplied by c.a
|
|
2086
|
+
rgb = mix(rgb, vec3(luma(rgb)), 0.6 * dens);
|
|
2087
|
+
|
|
2088
|
+
// snow: short white streaks on the tape lines, starting at a random offset on each line so they never line up
|
|
2089
|
+
vec2 cell = vec2(floor(uv.x * LINES * 0.3 * ratio + 40.0 * jitter), line);
|
|
2090
|
+
float n = hash12(cell + frame * vec2(37.0, 17.0));
|
|
2091
|
+
float amount = clamp(noise * max(1.3 * dens, 0.8 * strip) + 0.35 * flash, 0.0, 1.0);
|
|
2092
|
+
float snow = amount > 0.0 ? smoothstep(1.0 - amount, 1.0 - 0.6 * amount, n) : 0.0;
|
|
2093
|
+
snow *= 0.55 + 0.45 * hash12(cell.yx + frame);
|
|
2094
|
+
float g = hash12(vec2(floor(uv.x * LINES * ratio), line) + frame * vec2(13.0, 29.0));
|
|
2095
|
+
snow = max(snow, amount > 0.0 ? 0.7 * smoothstep(1.0 - 0.4 * amount, 1.0, g) : 0.0);
|
|
2096
|
+
float dark = g < 0.1 * amount ? min(10.0 * amount, 1.0) : 0.0;
|
|
2097
|
+
float group = floor(uv.y * LINES / 3.0);
|
|
2098
|
+
float drop = step(1.0 - 0.15 * flash, hash12(vec2(group, floor(uv.x * 6.0 + 5.0 * hash12(vec2(group, frame))) + frame * 7.0)));
|
|
2099
|
+
rgb *= 1.0 - 0.5 * dark;
|
|
2100
|
+
snow *= min(10.0 * amount, 1.0);
|
|
2101
|
+
rgb += (clamp(snow + drop + 0.12 * flash, 0.0, 1.0)) * (c.a - rgb);
|
|
2102
|
+
|
|
2103
|
+
return vec4(clamp(rgb / c.a, 0.0, 1.0), c.a);
|
|
2104
|
+
}`,"tv-turn-off":`// Author: gre
|
|
2105
|
+
// License: MIT
|
|
2106
|
+
// Description: The outgoing image collapses into a glowing line and a dot, like an old TV turned off, then the incoming image powers on from the dot
|
|
2107
|
+
// Tags: retro, vertical, flash
|
|
2108
|
+
|
|
2109
|
+
// @color Color of the switched-off screen
|
|
2110
|
+
const vec4 color = vec4(0.0, 0.0, 0.0, 1.0);
|
|
2111
|
+
// @range(0, 2) Strength of the glow around the line and the dot
|
|
2112
|
+
const float glow = 1.0;
|
|
2113
|
+
|
|
2114
|
+
vec4 getColor(vec2 uv, bool isFrom) {
|
|
2115
|
+
return isFrom ? getFromColor(uv) : getToColor(uv);
|
|
2116
|
+
}
|
|
2117
|
+
|
|
2118
|
+
// The screen at a time t of its power-off: 0 is the full image, 1 is off
|
|
2119
|
+
vec4 screen(vec2 uv, float t, bool isFrom) {
|
|
2120
|
+
float collapse = smoothstep(0.0, 0.4, t); // the image squeezes into a line
|
|
2121
|
+
float shrink = smoothstep(0.3, 0.65, t); // the line shrinks into a dot
|
|
2122
|
+
float fade = 0.4 * smoothstep(0.75, 1.0, t); // the dot dims
|
|
2123
|
+
float radius = 0.01 * (1.0 - fade);
|
|
2124
|
+
// half size of the picture, in height units (x is scaled by ratio)
|
|
2125
|
+
vec2 size = vec2(mix(0.5 * ratio, radius, shrink), mix(0.5, radius, collapse));
|
|
2126
|
+
vec2 p = (uv - 0.5) * vec2(ratio, 1.0);
|
|
2127
|
+
vec2 q = clamp(0.5 + 0.5 * p / size, 0.0, 1.0);
|
|
2128
|
+
vec4 c = getColor(q, isFrom);
|
|
2129
|
+
float white = smoothstep(0.4, 1.0, collapse);
|
|
2130
|
+
vec4 light = vec4(mix(min(c.rgb * (1.0 + 2.0 * collapse), 1.0), vec3(1.0), white), c.a);
|
|
2131
|
+
// soft edges, outside the picture so that t = 0 is the exact image
|
|
2132
|
+
vec2 d = abs(p) - size;
|
|
2133
|
+
float dist = length(max(d, 0.0)) + min(max(d.x, d.y), 0.0);
|
|
2134
|
+
float inside = clamp(1.0 - dist / 0.004, 0.0, 1.0);
|
|
2135
|
+
vec4 mid = getColor(vec2(0.5), isFrom);
|
|
2136
|
+
vec4 halo = vec4(mix(mix(mid.rgb, vec3(1.0), 0.7), vec3(1.0, 0.92, 0.8), shrink), mid.a);
|
|
2137
|
+
float h = 1.0 - exp(-2.0 * glow * white * exp(-max(dist, 0.0) / (0.02 + 0.04 * shrink)));
|
|
2138
|
+
vec4 col = mix(color, halo, h * (1.0 - fade));
|
|
2139
|
+
return mix(col, light, inside * (1.0 - fade));
|
|
2140
|
+
}
|
|
2141
|
+
|
|
2142
|
+
vec4 transition(vec2 uv) {
|
|
2143
|
+
if (progress < 0.5) {
|
|
2144
|
+
return screen(uv, 2.0 * progress, true);
|
|
2145
|
+
}
|
|
2146
|
+
return screen(uv, 2.0 - 2.0 * progress, false);
|
|
2147
|
+
}`,"ink-bleed":`// Author: gre
|
|
2148
|
+
// License: MIT
|
|
2149
|
+
// Description: The incoming image spreads over the outgoing one like drops of ink in water, blooming from a few points with curling, wispy edges and a darker rim, until it fills the frame
|
|
2150
|
+
// Tags: ink, organic, fluid, noise
|
|
2151
|
+
|
|
2152
|
+
// @range(1, 8, 1) Number of ink drops
|
|
2153
|
+
const float drops = 4.0;
|
|
2154
|
+
// @range(0, 1) How far the curling tendrils reach out of the blooms
|
|
2155
|
+
const float tendrils = 0.7;
|
|
2156
|
+
// @range(0, 1) How dark the rim of ink at the front of the blooms is
|
|
2157
|
+
const float rim = 0.5;
|
|
2158
|
+
// @param Random seed for the drop positions and the swirls
|
|
2159
|
+
const float seed = 3.0;
|
|
2160
|
+
|
|
2161
|
+
float hash (vec2 p) {
|
|
2162
|
+
vec3 p3 = fract(vec3(p.xyx) * 0.1031);
|
|
2163
|
+
p3 += dot(p3, p3.yzx + 33.33);
|
|
2164
|
+
return fract((p3.x + p3.y) * p3.z);
|
|
2165
|
+
}
|
|
2166
|
+
|
|
2167
|
+
float vnoise (vec2 p) {
|
|
2168
|
+
vec2 i = floor(p);
|
|
2169
|
+
vec2 f = fract(p);
|
|
2170
|
+
f = f * f * (3.0 - 2.0 * f);
|
|
2171
|
+
return mix(
|
|
2172
|
+
mix(hash(i), hash(i + vec2(1.0, 0.0)), f.x),
|
|
2173
|
+
mix(hash(i + vec2(0.0, 1.0)), hash(i + vec2(1.0, 1.0)), f.x),
|
|
2174
|
+
f.y
|
|
2175
|
+
);
|
|
2176
|
+
}
|
|
2177
|
+
|
|
2178
|
+
float fbm (vec2 p) {
|
|
2179
|
+
float v = 0.0;
|
|
2180
|
+
float a = 0.5;
|
|
2181
|
+
for (int i = 0; i < 4; i++) {
|
|
2182
|
+
v += a * vnoise(p);
|
|
2183
|
+
p = mat2(1.6, 1.2, -1.2, 1.6) * p + 7.3;
|
|
2184
|
+
a *= 0.5;
|
|
2185
|
+
}
|
|
2186
|
+
return v / 0.9375;
|
|
2187
|
+
}
|
|
2188
|
+
|
|
2189
|
+
vec2 fold (vec2 p) {
|
|
2190
|
+
return 1.0 - abs(1.0 - mod(p, 2.0));
|
|
2191
|
+
}
|
|
2192
|
+
|
|
2193
|
+
vec4 transition (vec2 uv) {
|
|
2194
|
+
float p = progress;
|
|
2195
|
+
vec2 q = vec2(uv.x * ratio, uv.y);
|
|
2196
|
+
vec2 o = vec2(seed * 3.1, seed * 1.7);
|
|
2197
|
+
vec2 sq = q * 2.2 + o;
|
|
2198
|
+
vec2 w1 = vec2(fbm(sq + vec2(0.0, 0.6 * p)), fbm(sq + vec2(5.2, 1.3) - vec2(0.5 * p, 0.0)));
|
|
2199
|
+
vec2 w2 = vec2(fbm(sq + 3.0 * w1 + vec2(1.7, 9.2)), fbm(sq + 3.0 * w1 + vec2(8.3, 2.8)));
|
|
2200
|
+
float swirl = fbm(sq * 0.8 + 2.5 * w2) - 0.5;
|
|
2201
|
+
vec2 flow = w2 - 0.5;
|
|
2202
|
+
float amp = 0.05 + 0.35 * tendrils;
|
|
2203
|
+
float n = clamp(floor(drops + 0.5), 1.0, 8.0);
|
|
2204
|
+
float rimW = 0.1;
|
|
2205
|
+
float feather = 0.05;
|
|
2206
|
+
float margin = 1.2 * amp + rimW + 0.08; // how far the swirls can pull the front back
|
|
2207
|
+
float f = -1e3; // > 0 inside the ink
|
|
2208
|
+
float fs = -1e3; // the same, only for the drops already fallen, which fades their haze in
|
|
2209
|
+
for (int i = 0; i < 8; i++) {
|
|
2210
|
+
float fi = float(i);
|
|
2211
|
+
if (fi < n) {
|
|
2212
|
+
vec2 hs = vec2(fi * 7.13 + seed, fi * 3.71 - seed);
|
|
2213
|
+
vec2 c = vec2(mix(0.15, 0.85, hash(hs)) * ratio, mix(0.15, 0.85, hash(hs + 19.7)));
|
|
2214
|
+
float start = 0.2 * fi / n;
|
|
2215
|
+
float s = clamp((p - start) / (1.0 - start), 0.0, 1.0);
|
|
2216
|
+
// distance to the farthest corner: each bloom alone covers the frame in the end
|
|
2217
|
+
vec2 m = max(c, vec2(ratio, 1.0) - c);
|
|
2218
|
+
float far = length(m) + margin;
|
|
2219
|
+
float s3 = s * s * s;
|
|
2220
|
+
float r = (far + 0.02) * s * (0.35 + 0.65 * s3 * s3) - 0.02;
|
|
2221
|
+
float reach = amp * min(1.0, max(r, 0.0) * 5.0);
|
|
2222
|
+
float g = r - length(q - c + 1.3 * reach * flow) + reach * 0.9 * swirl;
|
|
2223
|
+
f = max(f, g);
|
|
2224
|
+
fs = max(fs, g - 0.15 * (1.0 - min(1.0, s * 12.0)));
|
|
2225
|
+
}
|
|
2226
|
+
}
|
|
2227
|
+
float aa = 0.003;
|
|
2228
|
+
float inside = smoothstep(-aa, aa, f);
|
|
2229
|
+
float wisp = 1.0 - smoothstep(0.0, 0.08, abs(fbm(sq * 2.0 + 5.0 * w2) - 0.5));
|
|
2230
|
+
float soft = smoothstep(-feather, 0.0, fs) * (0.35 + 0.4 * wisp);
|
|
2231
|
+
float haze = 0.35 * wisp * (1.0 - smoothstep(0.0, 0.1, -fs));
|
|
2232
|
+
float cover = max(inside, max(soft, haze));
|
|
2233
|
+
float edge = 1.0 - smoothstep(0.0, rimW, f);
|
|
2234
|
+
vec4 to = getToColor(fold(uv - 0.015 * edge * flow / vec2(ratio, 1.0)));
|
|
2235
|
+
to.rgb = mix(to.rgb, to.rgb * to.rgb * 0.7, rim * edge);
|
|
2236
|
+
return mix(getFromColor(uv), to, cover);
|
|
2237
|
+
}`,watercolor:`// Author: gre
|
|
2238
|
+
// License: MIT
|
|
2239
|
+
// Description: The outgoing image is washed off into wet paper, then the incoming one is painted in watercolor: pale washes spread first, blooming where the paint is still wet and drying with darker edges and grainy pigment, then deeper glazes go on, darkest tones first, until the picture is complete
|
|
2240
|
+
// Tags: watercolor, paint, paper, organic, dissolve
|
|
2241
|
+
|
|
2242
|
+
// @range(0, 1) How dark the edges of the washes dry, where the pigment gathers
|
|
2243
|
+
const float edges = 0.6;
|
|
2244
|
+
// @range(0, 1) Amount of blooms: lighter flowers of paint with frilly dark edges, where water runs back into a wet wash
|
|
2245
|
+
const float blooms = 0.5;
|
|
2246
|
+
// @range(0, 1) How much the pigment settles into the grain of the paper
|
|
2247
|
+
const float granulation = 0.5;
|
|
2248
|
+
// @color Color of the paper
|
|
2249
|
+
const vec4 paper = vec4(0.98, 0.96, 0.92, 1.0);
|
|
2250
|
+
|
|
2251
|
+
float wcHash(vec2 p) {
|
|
2252
|
+
vec3 p3 = fract(vec3(p.xyx) * 0.1031);
|
|
2253
|
+
// (kept in 0..1 before the last product, so that its rounding is the same on every target)
|
|
2254
|
+
p3 = fract(p3 + dot(p3, p3.yzx + 33.33));
|
|
2255
|
+
return fract((p3.x + p3.y) * p3.z * 37.0);
|
|
2256
|
+
}
|
|
2257
|
+
|
|
2258
|
+
float wcNoise(vec2 p) {
|
|
2259
|
+
vec2 i = floor(p);
|
|
2260
|
+
vec2 f = fract(p);
|
|
2261
|
+
f = f * f * (3.0 - 2.0 * f);
|
|
2262
|
+
return mix(
|
|
2263
|
+
mix(wcHash(i), wcHash(i + vec2(1.0, 0.0)), f.x),
|
|
2264
|
+
mix(wcHash(i + vec2(0.0, 1.0)), wcHash(i + vec2(1.0, 1.0)), f.x),
|
|
2265
|
+
f.y
|
|
2266
|
+
);
|
|
2267
|
+
}
|
|
2268
|
+
|
|
2269
|
+
// 0..1, spread evenly over the range (the sum of the octaves is about normal, around 0.5)
|
|
2270
|
+
float wcFbm(vec2 p) {
|
|
2271
|
+
float v = 0.0;
|
|
2272
|
+
float a = 0.5;
|
|
2273
|
+
for (int i = 0; i < 4; i++) {
|
|
2274
|
+
v += a * wcNoise(p);
|
|
2275
|
+
p = mat2(1.6, 1.2, -1.2, 1.6) * p + 5.7;
|
|
2276
|
+
a *= 0.5;
|
|
2277
|
+
}
|
|
2278
|
+
float z = (v / 0.9375 - 0.5) / 0.11;
|
|
2279
|
+
return 0.5 + 0.5 * z / sqrt(1.0 + z * z);
|
|
2280
|
+
}
|
|
2281
|
+
|
|
2282
|
+
vec2 wcFold(vec2 p) {
|
|
2283
|
+
return 1.0 - abs(1.0 - mod(p, 2.0));
|
|
2284
|
+
}
|
|
2285
|
+
|
|
2286
|
+
// a front spreading over the thresholds of a wash: below -margin at the start, above 1 + margin at the end
|
|
2287
|
+
float wcFront(float start, float dur, float margin) {
|
|
2288
|
+
float s = clamp((progress - start) / dur, 0.0, 1.0);
|
|
2289
|
+
s = mix(s, s * s * (3.0 - 2.0 * s), 0.5);
|
|
2290
|
+
return s * (1.0 + 2.0 * margin) - margin;
|
|
2291
|
+
}
|
|
2292
|
+
|
|
2293
|
+
// dried edge of a wash at depth d inside it: a dark line right at the edge, fading inward over w
|
|
2294
|
+
float wcRim(float d, float w) {
|
|
2295
|
+
float r = 1.0 - smoothstep(0.0, w, d);
|
|
2296
|
+
return smoothstep(-0.006, 0.004, d) * r * r;
|
|
2297
|
+
}
|
|
2298
|
+
|
|
2299
|
+
float wcLuma(vec3 c) {
|
|
2300
|
+
return dot(c, vec3(0.299, 0.587, 0.114));
|
|
2301
|
+
}
|
|
2302
|
+
|
|
2303
|
+
vec4 transition(vec2 uv) {
|
|
2304
|
+
// the last glaze has covered everything (see d3 below)
|
|
2305
|
+
if (progress >= 0.98) return getToColor(uv);
|
|
2306
|
+
vec2 q = vec2(uv.x * ratio, uv.y);
|
|
2307
|
+
vec2 px = vec2(1.0 / ratio, 1.0);
|
|
2308
|
+
vec4 from = getFromColor(uv);
|
|
2309
|
+
|
|
2310
|
+
// paper texture, turned so that the cells of the noise do not line up with the frame
|
|
2311
|
+
vec2 gq = mat2(0.8, 0.6, -0.6, 0.8) * q;
|
|
2312
|
+
float grain = 0.55 * wcNoise(gq * 120.0) + 0.45 * wcNoise(gq * 50.0 + 3.1);
|
|
2313
|
+
float tooth = 0.03 * (grain - 0.5);
|
|
2314
|
+
vec2 w = vec2(wcNoise(q * 2.5 + 1.3), wcNoise(q * 2.5 + 8.1)) - 0.5;
|
|
2315
|
+
|
|
2316
|
+
vec4 run = vec4(from.rgb * from.a, from.a);
|
|
2317
|
+
for (int i = 0; i < 4; i++) {
|
|
2318
|
+
float a = float(i) * 1.570796 + 0.8;
|
|
2319
|
+
vec4 f = getFromColor(wcFold(uv + 0.007 * vec2(cos(a), sin(a)) * px));
|
|
2320
|
+
run += vec4(f.rgb * f.a, f.a);
|
|
2321
|
+
}
|
|
2322
|
+
vec3 fromRun = run.a > 0.0 ? run.rgb / run.a : from.rgb;
|
|
2323
|
+
float d0 = wcFront(0.0, 0.4, 0.1) - wcFbm(q * 2.8 + 0.9 * w + 11.0);
|
|
2324
|
+
float lift = smoothstep(-0.03, 0.06, d0);
|
|
2325
|
+
vec3 stain = mix(paper.rgb, paper.rgb * fromRun, 0.12);
|
|
2326
|
+
vec3 c = mix(from.rgb, mix(fromRun, stain, smoothstep(0.0, 0.1, d0)), lift);
|
|
2327
|
+
c *= 1.0 - 0.18 * wcRim(d0, 0.05) * (1.0 - wcLuma(fromRun)) * lift;
|
|
2328
|
+
c *= (1.0 - 0.06 * lift * (1.0 - smoothstep(0.05, 0.4, d0)) * (1.0 - smoothstep(0.35, 0.6, progress))) * (1.0 - 0.05 * (grain - 0.5) * lift);
|
|
2329
|
+
float alpha = mix(from.a, paper.a, lift);
|
|
2330
|
+
// no wash has started yet (see d1 below)
|
|
2331
|
+
if (progress <= 0.07) return vec4(c, alpha);
|
|
2332
|
+
|
|
2333
|
+
// washes carry no detail: they take the colors of the incoming image, blurred (broadly for the
|
|
2334
|
+
// first one, less for the second) and a little off its shapes, as painted by hand.
|
|
2335
|
+
// Their pigment is as dense as the incoming image is opaque
|
|
2336
|
+
vec2 hand = uv + 0.012 * w * px;
|
|
2337
|
+
vec4 broad = vec4(0.0);
|
|
2338
|
+
vec4 fine = vec4(0.0);
|
|
2339
|
+
for (int i = 0; i < 8; i++) {
|
|
2340
|
+
float a = float(i) * 0.785398 + 0.3;
|
|
2341
|
+
vec4 b = getToColor(wcFold(hand + 0.035 * vec2(cos(a), sin(a)) * px));
|
|
2342
|
+
vec4 f = getToColor(wcFold(hand + 0.012 * vec2(-sin(a), cos(a)) * px));
|
|
2343
|
+
broad += vec4(b.rgb * b.a, b.a);
|
|
2344
|
+
fine += vec4(f.rgb * f.a, f.a);
|
|
2345
|
+
}
|
|
2346
|
+
vec3 broadC = broad.rgb / max(broad.a, 1e-3);
|
|
2347
|
+
vec3 fineC = fine.rgb / max(fine.a, 1e-3);
|
|
2348
|
+
broad.a /= 8.0;
|
|
2349
|
+
fine.a /= 8.0;
|
|
2350
|
+
float pool = wcNoise(q * 4.0 + w * 2.0 + 31.0);
|
|
2351
|
+
|
|
2352
|
+
float d1 = wcFront(0.07, 0.43, 0.12) - wcFbm(q * 3.0 + 1.2 * w + 2.0);
|
|
2353
|
+
float cov1 = smoothstep(-0.05, 0.03, d1) * lift;
|
|
2354
|
+
float k1 = 0.55 * broad.a;
|
|
2355
|
+
vec3 g1 = mix(vec3(1.0), broadC, (0.4 + 0.3 * pool) * broad.a);
|
|
2356
|
+
vec2 bq = q / 0.3;
|
|
2357
|
+
vec2 bc = floor(bq);
|
|
2358
|
+
float frill = 0.5 * wcNoise(q * 14.0) + 0.3 * wcNoise(q * 33.0 + 4.0) + 0.2 * wcNoise(q * 80.0 + 9.0);
|
|
2359
|
+
float inBloom = 0.0;
|
|
2360
|
+
float bloomRim = 0.0;
|
|
2361
|
+
for (int j = -1; j <= 1; j++) {
|
|
2362
|
+
for (int i = -1; i <= 1; i++) {
|
|
2363
|
+
vec2 cell = bc + vec2(float(i), float(j));
|
|
2364
|
+
if (wcHash(cell + vec2(17.0, 53.0)) < blooms) {
|
|
2365
|
+
vec2 ctr = cell + 0.3 + 0.4 * vec2(wcHash(cell + vec2(3.0, 71.0)), wcHash(cell + vec2(89.0, 9.0)));
|
|
2366
|
+
float g = clamp((d1 - 0.08 - 0.2 * wcHash(cell + vec2(5.0, 37.0))) / 0.3, 0.0, 1.0);
|
|
2367
|
+
g = 1.0 - (1.0 - g) * (1.0 - g) * (1.0 - g);
|
|
2368
|
+
// at most 0.32 * 1.55 < 0.5 cells: a bloom never reaches past the cells next to its own
|
|
2369
|
+
float r = g * (0.18 + 0.14 * wcHash(cell + vec2(61.0, 7.0))) * (0.45 + 1.1 * frill);
|
|
2370
|
+
float d = r - length(bq - ctr);
|
|
2371
|
+
float inside = smoothstep(-0.015, 0.015, d);
|
|
2372
|
+
inBloom = max(inBloom, inside * smoothstep(0.0, 0.25, r));
|
|
2373
|
+
bloomRim = max(bloomRim, inside * (1.0 - smoothstep(0.0, 0.05, d)) * smoothstep(0.0, 0.1, r));
|
|
2374
|
+
}
|
|
2375
|
+
}
|
|
2376
|
+
}
|
|
2377
|
+
g1 = mix(g1, mix(vec3(1.0), g1, 0.55), inBloom);
|
|
2378
|
+
g1 *= mix(vec3(1.0), g1 * g1 * 0.9, bloomRim);
|
|
2379
|
+
g1 *= mix(vec3(1.0), g1, edges * 0.8 * wcRim(d1, 0.06));
|
|
2380
|
+
|
|
2381
|
+
float t2 = clamp(mix(wcFbm(q * 3.2 - 1.0 * w + 7.0), mix(1.0, wcLuma(fineC), fine.a), 0.55) + tooth, 0.0, 1.0);
|
|
2382
|
+
float d2 = wcFront(0.25, 0.42, 0.1) - t2;
|
|
2383
|
+
float cov2 = smoothstep(-0.006, 0.004, d2) * cov1;
|
|
2384
|
+
vec3 g2 = clamp(mix(vec3(1.0), fineC, (0.75 + 0.2 * (1.0 - pool)) * fine.a) / mix(vec3(1.0), broadC, 0.55 * broad.a), 0.0, 1.0);
|
|
2385
|
+
g2 *= mix(vec3(1.0), g2 * g2 * 0.92, edges * wcRim(d2, 0.07));
|
|
2386
|
+
|
|
2387
|
+
vec3 wash = mix(vec3(1.0), g1, cov1) * mix(vec3(1.0), g2, cov2);
|
|
2388
|
+
float settle = clamp((grain - 0.5) * 2.0 + 0.5 * (wcNoise(q * 18.0 + 9.0) - 0.5), -0.4, 1.0);
|
|
2389
|
+
wash = min(wash * (1.0 - granulation * 0.45 * settle * (1.0 - wcLuma(wash))), 1.0);
|
|
2390
|
+
// on paper that is not opaque, the pigment brings its own opacity
|
|
2391
|
+
float a1 = alpha + (1.0 - alpha) * clamp(cov1 * k1 + cov2 * 0.35 * fine.a, 0.0, 1.0);
|
|
2392
|
+
c = mix(c * wash, wash, (a1 - alpha) / max(a1, 1e-3));
|
|
2393
|
+
alpha = a1;
|
|
2394
|
+
|
|
2395
|
+
vec4 to = getToColor(uv);
|
|
2396
|
+
float t3 = clamp(mix(wcFbm(q * 3.6 + 0.8 * w + 19.0), mix(1.0, wcLuma(fineC), fine.a), 0.45) + tooth, 0.0, 1.0);
|
|
2397
|
+
float d3 = wcFront(0.45, 0.53, 0.1) - t3;
|
|
2398
|
+
float cov3 = smoothstep(-0.006, 0.004, d3);
|
|
2399
|
+
vec3 last = to.rgb * mix(vec3(1.0), to.rgb * 0.9, edges * 0.7 * wcRim(d3, 0.05));
|
|
2400
|
+
return vec4(mix(c, last, cov3), mix(alpha, to.a, cov3));
|
|
2401
|
+
}`,smoke:`// Author: gre
|
|
2402
|
+
// License: MIT
|
|
2403
|
+
// Description: Billowing smoke drifts in across the outgoing image, with lit tops, darker folds and wispy edges, and thickens until it covers the frame; as it thins out and drifts away, the incoming image shows through
|
|
2404
|
+
// Tags: smoke, fog, organic, noise, cover
|
|
2405
|
+
|
|
2406
|
+
// @param Direction the smoke drifts toward (it comes in from the opposite side); its length is how far it drifts, in frame heights
|
|
2407
|
+
const vec2 direction = vec2(0.5, 0.1);
|
|
2408
|
+
// @range(1, 8) Size of the billows: more, smaller ones with a larger value
|
|
2409
|
+
const float scale = 2.5;
|
|
2410
|
+
// @range(0, 1) How much the smoke rolls in from one side rather than everywhere at once
|
|
2411
|
+
const float spread = 0.4;
|
|
2412
|
+
// @range(0.05, 1) Softness of the smoke: wispier, more see-through edges with a larger value
|
|
2413
|
+
const float softness = 0.5;
|
|
2414
|
+
// @color Color of the smoke, lit from above
|
|
2415
|
+
const vec4 color = vec4(0.86, 0.86, 0.88, 1.0);
|
|
2416
|
+
|
|
2417
|
+
float hash12(vec2 v) {
|
|
2418
|
+
vec3 v3 = fract(vec3(v.xyx) * 0.1031);
|
|
2419
|
+
v3 += dot(v3, v3.yzx + 33.33);
|
|
2420
|
+
return fract((v3.x + v3.y) * v3.z);
|
|
2421
|
+
}
|
|
2422
|
+
|
|
2423
|
+
float vnoise(vec2 v) {
|
|
2424
|
+
vec2 i = floor(v);
|
|
2425
|
+
vec2 f = fract(v);
|
|
2426
|
+
f = f * f * (3.0 - 2.0 * f);
|
|
2427
|
+
return mix(
|
|
2428
|
+
mix(hash12(i), hash12(i + vec2(1.0, 0.0)), f.x),
|
|
2429
|
+
mix(hash12(i + vec2(0.0, 1.0)), hash12(i + vec2(1.0, 1.0)), f.x),
|
|
2430
|
+
f.y
|
|
2431
|
+
);
|
|
2432
|
+
}
|
|
2433
|
+
|
|
2434
|
+
float fbm(vec2 v) {
|
|
2435
|
+
float sum = 0.0;
|
|
2436
|
+
float amp = 0.5;
|
|
2437
|
+
for (int i = 0; i < 4; i++) {
|
|
2438
|
+
sum += amp * vnoise(v);
|
|
2439
|
+
v = mat2(1.6, 1.2, -1.2, 1.6) * v + 5.3;
|
|
2440
|
+
amp *= 0.5;
|
|
2441
|
+
}
|
|
2442
|
+
return sum / 0.9375;
|
|
2443
|
+
}
|
|
2444
|
+
|
|
2445
|
+
vec4 transition(vec2 uv) {
|
|
2446
|
+
float p = progress;
|
|
2447
|
+
vec2 pos = (uv - 0.5) * vec2(ratio, 1.0);
|
|
2448
|
+
|
|
2449
|
+
// where along the drift the pixel is: 0 on the side the smoke comes from, 1 on the other
|
|
2450
|
+
float len = length(direction);
|
|
2451
|
+
vec2 dir = len > 1e-4 ? direction / len : vec2(0.0);
|
|
2452
|
+
float ext = 0.5 * (abs(dir.x) * ratio + abs(dir.y)) + 1e-4;
|
|
2453
|
+
float along = len > 1e-4 ? 0.5 + 0.5 * dot(pos, dir) / ext : 0.5;
|
|
2454
|
+
|
|
2455
|
+
// the smoke rolls in (until 0.45), covers the whole frame, then thins out (from 0.55),
|
|
2456
|
+
// each side of the frame in turn
|
|
2457
|
+
float arrive = (p / 0.45) * (1.0 + spread) - spread * along;
|
|
2458
|
+
float leave = ((p - 0.55) / 0.45) * (1.0 + spread) - spread * along;
|
|
2459
|
+
float body = smoothstep(0.0, 1.0, arrive) * (1.0 - smoothstep(0.0, 1.0, leave));
|
|
2460
|
+
// the images switch while the smoke is fully dense everywhere
|
|
2461
|
+
float m = smoothstep(0.48, 0.52, p);
|
|
2462
|
+
if (body <= 0.0) return m < 0.5 ? getFromColor(uv) : getToColor(uv);
|
|
2463
|
+
|
|
2464
|
+
vec2 q = (pos - direction * (p - 0.5)) * scale;
|
|
2465
|
+
vec2 churn = vec2(0.5 * p, -0.35 * p);
|
|
2466
|
+
vec2 warp = vec2(fbm(q + vec2(3.1, 1.7) + churn), fbm(q + vec2(8.3, 2.8) - churn));
|
|
2467
|
+
vec2 w = q + 1.1 * (warp - 0.5);
|
|
2468
|
+
float n = fbm(w);
|
|
2469
|
+
// the billows catch the light from above: brighter where the smoke rises toward it
|
|
2470
|
+
// (on the coarse octave only, which shapes them)
|
|
2471
|
+
float lit = 0.53 * (vnoise(w) - vnoise(w + vec2(0.0, 0.2)));
|
|
2472
|
+
float wisp = vnoise(w * 3.3 - 2.0 * churn) - 0.5;
|
|
2473
|
+
|
|
2474
|
+
float edge = 2.0 * body - (1.0 - smoothstep(0.1, 0.6, n)) + 1.6 * body * (1.0 - body) * wisp;
|
|
2475
|
+
float d = smoothstep(0.0, softness, edge) * mix(0.5, 1.0, smoothstep(0.2, 0.9, body));
|
|
2476
|
+
|
|
2477
|
+
vec4 base;
|
|
2478
|
+
if (m <= 0.0) base = getFromColor(uv);
|
|
2479
|
+
else if (m >= 1.0) base = getToColor(uv);
|
|
2480
|
+
else {
|
|
2481
|
+
vec4 a = getFromColor(uv);
|
|
2482
|
+
vec4 b = getToColor(uv);
|
|
2483
|
+
base = mix(vec4(a.rgb * a.a, a.a), vec4(b.rgb * b.a, b.a), m);
|
|
2484
|
+
base = base.a > 0.0 ? vec4(base.rgb / base.a, base.a) : vec4(0.0);
|
|
2485
|
+
}
|
|
2486
|
+
if (d <= 0.0) return base;
|
|
2487
|
+
|
|
2488
|
+
float shade = 0.92 + 1.3 * lit;
|
|
2489
|
+
shade *= mix(0.76, 1.04, smoothstep(0.25, 0.75, n));
|
|
2490
|
+
shade = mix(1.0, shade, 0.3 + 0.7 * d);
|
|
2491
|
+
vec3 smoke = clamp(color.rgb * shade, 0.0, 1.0);
|
|
2492
|
+
|
|
2493
|
+
// the smoke color mixes as straight RGBA, like every fill color
|
|
2494
|
+
return mix(base, vec4(smoke, color.a), d);
|
|
2495
|
+
}`,"paper-tear":`// Author: gre
|
|
2496
|
+
// License: MIT
|
|
2497
|
+
// Description: The outgoing image tears in two along a ragged line, and the halves are pulled apart to reveal the incoming one
|
|
2498
|
+
// Tags: split, horizontal, shadow
|
|
2499
|
+
|
|
2500
|
+
// @range(0, 0.3) How far the tear wanders from the middle, relative to the image height
|
|
2501
|
+
const float roughness = 0.12;
|
|
2502
|
+
// @range(0, 0.5) How much the top of each half leans away first, so that the tear opens from the top
|
|
2503
|
+
const float tilt = 0.1;
|
|
2504
|
+
// @range(0, 0.05) Width of the white torn edge, relative to the image height
|
|
2505
|
+
const float rim = 0.012;
|
|
2506
|
+
// @color Color of the paper fibers on the torn edges
|
|
2507
|
+
const vec4 paper = vec4(1.0, 0.98, 0.94, 1.0);
|
|
2508
|
+
// @color Color of the shadow cast on the incoming image
|
|
2509
|
+
const vec4 shadow = vec4(0.0, 0.0, 0.0, 0.35);
|
|
2510
|
+
|
|
2511
|
+
float tri (float x) {
|
|
2512
|
+
return abs(fract(x) - 0.5) - 0.25;
|
|
2513
|
+
}
|
|
2514
|
+
|
|
2515
|
+
// horizontal position of the tear at height y: smooth meanders...
|
|
2516
|
+
float meander (float y) {
|
|
2517
|
+
return 0.5 * ratio + roughness * (0.5 * sin(y * 4.7 + 1.3) + 0.25 * sin(y * 11.3 + 4.1));
|
|
2518
|
+
}
|
|
2519
|
+
|
|
2520
|
+
// ...and sharp jags
|
|
2521
|
+
float tear (float y) {
|
|
2522
|
+
return meander(y) + roughness * (0.1 * sin(y * 29.0 + 0.7) + 0.35 * tri(y * 19.0 + sin(y * 7.0)) + 0.12 * tri(y * 47.0 + 0.6 * sin(y * 13.0)));
|
|
2523
|
+
}
|
|
2524
|
+
|
|
2525
|
+
float fibers (float y, float seed) {
|
|
2526
|
+
return rim * (0.7 + 0.3 * sin(y * 37.0 + seed) + 0.4 * tri(y * 83.0 + seed));
|
|
2527
|
+
}
|
|
2528
|
+
|
|
2529
|
+
// the left half (or the mirrored right half) slides out, its top leaning away first:
|
|
2530
|
+
// from a point on screen to the point of the paper (the frame edges stay covered)
|
|
2531
|
+
vec2 unfold (vec2 q, float away, float lean) {
|
|
2532
|
+
return vec2(q.x + away + lean * q.y, q.y);
|
|
2533
|
+
}
|
|
2534
|
+
|
|
2535
|
+
// a torn half over bg; e: distance past the torn edge, limit: how far the fibers reach, aa: edge softness
|
|
2536
|
+
vec4 torn (vec4 bg, vec4 col, float e, float limit, float aa) {
|
|
2537
|
+
vec4 c = vec4(mix(col.rgb, paper.rgb, clamp(0.5 + e / aa, 0.0, 1.0) * paper.a), col.a);
|
|
2538
|
+
return mix(bg, c, clamp(0.5 - (e - limit) / aa, 0.0, 1.0));
|
|
2539
|
+
}
|
|
2540
|
+
|
|
2541
|
+
vec4 transition (vec2 uv) {
|
|
2542
|
+
float p = progress;
|
|
2543
|
+
float away = p * p * (0.5 * ratio + 0.1 + roughness + 2.0 * rim); // far enough to leave the frame
|
|
2544
|
+
float lean = tilt * p * (2.0 - p);
|
|
2545
|
+
float fiber = smoothstep(0.0, 0.15, p); // no torn edge on the intact image
|
|
2546
|
+
float aa = 0.002 * fiber + 1e-6;
|
|
2547
|
+
vec2 q = vec2(uv.x * ratio, uv.y);
|
|
2548
|
+
vec2 l = unfold(q, away, lean);
|
|
2549
|
+
vec2 r = unfold(vec2(ratio - q.x, q.y), away, lean);
|
|
2550
|
+
float el = l.x - tear(l.y); // > 0 right of the left half's torn edge
|
|
2551
|
+
float er = r.x - (ratio - tear(r.y)); // > 0 left of the right half's torn edge
|
|
2552
|
+
vec2 sq = q - vec2(0.01, 0.0);
|
|
2553
|
+
float dl = unfold(sq, away, lean).x - meander(sq.y);
|
|
2554
|
+
float dr = unfold(vec2(ratio - sq.x, sq.y), away, lean).x - (ratio - meander(sq.y));
|
|
2555
|
+
vec4 to = getToColor(uv);
|
|
2556
|
+
float sh = shadow.a * (1.0 - smoothstep(-0.02, 0.08, min(dl, dr)));
|
|
2557
|
+
vec4 c = vec4(mix(to.rgb, shadow.rgb, sh), to.a);
|
|
2558
|
+
if (r.x >= 0.0) {
|
|
2559
|
+
c = torn(c, getFromColor(vec2(1.0 - r.x / ratio, r.y)), er, fibers(r.y, 2.0) * 1.5 * fiber, aa);
|
|
2560
|
+
}
|
|
2561
|
+
if (l.x >= 0.0) {
|
|
2562
|
+
c = torn(c, getFromColor(vec2(l.x / ratio, l.y)), el, fibers(l.y, 0.0) * fiber, aa);
|
|
2563
|
+
}
|
|
2564
|
+
return c;
|
|
2565
|
+
}`,crumple:`// Author: gre
|
|
2566
|
+
// License: MIT
|
|
2567
|
+
// Description: The outgoing image crumples into a creased paper ball, shaded along its folds, which is then tossed away to reveal the incoming image
|
|
2568
|
+
// Tags: paper, 3d, shrink, shadow
|
|
2569
|
+
|
|
2570
|
+
// @range(1, 32, 1) Number of folds creasing the paper
|
|
2571
|
+
const int creases = 16;
|
|
2572
|
+
// @range(0.05, 0.4) Radius of the paper ball, relative to the image height
|
|
2573
|
+
const float size = 0.2;
|
|
2574
|
+
// @param Direction the ball is tossed toward
|
|
2575
|
+
const vec2 direction = vec2(1.0, 0.4);
|
|
2576
|
+
// @color Color of the bare paper showing through the ink along the sharpest creases
|
|
2577
|
+
const vec4 paper = vec4(0.96, 0.95, 0.91, 1.0);
|
|
2578
|
+
// @color Color of the shadow cast on the incoming image
|
|
2579
|
+
const vec4 shadow = vec4(0.0, 0.0, 0.0, 0.45);
|
|
2580
|
+
|
|
2581
|
+
const float PI = 3.14159265;
|
|
2582
|
+
|
|
2583
|
+
vec2 hash2(vec2 p) {
|
|
2584
|
+
p = vec2(dot(p, vec2(127.1, 311.7)), dot(p, vec2(269.5, 183.3)));
|
|
2585
|
+
return fract(sin(p) * 43758.5453);
|
|
2586
|
+
}
|
|
2587
|
+
|
|
2588
|
+
mat2 rot(float a) {
|
|
2589
|
+
float s = sin(a);
|
|
2590
|
+
float c = cos(a);
|
|
2591
|
+
return mat2(c, -s, s, c);
|
|
2592
|
+
}
|
|
2593
|
+
|
|
2594
|
+
float frame(vec2 a) {
|
|
2595
|
+
return min(0.5 * ratio / max(abs(a.x), 1e-4), 0.5 / max(abs(a.y), 1e-4));
|
|
2596
|
+
}
|
|
2597
|
+
|
|
2598
|
+
// distance from the center to the edge of the paper in the direction a (unit vector):
|
|
2599
|
+
// the frame shrinking and buckling while it crumples (c), turning into a lumpy ball (k)
|
|
2600
|
+
float outline(vec2 a, float c, float k, float radius) {
|
|
2601
|
+
float rect = frame(a);
|
|
2602
|
+
float th = atan(a.y, a.x);
|
|
2603
|
+
float buckle = 0.03 + 0.05 * abs(sin(4.0 * th + 0.7)) + 0.03 * abs(sin(9.0 * th + 2.0)) + 0.015 * abs(sin(23.0 * th + 1.3));
|
|
2604
|
+
float i = floor((th / (2.0 * PI) + 0.5) * 9.0);
|
|
2605
|
+
float a0 = i * 2.0 * PI / 9.0 - PI;
|
|
2606
|
+
float a1 = a0 + 2.0 * PI / 9.0;
|
|
2607
|
+
vec2 v0 = vec2(cos(a0), sin(a0)) * (0.78 + 0.27 * hash2(vec2(mod(i, 9.0), 3.0)).x);
|
|
2608
|
+
vec2 v1 = vec2(cos(a1), sin(a1)) * (0.78 + 0.27 * hash2(vec2(mod(i + 1.0, 9.0), 3.0)).x);
|
|
2609
|
+
vec2 e = v1 - v0;
|
|
2610
|
+
float ball = radius * (v0.x * e.y - v0.y * e.x) / (a.x * e.y - a.y * e.x);
|
|
2611
|
+
return mix(rect * mix(1.0, 0.75, c) * (1.0 - c * buckle), ball, k);
|
|
2612
|
+
}
|
|
2613
|
+
|
|
2614
|
+
// n straight creases of random position, orientation and length, in a space where the
|
|
2615
|
+
// paper spans about [-span, span]; each one tilts the paper on its two sides (a sharp ridge
|
|
2616
|
+
// or valley between flat facets) and swallows a strip of the image. They come one after
|
|
2617
|
+
// another as c grows; px is the half width of a crease line, in the units of x.
|
|
2618
|
+
void fold(vec2 x, float seed, int n, vec2 span, float len, float c, float px, float weight,
|
|
2619
|
+
inout vec2 grad, inout vec2 shift, inout float valley, inout float ridge) {
|
|
2620
|
+
float tilt = 2.0 / sqrt(float(n));
|
|
2621
|
+
for (int i = 0; i < 32; i++) {
|
|
2622
|
+
if (i >= n) break;
|
|
2623
|
+
float fi = float(i);
|
|
2624
|
+
vec2 h = hash2(vec2(fi, seed));
|
|
2625
|
+
vec2 g = hash2(vec2(fi, seed + 11.8));
|
|
2626
|
+
vec2 o = (h - 0.5) * 2.0 * span;
|
|
2627
|
+
vec2 nrm = vec2(cos(2.0 * PI * g.x), sin(2.0 * PI * g.x));
|
|
2628
|
+
float d = dot(x - o, nrm);
|
|
2629
|
+
float along = dot(x - o, vec2(-nrm.y, nrm.x));
|
|
2630
|
+
float l = len * (0.5 + g.y);
|
|
2631
|
+
float start = 0.4 * fi / float(n);
|
|
2632
|
+
float act = weight * smoothstep(start, start + 0.3, c) * (1.0 - smoothstep(0.5 * l, l, abs(along)));
|
|
2633
|
+
float amp = (h.x > 0.5 ? 1.0 : -1.0) * (0.5 + 0.5 * h.y);
|
|
2634
|
+
float side = d / (abs(d) + px);
|
|
2635
|
+
grad += act * amp * side * nrm * tilt;
|
|
2636
|
+
shift += act * 0.03 * side * nrm;
|
|
2637
|
+
float line = 1.0 - smoothstep(0.0, 2.0 * px, abs(d));
|
|
2638
|
+
if (amp < 0.0) valley += act * line;
|
|
2639
|
+
else ridge += act * line * amp;
|
|
2640
|
+
}
|
|
2641
|
+
}
|
|
2642
|
+
|
|
2643
|
+
vec4 transition(vec2 uv) {
|
|
2644
|
+
vec4 b = getToColor(uv);
|
|
2645
|
+
|
|
2646
|
+
// crumpling (c), balling up (k), then tossing (t)
|
|
2647
|
+
float c = smoothstep(0.0, 0.6, progress);
|
|
2648
|
+
float k = smoothstep(0.1, 0.62, progress);
|
|
2649
|
+
float t = smoothstep(0.58, 1.0, progress);
|
|
2650
|
+
t *= t;
|
|
2651
|
+
|
|
2652
|
+
vec2 dir = length(direction) > 0.0 ? normalize(direction) : vec2(1.0, 0.0);
|
|
2653
|
+
float radius = max(size, 0.01) * mix(1.0, 0.6, t);
|
|
2654
|
+
// far enough along the direction for the ball and its shadow (offset and blurred by up
|
|
2655
|
+
// to about 0.09 each) to leave the frame
|
|
2656
|
+
float reach = 0.5 * (abs(dir.x) * ratio + abs(dir.y)) + 1.2 * radius + 0.3;
|
|
2657
|
+
float bend = dir.x < 0.0 ? -1.0 : 1.0;
|
|
2658
|
+
vec2 center = dir * reach * t + vec2(-dir.y, dir.x) * 0.15 * bend * sin(PI * t);
|
|
2659
|
+
float angle = 0.6 * c - 5.0 * bend * t;
|
|
2660
|
+
float lift = 0.012 * c + 0.06 * t;
|
|
2661
|
+
|
|
2662
|
+
vec2 p = (uv - 0.5) * vec2(ratio, 1.0);
|
|
2663
|
+
|
|
2664
|
+
vec2 sp = rot(angle) * (p - center - vec2(0.6, -1.0) * lift);
|
|
2665
|
+
float sl = length(sp);
|
|
2666
|
+
float sd = sl - outline(sl > 1e-5 ? sp / sl : vec2(1.0, 0.0), c, k, radius);
|
|
2667
|
+
float blur = 0.005 + 1.2 * lift;
|
|
2668
|
+
vec4 col = vec4(mix(b.rgb, shadow.rgb, shadow.a * c * (1.0 - smoothstep(-blur, blur, sd))), b.a);
|
|
2669
|
+
|
|
2670
|
+
vec2 q = rot(angle) * (p - center);
|
|
2671
|
+
float l = length(q);
|
|
2672
|
+
vec2 dq = l > 1e-5 ? q / l : vec2(1.0, 0.0);
|
|
2673
|
+
float edge = outline(dq, c, k, radius);
|
|
2674
|
+
// the edge (about a pixel at 300 px high) is antialiased only once the sheet has left the
|
|
2675
|
+
// borders of the frame
|
|
2676
|
+
float aa = 0.003 * smoothstep(0.0, 0.1, progress) + 1e-5;
|
|
2677
|
+
float inside = 1.0 - smoothstep(-aa, aa, l - edge);
|
|
2678
|
+
if (inside <= 0.0) return col;
|
|
2679
|
+
|
|
2680
|
+
// back onto the flat sheet: the outline is mapped onto the frame, the middle of the ball
|
|
2681
|
+
// holds more of it, as if the edges were tucked under
|
|
2682
|
+
float r = l / edge;
|
|
2683
|
+
float rect = frame(dq);
|
|
2684
|
+
vec2 s = dq * rect * mix(r, r * (0.6 + 0.4 * r), k);
|
|
2685
|
+
|
|
2686
|
+
int count = creases < 1 ? 1 : creases;
|
|
2687
|
+
vec2 grad = vec2(0.0);
|
|
2688
|
+
vec2 shift = vec2(0.0);
|
|
2689
|
+
float valley = 0.0;
|
|
2690
|
+
float ridge = 0.0;
|
|
2691
|
+
fold(s, 7.3, count, 0.45 * vec2(ratio, 1.0), 0.6, c, 0.003 * rect / edge, 1.0 - 0.8 * k, grad, shift, valley, ridge);
|
|
2692
|
+
vec2 g2 = vec2(0.0);
|
|
2693
|
+
vec2 s2 = vec2(0.0);
|
|
2694
|
+
float v2 = 0.0;
|
|
2695
|
+
float r2 = 0.0;
|
|
2696
|
+
fold(q / radius, 2.9, count, vec2(0.7), 8.0, k, 0.003 / radius, k, g2, s2, v2, r2);
|
|
2697
|
+
grad += g2 * 0.8;
|
|
2698
|
+
vec2 piece = s + shift + s2 * 3.0;
|
|
2699
|
+
|
|
2700
|
+
// facets over the ball's volume, lit from the top left (the light does not turn with the ball)
|
|
2701
|
+
float rr = clamp(l / (radius * 1.1), 0.0, 1.0);
|
|
2702
|
+
vec3 sphere = vec3(q / (radius * 1.1) * k * 0.8, sqrt(1.0 - 0.64 * rr * rr * k));
|
|
2703
|
+
vec3 n = normalize(sphere + vec3(grad, 0.0));
|
|
2704
|
+
n.xy = rot(-angle) * n.xy;
|
|
2705
|
+
vec3 light = normalize(vec3(-0.5, 0.6, 0.8));
|
|
2706
|
+
float diffuse = max(dot(n, light), 0.0);
|
|
2707
|
+
vec3 hv = normalize(light + vec3(0.0, 0.0, 1.0));
|
|
2708
|
+
// only what facets add over the flat sheet
|
|
2709
|
+
float spec = max(pow(max(dot(n, hv), 0.0), 20.0) - pow(hv.z, 20.0), 0.0);
|
|
2710
|
+
float level = light.z;
|
|
2711
|
+
float relief = min(2.0 * c, 1.0);
|
|
2712
|
+
float shade = 1.0 + relief * ((0.12 + diffuse) / (0.12 + level) - 1.0) + 0.7 * spec * relief;
|
|
2713
|
+
shade -= 0.2 * relief * min(valley, 1.0);
|
|
2714
|
+
shade *= 1.0 - 0.3 * k * smoothstep(0.6, 1.0, r);
|
|
2715
|
+
|
|
2716
|
+
// the edges of the sheet that the folds pull in are mirrored, as if folded back
|
|
2717
|
+
vec2 f = piece / vec2(ratio, 1.0) + 0.5;
|
|
2718
|
+
vec4 img = getFromColor(1.0 - abs(1.0 - mod(f, 2.0)));
|
|
2719
|
+
img.rgb = mix(img.rgb, paper.rgb, 0.6 * min(ridge, 1.0) * paper.a * c);
|
|
2720
|
+
vec4 ball = vec4(img.rgb * shade, img.a);
|
|
2721
|
+
|
|
2722
|
+
// mixed premultiplied, so transparent images do not bleed their color
|
|
2723
|
+
float m = inside * ball.a;
|
|
2724
|
+
vec4 o = vec4(mix(col.rgb * col.a, ball.rgb, m), mix(col.a, 1.0, m));
|
|
2725
|
+
return o.a > 0.0 ? vec4(o.rgb / o.a, o.a) : vec4(0.0);
|
|
2726
|
+
}`,sphere:`// Author: gre
|
|
2727
|
+
// License: MIT
|
|
2728
|
+
// Description: The outgoing image wraps itself onto a shaded ball that shrinks and rolls away, revealing the incoming image under its shadow
|
|
2729
|
+
// Tags: 3d, sphere, roll, wrap, shape
|
|
2730
|
+
|
|
2731
|
+
// @param Direction the ball rolls away toward
|
|
2732
|
+
const vec2 direction = vec2(1.0, 0.0);
|
|
2733
|
+
// @range(0.1, 0.5) Radius of the ball once wrapped, relative to the shorter side of the frame
|
|
2734
|
+
const float size = 0.3;
|
|
2735
|
+
// @range(0, 1) Strength of the light and shading on the ball
|
|
2736
|
+
const float shading = 0.6;
|
|
2737
|
+
// @range(0, 1) Darkness of the soft shadow the ball casts on the incoming image
|
|
2738
|
+
const float shadow = 0.5;
|
|
2739
|
+
|
|
2740
|
+
const float PI = 3.14159265;
|
|
2741
|
+
const float AA = 0.0015;
|
|
2742
|
+
const vec3 LIGHT = vec3(-0.5, 0.6, 1.0) / 1.2689;
|
|
2743
|
+
|
|
2744
|
+
vec4 transition(vec2 uv) {
|
|
2745
|
+
vec4 b = getToColor(uv);
|
|
2746
|
+
|
|
2747
|
+
vec2 dir = length(direction) > 0.0 ? normalize(direction) : vec2(1.0, 0.0);
|
|
2748
|
+
vec2 side = vec2(-dir.y, dir.x);
|
|
2749
|
+
vec2 p = (uv - 0.5) * vec2(ratio, 1.0);
|
|
2750
|
+
float shorter = min(ratio, 1.0);
|
|
2751
|
+
float r0 = clamp(size, 0.1, 0.5) * shorter;
|
|
2752
|
+
|
|
2753
|
+
// the image curves into a ball (infinite radius: exactly flat at the start), then the
|
|
2754
|
+
// ball shrinks while rolling away until it and its shadow have left the frame
|
|
2755
|
+
float w = clamp(progress / 0.45, 0.0, 1.0);
|
|
2756
|
+
w = 1.0 - (1.0 - w) * (1.0 - w);
|
|
2757
|
+
float away = smoothstep(0.3, 1.0, progress);
|
|
2758
|
+
away *= away;
|
|
2759
|
+
float wrapped = r0 / max(w, 1e-4);
|
|
2760
|
+
float radius = wrapped * mix(1.0, 0.5, away);
|
|
2761
|
+
// the image is pulled tighter as it wraps, so that it ends up covering the whole ball
|
|
2762
|
+
// (its shortest half extent reaches around to the back)
|
|
2763
|
+
float tight = mix(1.0, min(1.0, 0.48 * shorter / (PI * r0)), w * w);
|
|
2764
|
+
float paper = radius * tight;
|
|
2765
|
+
float e = 0.5 * (abs(dir.x) * ratio + abs(dir.y));
|
|
2766
|
+
// far enough that the ball (0.5 * r0 by then) and its shadow (within 0.9 * r0 of it) have left
|
|
2767
|
+
float full = e + 1.1 * r0 + 2.0 * AA;
|
|
2768
|
+
float travel = away * full;
|
|
2769
|
+
vec2 center = dir * travel;
|
|
2770
|
+
// rolling without slipping: the integral of dtravel / radius while the radius shrinks
|
|
2771
|
+
float angle = -2.0 * full * log(1.0 - 0.5 * away) / wrapped;
|
|
2772
|
+
|
|
2773
|
+
vec2 d = p - center;
|
|
2774
|
+
float r = length(d);
|
|
2775
|
+
|
|
2776
|
+
vec2 sd = d - vec2(0.25, -0.3) * radius * w;
|
|
2777
|
+
float sh = shadow * w * (1.0 - smoothstep(0.6 * radius, 1.4 * radius, length(sd)));
|
|
2778
|
+
vec4 bg = vec4(b.rgb * b.a * (1.0 - sh), b.a);
|
|
2779
|
+
|
|
2780
|
+
vec4 ball = vec4(0.0);
|
|
2781
|
+
float cover = 1.0 - smoothstep(radius - AA, radius + AA, r);
|
|
2782
|
+
if (cover > 0.0) {
|
|
2783
|
+
// normal of the visible point of the ball (no squared radius, which overflows when it is huge)
|
|
2784
|
+
vec2 nd = d / radius;
|
|
2785
|
+
vec3 n = vec3(nd, sqrt(max(1.0 - dot(nd, nd), 0.0)));
|
|
2786
|
+
float u = dot(n.xy, dir);
|
|
2787
|
+
float s = dot(n.xy, side);
|
|
2788
|
+
float cu = cos(angle), su = sin(angle);
|
|
2789
|
+
vec3 q = vec3(u * cu - n.z * su, s, u * su + n.z * cu);
|
|
2790
|
+
// the image is wrapped around the ball from its front point, distances kept along the surface
|
|
2791
|
+
float lq = length(q.xy);
|
|
2792
|
+
float arc = atan(lq, q.z) * paper;
|
|
2793
|
+
vec2 img = lq > 0.0 ? (q.x * dir + q.y * side) / lq * arc : vec2(0.0);
|
|
2794
|
+
vec2 iuv = img / vec2(ratio, 1.0) + 0.5;
|
|
2795
|
+
vec2 edge = min(iuv, 1.0 - iuv) * vec2(ratio, 1.0);
|
|
2796
|
+
float inside = cover * smoothstep(-AA, AA, min(edge.x, edge.y));
|
|
2797
|
+
if (inside > 0.0) {
|
|
2798
|
+
vec4 c = getFromColor(clamp(iuv, 0.0, 1.0));
|
|
2799
|
+
float diff = max(dot(n, LIGHT), 0.0);
|
|
2800
|
+
float spec = pow(max(reflect(-LIGHT, n).z, 0.0), 24.0);
|
|
2801
|
+
float k = shading * w;
|
|
2802
|
+
vec3 lit = c.rgb * mix(1.0, 0.25 + 0.85 * diff, k) + 0.35 * k * spec;
|
|
2803
|
+
ball = vec4(clamp(lit, 0.0, 1.0) * c.a, c.a) * inside;
|
|
2804
|
+
}
|
|
2805
|
+
}
|
|
2806
|
+
|
|
2807
|
+
// the ball over the incoming image, premultiplied so transparent images do not bleed their color
|
|
2808
|
+
vec4 c = ball + bg * (1.0 - ball.a);
|
|
2809
|
+
return c.a > 0.0 ? vec4(c.rgb / c.a, c.a) : vec4(0.0);
|
|
2810
|
+
}`,"book-flip":`// Author: hong
|
|
2811
|
+
// License: MIT
|
|
2812
|
+
// Description: The right half of the outgoing image is a book page that turns over from right to left on the spine at the middle of the frame, curling near its free edge, its back bringing the left half of the incoming image
|
|
2813
|
+
// Tags: page, flip, 3d
|
|
2814
|
+
|
|
2815
|
+
// @range(0, 1) Strength of the perspective: the page grows as it lifts toward the viewer
|
|
2816
|
+
const float perspective = 0.5;
|
|
2817
|
+
// @range(0, 1) How much the page darkens as it turns away from the light, and the shadows it casts
|
|
2818
|
+
const float shading = 0.6;
|
|
2819
|
+
// @range(0, 1) How much the page bends near its free edge, which trails behind as it turns
|
|
2820
|
+
const float curl = 0.5;
|
|
2821
|
+
|
|
2822
|
+
const float PI = 3.141592653589793;
|
|
2823
|
+
const float EDGE = 0.0015;
|
|
2824
|
+
const float CURL_PART = 0.45;
|
|
2825
|
+
// direction of the light, in (x, height toward the viewer)
|
|
2826
|
+
const vec2 LIGHT = vec2(-0.447214, 0.894427);
|
|
2827
|
+
|
|
2828
|
+
float cross2(vec2 a, vec2 b) {
|
|
2829
|
+
return a.x * b.y - a.y * b.x;
|
|
2830
|
+
}
|
|
2831
|
+
|
|
2832
|
+
// the page's angle, 0 lying on the right to PI lying on the left: eased, but never at rest
|
|
2833
|
+
float pageAngle() {
|
|
2834
|
+
float p = clamp(progress, 0.0, 1.0);
|
|
2835
|
+
return PI * p * (0.35 + p * (1.95 - 1.3 * p));
|
|
2836
|
+
}
|
|
2837
|
+
|
|
2838
|
+
// The page is seen in a cross-section across the spine, in (x, height toward the viewer) from the spine:
|
|
2839
|
+
// a straight part at angle a from the spine, then, when k is not 0, an arc of curvature k centered on c up to its free edge,
|
|
2840
|
+
// extruded along y. Returns the nearest point of the page hit by the ray from eye along dir:
|
|
2841
|
+
// (ray length, distance along the page, angle there), with a negative ray length when it is missed.
|
|
2842
|
+
vec3 hitPage(vec2 eye, vec2 dir, float a, float k, float straight, vec2 c, float w) {
|
|
2843
|
+
vec3 best = vec3(-1.0, 0.0, 0.0);
|
|
2844
|
+
vec2 d = vec2(cos(a), sin(a));
|
|
2845
|
+
float den = cross2(d, dir);
|
|
2846
|
+
if (abs(den) > 1e-7) {
|
|
2847
|
+
float u = cross2(eye, dir) / den;
|
|
2848
|
+
float t = cross2(eye, d) / den;
|
|
2849
|
+
if (t > 0.0 && u >= 0.0 && u <= straight) best = vec3(t, u, a);
|
|
2850
|
+
}
|
|
2851
|
+
if (k != 0.0) {
|
|
2852
|
+
float r = 1.0 / k;
|
|
2853
|
+
vec2 oc = eye - c;
|
|
2854
|
+
float qa = dot(dir, dir);
|
|
2855
|
+
float qb = dot(oc, dir);
|
|
2856
|
+
float disc = qb * qb - qa * (dot(oc, oc) - r * r);
|
|
2857
|
+
if (disc >= 0.0) {
|
|
2858
|
+
float sq = sqrt(disc);
|
|
2859
|
+
for (int i = 0; i < 2; i++) {
|
|
2860
|
+
float t = (-qb + (i == 0 ? -sq : sq)) / qa;
|
|
2861
|
+
if (t > 0.0 && (best.x < 0.0 || t < best.x)) {
|
|
2862
|
+
// (sin(b), -cos(b)) where b is the angle of the page at that point
|
|
2863
|
+
vec2 v = (oc + t * dir) * k;
|
|
2864
|
+
float db = atan(v.x, -v.y) - a;
|
|
2865
|
+
db -= 2.0 * PI * floor((db + PI) / (2.0 * PI));
|
|
2866
|
+
float s = db / k;
|
|
2867
|
+
if (s >= 0.0 && s <= w - straight) best = vec3(t, straight + s, a + db);
|
|
2868
|
+
}
|
|
2869
|
+
}
|
|
2870
|
+
}
|
|
2871
|
+
}
|
|
2872
|
+
return best;
|
|
2873
|
+
}
|
|
2874
|
+
|
|
2875
|
+
vec2 curlPoint(vec2 c, float k, float b) {
|
|
2876
|
+
return c + vec2(sin(b), -cos(b)) / k;
|
|
2877
|
+
}
|
|
2878
|
+
|
|
2879
|
+
vec4 transition (vec2 uv) {
|
|
2880
|
+
float a = pageAngle();
|
|
2881
|
+
float lift = sin(a);
|
|
2882
|
+
float w = 0.5 * ratio;
|
|
2883
|
+
float x = uv.x * ratio - w;
|
|
2884
|
+
float dist = w * (1.0 + 1.5 / max(perspective, 0.01));
|
|
2885
|
+
vec2 eye = vec2(0.0, dist);
|
|
2886
|
+
vec2 dir = vec2(x, -dist);
|
|
2887
|
+
|
|
2888
|
+
vec2 d = vec2(cos(a), sin(a));
|
|
2889
|
+
float k = -clamp(curl, 0.0, 1.0) * lift / (CURL_PART * w);
|
|
2890
|
+
if (abs(k) * CURL_PART * w <= 1e-4) k = 0.0;
|
|
2891
|
+
float straight = k != 0.0 ? (1.0 - CURL_PART) * w : w;
|
|
2892
|
+
vec2 c = straight * d + vec2(-d.y, d.x) / (k != 0.0 ? k : 1.0);
|
|
2893
|
+
vec2 bend = straight * d;
|
|
2894
|
+
vec2 middle = k != 0.0 ? curlPoint(c, k, a + 0.5 * k * (w - straight)) : bend;
|
|
2895
|
+
vec2 edge = k != 0.0 ? curlPoint(c, k, a + k * (w - straight)) : bend;
|
|
2896
|
+
|
|
2897
|
+
// anti-aliased edges, only once the page has left the frame's plane, so that it covers it exactly at both ends
|
|
2898
|
+
float aa = EDGE * min(20.0 * lift, 1.0);
|
|
2899
|
+
vec4 img = vec4(0.0);
|
|
2900
|
+
float m = 0.0;
|
|
2901
|
+
vec3 hit = hitPage(eye, dir, a, k, straight, c, w);
|
|
2902
|
+
if (hit.x > 0.0) {
|
|
2903
|
+
float t = hit.x;
|
|
2904
|
+
float u = hit.y;
|
|
2905
|
+
float b = hit.z;
|
|
2906
|
+
vec2 pt = eye + t * dir;
|
|
2907
|
+
float y = clamp(0.5 + (uv.y - 0.5) * t, 0.0, 1.0);
|
|
2908
|
+
float edgeX = edge.x * dist / max(dist - edge.y, 1e-4);
|
|
2909
|
+
m = aa > 0.0 && u > (k != 0.0 ? straight : 0.5 * w) ? clamp(abs(x - edgeX) / aa, 0.0, 1.0) : 1.0;
|
|
2910
|
+
vec2 normal = vec2(-sin(b), cos(b));
|
|
2911
|
+
bool front = dot(normal, eye - pt) > 0.0;
|
|
2912
|
+
img = front
|
|
2913
|
+
? getFromColor(vec2(clamp(w + u, w, ratio) / ratio, y))
|
|
2914
|
+
: getToColor(vec2(clamp(w - u, 0.0, w) / ratio, y));
|
|
2915
|
+
float diffuse = max(dot(front ? normal : -normal, LIGHT), 0.0) / LIGHT.y;
|
|
2916
|
+
float shade = mix(1.0, 0.25 + 0.75 * diffuse, shading);
|
|
2917
|
+
shade *= 1.0 - 0.35 * shading * lift * exp(-u / (0.04 * w));
|
|
2918
|
+
img.rgb *= shade;
|
|
2919
|
+
if (m >= 1.0) return img;
|
|
2920
|
+
}
|
|
2921
|
+
|
|
2922
|
+
vec4 color = x < 0.0 ? getFromColor(uv) : getToColor(uv);
|
|
2923
|
+
vec2 toEdge = edge - vec2(x, 0.0);
|
|
2924
|
+
float cosEdge = toEdge.x / max(length(toEdge), 1e-6);
|
|
2925
|
+
float blocked = 0.5 * abs((x < 0.0 ? 1.0 : -1.0) - cosEdge);
|
|
2926
|
+
float shadow = blocked * blocked * (3.0 - 2.0 * blocked);
|
|
2927
|
+
float slope = -LIGHT.x / LIGHT.y;
|
|
2928
|
+
vec3 reach = vec3(bend.x, middle.x, edge.x) + slope * vec3(bend.y, middle.y, edge.y);
|
|
2929
|
+
float lo = min(0.0, min(reach.x, min(reach.y, reach.z)));
|
|
2930
|
+
float hi = max(0.0, max(reach.x, max(reach.y, reach.z)));
|
|
2931
|
+
float soft = max(0.25 * edge.y, 1e-5);
|
|
2932
|
+
shadow = max(0.5 * shadow, 0.85 * clamp(min(x - lo, hi - x) / soft + 0.5, 0.0, 1.0) * min(4.0 * lift, 1.0));
|
|
2933
|
+
color.rgb *= 1.0 - shading * shadow;
|
|
2934
|
+
return mix(color, img, m);
|
|
2935
|
+
}`,"split-flap":`// Author: gre
|
|
2936
|
+
// License: MIT
|
|
2937
|
+
// Description: The frame becomes a split-flap board: in each cell the top half of the outgoing image flips down on a hinge across the middle, cell after cell, its back bringing the bottom half of the incoming image
|
|
2938
|
+
// Tags: 3d, flip, grid
|
|
2939
|
+
|
|
2940
|
+
// @param Number of cells (columns, rows)
|
|
2941
|
+
const ivec2 size = ivec2(8, 6);
|
|
2942
|
+
// @range(0, 0.9) Delay of the last cell's flip, as a part of the transition
|
|
2943
|
+
const float stagger = 0.6;
|
|
2944
|
+
// @range(0, 1) How much the order of the cells is shuffled, from a wave across the board to random
|
|
2945
|
+
const float randomness = 0.3;
|
|
2946
|
+
// @range(1, 4, 1) Number of flaps that fall in each cell, the ones before the last showing other parts of the incoming image
|
|
2947
|
+
const int flaps = 1;
|
|
2948
|
+
// @range(0, 0.05) Width of the gaps between the cells, as a part of the frame's shorter side (the hinges get half of it)
|
|
2949
|
+
const float gap = 0.004;
|
|
2950
|
+
// @range(0, 1) Amount of perspective: the falling flaps grow as they come toward the viewer
|
|
2951
|
+
const float perspective = 0.35;
|
|
2952
|
+
// @range(0, 1) How much the flaps darken as they turn away from the light, and the shadows they cast
|
|
2953
|
+
const float shading = 0.4;
|
|
2954
|
+
// @color Color seen in the gaps between the cells
|
|
2955
|
+
const vec4 background = vec4(0.0, 0.0, 0.0, 1.0);
|
|
2956
|
+
|
|
2957
|
+
const float PI = 3.141592653589793;
|
|
2958
|
+
const float EDGE = 0.001;
|
|
2959
|
+
|
|
2960
|
+
float hash12(vec2 v) {
|
|
2961
|
+
vec3 v3 = fract(vec3(v.xyx) * 0.1031);
|
|
2962
|
+
v3 += dot(v3, v3.yzx + 33.33);
|
|
2963
|
+
return fract((v3.x + v3.y) * v3.z);
|
|
2964
|
+
}
|
|
2965
|
+
|
|
2966
|
+
float cellTime(vec2 cell, vec2 grid) {
|
|
2967
|
+
float wave = (cell.x + 0.5 * (grid.y - 1.0 - cell.y)) / max(grid.x - 1.0 + 0.5 * (grid.y - 1.0), 1.0);
|
|
2968
|
+
float order = mix(wave, hash12(cell + 17.0), randomness);
|
|
2969
|
+
float delay = clamp(stagger, 0.0, 0.99);
|
|
2970
|
+
return clamp((progress - order * delay) / (1.0 - delay), 0.0, 1.0);
|
|
2971
|
+
}
|
|
2972
|
+
|
|
2973
|
+
// the card on the front of the falling flap, at the cell's flip t
|
|
2974
|
+
float flapIndex(float t, float n) {
|
|
2975
|
+
return min(floor(t * n), n - 1.0);
|
|
2976
|
+
}
|
|
2977
|
+
|
|
2978
|
+
// the falling flap's angle, 0 upright to PI down: it starts gently and lands fast
|
|
2979
|
+
float flapAngle(float t, float n) {
|
|
2980
|
+
float u = t * n - flapIndex(t, n);
|
|
2981
|
+
return PI * u * (0.3 + 0.7 * u);
|
|
2982
|
+
}
|
|
2983
|
+
|
|
2984
|
+
// card i of a cell at the point lc of the card: the outgoing image first, the incoming one last,
|
|
2985
|
+
// and in between the incoming image of another cell
|
|
2986
|
+
vec4 card(float i, float n, vec2 cell, vec2 grid, vec2 lc) {
|
|
2987
|
+
if (i < 0.5) return getFromColor((cell + lc) / grid);
|
|
2988
|
+
vec2 src = cell;
|
|
2989
|
+
if (i < n - 0.5) src = floor(vec2(hash12(cell * 3.7 + i * 11.3), hash12(cell * 5.3 + i * 7.9 + 1.7)) * grid);
|
|
2990
|
+
return getToColor((src + lc) / grid);
|
|
2991
|
+
}
|
|
2992
|
+
|
|
2993
|
+
// 1 inside a half card, 0 in the gaps: x across the card and f the distance from the hinge, in cell sizes
|
|
2994
|
+
float cardMask(float x, float f, vec2 cellSize, float g) {
|
|
2995
|
+
if (g <= 0.0) return 1.0;
|
|
2996
|
+
float e = EDGE * min(1.0, g / max(gap, 1e-4));
|
|
2997
|
+
// the gap at the hinge is half as wide as the one between the cells
|
|
2998
|
+
float d = min(min(x, 1.0 - x) * cellSize.x, min(2.0 * f, 0.5 - f) * cellSize.y);
|
|
2999
|
+
return smoothstep(0.5 * g - e, 0.5 * g + e, d);
|
|
3000
|
+
}
|
|
3001
|
+
|
|
3002
|
+
vec4 transition (vec2 uv) {
|
|
3003
|
+
vec2 grid = max(vec2(size), 1.0);
|
|
3004
|
+
float n = max(float(flaps), 1.0);
|
|
3005
|
+
vec2 cellSize = vec2(ratio, 1.0) / grid / min(ratio, 1.0);
|
|
3006
|
+
vec2 cell = floor(uv * grid);
|
|
3007
|
+
vec2 l = uv * grid - cell;
|
|
3008
|
+
float g = gap * smoothstep(0.0, 0.12, progress) * (1.0 - smoothstep(0.88, 1.0, progress));
|
|
3009
|
+
// w: height above the hinge, in cell heights
|
|
3010
|
+
float w = l.y - 0.5;
|
|
3011
|
+
bool upper = w >= 0.0;
|
|
3012
|
+
|
|
3013
|
+
// the board behind the falling flaps: the top half of the next card once the flap has left it,
|
|
3014
|
+
// the bottom half of the current card until the flap has landed on it
|
|
3015
|
+
float t = cellTime(cell, grid);
|
|
3016
|
+
float k = flapIndex(t, n);
|
|
3017
|
+
float a = flapAngle(t, n);
|
|
3018
|
+
bool started = t * n > k;
|
|
3019
|
+
bool landed = t >= 1.0;
|
|
3020
|
+
vec4 color = card(k + (upper ? (started ? 1.0 : 0.0) : (landed ? 1.0 : 0.0)), n, cell, grid, l);
|
|
3021
|
+
if (started && !landed) color.rgb *= 1.0 - 0.45 * shading * max(upper ? cos(a) : -cos(a), 0.0);
|
|
3022
|
+
color = mix(background, color, cardMask(l.x, abs(w), cellSize, g));
|
|
3023
|
+
|
|
3024
|
+
// the falling flaps of this cell and of its neighbors, which grow beyond their cells as they come closer
|
|
3025
|
+
float nearest = -1.0;
|
|
3026
|
+
for (int d = -1; d <= 1; d++) {
|
|
3027
|
+
vec2 nc = cell + vec2(float(d), 0.0);
|
|
3028
|
+
if (nc.x < 0.0 || nc.x > grid.x - 1.0) continue;
|
|
3029
|
+
float nt = d == 0 ? t : cellTime(nc, grid);
|
|
3030
|
+
float na = d == 0 ? a : flapAngle(nt, n);
|
|
3031
|
+
float fc = cos(na);
|
|
3032
|
+
float fs = sin(na);
|
|
3033
|
+
// a point at distance f from the hinge is at height f * fc and depth f * fs, nearer points look wider
|
|
3034
|
+
if (abs(fc) < 1e-5 || (w >= 0.0) != (fc > 0.0)) continue;
|
|
3035
|
+
float f = w / fc;
|
|
3036
|
+
if (f > 0.5) continue;
|
|
3037
|
+
float z = f * fs;
|
|
3038
|
+
if (z <= nearest) continue;
|
|
3039
|
+
float lx = 0.5 + (l.x - float(d) - 0.5) * (1.0 - perspective * z);
|
|
3040
|
+
if (lx < 0.0 || lx > 1.0) continue;
|
|
3041
|
+
bool front = fc > 0.0;
|
|
3042
|
+
vec2 lc = vec2(lx, front ? 0.5 + f : 0.5 - f);
|
|
3043
|
+
float m = cardMask(lx, f, cellSize, g);
|
|
3044
|
+
if (m <= 0.0) continue;
|
|
3045
|
+
vec4 img = card(flapIndex(nt, n) + (front ? 0.0 : 1.0), n, nc, grid, lc);
|
|
3046
|
+
float lambert = (front ? 0.92 * fc - 0.4 * fs : 0.4 * fs - 0.92 * fc) / 0.92;
|
|
3047
|
+
img.rgb *= mix(1.0 - shading, 1.0, clamp(lambert, 0.0, 1.0));
|
|
3048
|
+
color = mix(color, img, m);
|
|
3049
|
+
nearest = z;
|
|
3050
|
+
}
|
|
3051
|
+
return color;
|
|
3052
|
+
}`,disintegrate:`// Author: gre
|
|
3053
|
+
// License: MIT
|
|
3054
|
+
// Description: The outgoing image crumbles into fine dust from one side, its grains blown away by the wind and fading out, revealing the incoming image underneath
|
|
3055
|
+
// Tags: particles, dust, wind, directional
|
|
3056
|
+
|
|
3057
|
+
// @range(0.0075, 0.03) Size of the dust grains, in frame heights
|
|
3058
|
+
const float particleSize = 0.008;
|
|
3059
|
+
// @param Direction in which the wind blows the dust
|
|
3060
|
+
const vec2 direction = vec2(1.0, -0.15);
|
|
3061
|
+
// @range(0, 1) How far the dust flies and scatters before it fades out
|
|
3062
|
+
const float spread = 0.75;
|
|
3063
|
+
|
|
3064
|
+
// the grains a pixel looks back to, along the wind: every grain up to 16 cells away,
|
|
3065
|
+
// one in 2 up to 32 cells, one in 4 up to 64 cells (only those stay visible that far,
|
|
3066
|
+
// so the dust thins out as it flies): 35 candidates, without unrolling a long loop
|
|
3067
|
+
const int NEAR = 17;
|
|
3068
|
+
const int CANDIDATES = 35;
|
|
3069
|
+
const float LIFE = 0.45;
|
|
3070
|
+
|
|
3071
|
+
float hash12(vec2 p) {
|
|
3072
|
+
vec3 p3 = fract(vec3(p.xyx) * 0.1031);
|
|
3073
|
+
p3 += dot(p3, p3.yzx + 33.33);
|
|
3074
|
+
return fract((p3.x + p3.y) * p3.z);
|
|
3075
|
+
}
|
|
3076
|
+
|
|
3077
|
+
float noise(vec2 p) {
|
|
3078
|
+
vec2 i = floor(p);
|
|
3079
|
+
vec2 f = fract(p);
|
|
3080
|
+
f = f * f * (3.0 - 2.0 * f);
|
|
3081
|
+
float a = hash12(i);
|
|
3082
|
+
float b = hash12(i + vec2(1.0, 0.0));
|
|
3083
|
+
float c = hash12(i + vec2(0.0, 1.0));
|
|
3084
|
+
float d = hash12(i + vec2(1.0, 1.0));
|
|
3085
|
+
return 2.0 * mix(mix(a, b, f.x), mix(c, d, f.x), f.y) - 1.0;
|
|
3086
|
+
}
|
|
3087
|
+
|
|
3088
|
+
// the grains' sideways drift, in gusts along the wind, between -1 and 1: it depends only
|
|
3089
|
+
// on where a grain comes from along the wind, so that a pixel knows which row to look in
|
|
3090
|
+
float gust(float x) {
|
|
3091
|
+
float i = floor(x);
|
|
3092
|
+
float f = fract(x);
|
|
3093
|
+
f = f * f * (3.0 - 2.0 * f);
|
|
3094
|
+
return 2.0 * mix(hash12(vec2(i, 7.0)), hash12(vec2(i + 1.0, 7.0)), f) - 1.0;
|
|
3095
|
+
}
|
|
3096
|
+
|
|
3097
|
+
// when the grain at center (in cells) is released: downwind side first, along a ragged front
|
|
3098
|
+
float release(vec2 center, float h, float halfLength, float s) {
|
|
3099
|
+
float front = 1.0 - (center.x + halfLength) / (2.0 * halfLength) + 0.14 * noise(center * s * 6.0) + 0.08 * (h - 0.5);
|
|
3100
|
+
return clamp((front + 0.12) / 1.24, 0.0, 1.0) * (1.0 - LIFE);
|
|
3101
|
+
}
|
|
3102
|
+
|
|
3103
|
+
vec4 transition(vec2 uv) {
|
|
3104
|
+
vec2 d = length(direction) > 0.0 ? normalize(direction) : vec2(1.0, 0.0);
|
|
3105
|
+
vec2 n = vec2(-d.y, d.x);
|
|
3106
|
+
vec2 fp = (uv - 0.5) * vec2(ratio, 1.0);
|
|
3107
|
+
float s = particleSize;
|
|
3108
|
+
vec2 g = vec2(dot(fp, d), dot(fp, n)) / s;
|
|
3109
|
+
float halfLength = 0.5 * (ratio * abs(d.x) + abs(d.y)) / s;
|
|
3110
|
+
// the longest flight, in cells (at most 60, within the 64 cells looked back to)
|
|
3111
|
+
float reach = min(spread * 0.45 / s, 60.0);
|
|
3112
|
+
float px = floor(g.x);
|
|
3113
|
+
|
|
3114
|
+
vec2 own = floor(g);
|
|
3115
|
+
vec4 under = progress > release(own + 0.5, hash12(own), halfLength, s) ? getToColor(uv) : getFromColor(uv);
|
|
3116
|
+
vec2 grainUV = vec2(0.5);
|
|
3117
|
+
float cover = 0.0;
|
|
3118
|
+
for (int i = 0; i < CANDIDATES; i++) {
|
|
3119
|
+
float fi = float(i);
|
|
3120
|
+
float cx = px - fi;
|
|
3121
|
+
if (i >= NEAR + 9) {
|
|
3122
|
+
cx = floor(px / 4.0) * 4.0 - 4.0 * (fi - float(NEAR + 9) + 8.0);
|
|
3123
|
+
} else if (i >= NEAR) {
|
|
3124
|
+
cx = floor(px / 2.0) * 2.0 - 2.0 * (fi - float(NEAR) + 8.0);
|
|
3125
|
+
}
|
|
3126
|
+
// how far the grain stays visible (in cells): further when its column is a multiple
|
|
3127
|
+
// of 2, and of 4, as far as the pixels look back to
|
|
3128
|
+
float visible = mod(cx, 4.0) < 0.5 ? 63.0 : mod(cx, 2.0) < 0.5 ? 31.0 : 15.0;
|
|
3129
|
+
float drift = 0.3 * gust(cx * s * 4.0);
|
|
3130
|
+
// the row the grain comes from: its sideways drift is known from its column and how
|
|
3131
|
+
// far it has flown to get here
|
|
3132
|
+
vec2 cell = vec2(cx, floor(g.y - drift * (g.x - cx - 0.5)));
|
|
3133
|
+
vec2 center = cell + 0.5;
|
|
3134
|
+
vec2 cuv = (center.x * d + center.y * n) * s / vec2(ratio, 1.0) + 0.5;
|
|
3135
|
+
if (cuv.x < 0.0 || cuv.x > 1.0 || cuv.y < 0.0 || cuv.y > 1.0) continue;
|
|
3136
|
+
float h = hash12(cell);
|
|
3137
|
+
float t = (progress - release(center, h, halfLength, s)) / LIFE;
|
|
3138
|
+
if (t <= 0.0 || t >= 1.0) continue;
|
|
3139
|
+
float r2 = fract(h * 13.7);
|
|
3140
|
+
float travel = reach * (0.4 + 0.6 * r2) * t * (0.2 + 0.8 * t);
|
|
3141
|
+
float crumble = smoothstep(0.0, 0.25, t);
|
|
3142
|
+
vec2 pos = center + vec2(travel + (fract(h * 71.1) - 0.5) * 0.3 * crumble, drift * travel);
|
|
3143
|
+
vec2 local = abs(g - pos);
|
|
3144
|
+
float size = mix(0.5, 0.3 * (1.0 - 0.5 * t) * (0.6 + 0.4 * h), crumble);
|
|
3145
|
+
float feather = 0.001 + 0.12 * crumble;
|
|
3146
|
+
float a = (1.0 - smoothstep(size - feather, size, max(local.x, local.y))) * (1.0 - smoothstep(0.15, 1.0, t))
|
|
3147
|
+
* (1.0 - smoothstep(0.6 * visible, visible, travel));
|
|
3148
|
+
if (a > cover) {
|
|
3149
|
+
cover = a;
|
|
3150
|
+
grainUV = cuv;
|
|
3151
|
+
}
|
|
3152
|
+
}
|
|
3153
|
+
return mix(under, getFromColor(grainUV), cover);
|
|
3154
|
+
}`,vaporize:`// Author: gre
|
|
3155
|
+
// License: MIT
|
|
3156
|
+
// Description: The outgoing image goes up in smoke: from one side, the picture itself turns to vapour that rises over what is still intact, curls into wisps and pales as it thins out, revealing the incoming image underneath
|
|
3157
|
+
// Tags: smoke, organic, noise, directional, reveal
|
|
3158
|
+
|
|
3159
|
+
// @param Direction the vapour rises toward (the image starts turning to vapour on the opposite side)
|
|
3160
|
+
const vec2 direction = vec2(0.0, 1.0);
|
|
3161
|
+
// @range(0.1, 0.6) How high the vapour rises above the image before it is gone, in frame heights
|
|
3162
|
+
const float rise = 0.4;
|
|
3163
|
+
// @range(0, 1) How much the vapour swirls and curls as it rises
|
|
3164
|
+
const float swirl = 0.6;
|
|
3165
|
+
// @color Color the vapour pales to as it thins out
|
|
3166
|
+
const vec4 color = vec4(0.92, 0.92, 0.94, 1.0);
|
|
3167
|
+
|
|
3168
|
+
// raggedness of the line where the image turns to vapour, and the width over which it dissolves
|
|
3169
|
+
const float RAGGED = 0.09;
|
|
3170
|
+
const float BAND = 0.12;
|
|
3171
|
+
const float LIFE = 0.16;
|
|
3172
|
+
const int TAPS = 6;
|
|
3173
|
+
|
|
3174
|
+
float hash12(vec2 p) {
|
|
3175
|
+
vec3 p3 = fract(vec3(p.xyx) * 0.1031);
|
|
3176
|
+
p3 += dot(p3, p3.yzx + 33.33);
|
|
3177
|
+
return fract((p3.x + p3.y) * p3.z);
|
|
3178
|
+
}
|
|
3179
|
+
|
|
3180
|
+
float vnoise(vec2 p) {
|
|
3181
|
+
vec2 i = floor(p);
|
|
3182
|
+
vec2 f = fract(p);
|
|
3183
|
+
f = f * f * (3.0 - 2.0 * f);
|
|
3184
|
+
return mix(
|
|
3185
|
+
mix(hash12(i), hash12(i + vec2(1.0, 0.0)), f.x),
|
|
3186
|
+
mix(hash12(i + vec2(0.0, 1.0)), hash12(i + vec2(1.0, 1.0)), f.x),
|
|
3187
|
+
f.y
|
|
3188
|
+
);
|
|
3189
|
+
}
|
|
3190
|
+
|
|
3191
|
+
float fbm(vec2 p) {
|
|
3192
|
+
return 0.55 * vnoise(p) + 0.3 * vnoise(p * 2.03 + 5.1) + 0.15 * vnoise(p * 4.1 + 9.7);
|
|
3193
|
+
}
|
|
3194
|
+
|
|
3195
|
+
// a swirling flow without sources or sinks: the curl of a noise field
|
|
3196
|
+
vec2 curl(vec2 p) {
|
|
3197
|
+
float e = 0.1;
|
|
3198
|
+
float n = vnoise(p);
|
|
3199
|
+
float nx = vnoise(p + vec2(e, 0.0));
|
|
3200
|
+
float ny = vnoise(p + vec2(0.0, e));
|
|
3201
|
+
return vec2(ny - n, n - nx) / e;
|
|
3202
|
+
}
|
|
3203
|
+
|
|
3204
|
+
// where the line is at time t, as a part of its way across: quicker through the margins
|
|
3205
|
+
// outside the frame, slower across it
|
|
3206
|
+
float sweep(float t) {
|
|
3207
|
+
return t + 0.6 * t * (1.0 - t) * (1.0 - 2.0 * t);
|
|
3208
|
+
}
|
|
3209
|
+
|
|
3210
|
+
vec2 mirror(vec2 v) {
|
|
3211
|
+
return 1.0 - abs(1.0 - mod(v, 2.0));
|
|
3212
|
+
}
|
|
3213
|
+
|
|
3214
|
+
vec4 transition(vec2 uv) {
|
|
3215
|
+
vec2 dir = length(direction) > 0.0 ? normalize(direction) : vec2(0.0, 1.0);
|
|
3216
|
+
vec2 side = vec2(-dir.y, dir.x);
|
|
3217
|
+
vec2 q = (uv - 0.5) * vec2(ratio, 1.0);
|
|
3218
|
+
float along = dot(q, dir);
|
|
3219
|
+
float across = dot(q, side);
|
|
3220
|
+
float ext = 0.5 * (abs(dir.x) * ratio + abs(dir.y));
|
|
3221
|
+
|
|
3222
|
+
float ragged = RAGGED * (2.0 * fbm(q * 2.5 + 1.3) - 1.0);
|
|
3223
|
+
float start = -ext - RAGGED;
|
|
3224
|
+
float travel = 2.0 * ext + 2.0 * RAGGED + BAND;
|
|
3225
|
+
float front = start + travel * sweep(progress) + ragged;
|
|
3226
|
+
|
|
3227
|
+
float gone = smoothstep(0.0, BAND, front - along);
|
|
3228
|
+
vec4 base = mix(getFromColor(uv), getToColor(uv), gone);
|
|
3229
|
+
|
|
3230
|
+
// the vapour above the line: the higher it is, the longer ago it left the image
|
|
3231
|
+
float height = max(rise, 0.05) * (0.7 + 0.6 * vnoise(vec2(across * 3.0 + 2.7, 0.5)));
|
|
3232
|
+
float age = (along - front) / height;
|
|
3233
|
+
float released = progress - age * LIFE;
|
|
3234
|
+
if (age <= 0.0 || age >= 1.0 || released <= 0.0) return base;
|
|
3235
|
+
|
|
3236
|
+
// where it came from: the line, back when it was released
|
|
3237
|
+
float origin = start + travel * sweep(released) + ragged;
|
|
3238
|
+
vec2 org = q - dir * (along - origin);
|
|
3239
|
+
|
|
3240
|
+
vec2 sw = curl(org * 3.0 + dir * progress * 1.5) * (swirl * 0.08 * sqrt(age));
|
|
3241
|
+
vec2 src = org - sw;
|
|
3242
|
+
|
|
3243
|
+
vec2 spreadOut = (side * 0.07 + dir * 0.02) * sqrt(age);
|
|
3244
|
+
vec4 c = vec4(0.0);
|
|
3245
|
+
for (int i = 0; i < TAPS; i++) {
|
|
3246
|
+
float t = float(i) / float(TAPS - 1) - 0.5;
|
|
3247
|
+
vec4 img = getFromColor(mirror((src + spreadOut * t) / vec2(ratio, 1.0) + 0.5));
|
|
3248
|
+
c += vec4(img.rgb * img.a, img.a);
|
|
3249
|
+
}
|
|
3250
|
+
c = c.a > 0.0 ? vec4(c.rgb / c.a, c.a / float(TAPS)) : vec4(0.0);
|
|
3251
|
+
|
|
3252
|
+
vec2 wq = (q - 0.6 * sw - dir * (progress * 2.5)) * 4.0;
|
|
3253
|
+
float w = fbm(vec2(dot(wq, side), dot(wq, dir) * 0.6) + 2.0);
|
|
3254
|
+
float density = smoothstep(1.2 * age - 0.2, 1.2 * age + 0.1, w);
|
|
3255
|
+
density *= 1.0 - smoothstep(0.3, 1.0, age);
|
|
3256
|
+
// (only the image turns to vapour, not what lies beyond its edge)
|
|
3257
|
+
density *= smoothstep(-ext, -ext + 0.05, origin);
|
|
3258
|
+
|
|
3259
|
+
float pale = smoothstep(0.0, 0.5, age);
|
|
3260
|
+
float l = dot(c.rgb, vec3(0.299, 0.587, 0.114));
|
|
3261
|
+
c = mix(c, vec4(mix(vec3(l), color.rgb, 0.7), c.a * color.a), pale * 0.85);
|
|
3262
|
+
c.rgb = min(c.rgb + 0.12 * pale * density * (1.0 - density), vec3(1.0));
|
|
3263
|
+
float a = density * c.a;
|
|
3264
|
+
float outA = a + base.a * (1.0 - a);
|
|
3265
|
+
if (outA <= 0.0) return vec4(0.0);
|
|
3266
|
+
return vec4((c.rgb * a + base.rgb * base.a * (1.0 - a)) / outA, outA);
|
|
3267
|
+
}`,"light-rays":`// Author: gre
|
|
3268
|
+
// License: MIT
|
|
3269
|
+
// Description: Shafts of light burst from the highlights of the outgoing image and stream outward from a slowly drifting center; at their peak the incoming image takes over and its own rays shrink back into its highlights
|
|
3270
|
+
// Tags: light, glow, rays, radial
|
|
3271
|
+
|
|
3272
|
+
// @param Point the rays stream away from, at the middle of the transition
|
|
3273
|
+
const vec2 center = vec2(0.5, 0.6);
|
|
3274
|
+
// @range(0, 0.5) How far the center drifts during the transition, from left to right
|
|
3275
|
+
const float drift = 0.15;
|
|
3276
|
+
// @range(0, 1) Length of the rays at the peak, as a fraction of their distance to the center
|
|
3277
|
+
const float reach = 0.6;
|
|
3278
|
+
// @range(0, 0.8) Brightness above which the image casts rays
|
|
3279
|
+
const float threshold = 0.65;
|
|
3280
|
+
// @range(0, 4) Brightness of the rays
|
|
3281
|
+
const float intensity = 1.5;
|
|
3282
|
+
// @color Tint of the rays, toward their ends
|
|
3283
|
+
const vec3 tint = vec3(1.0, 0.82, 0.55);
|
|
3284
|
+
|
|
3285
|
+
const int TAPS = 20;
|
|
3286
|
+
const float SHAFTS = 23.0;
|
|
3287
|
+
const float PI = 3.141592653589793;
|
|
3288
|
+
|
|
3289
|
+
float hash12(vec2 v) {
|
|
3290
|
+
vec3 v3 = fract(vec3(v.xyx) * 0.1031);
|
|
3291
|
+
v3 += dot(v3, v3.yzx + 33.33);
|
|
3292
|
+
return fract((v3.x + v3.y) * v3.z);
|
|
3293
|
+
}
|
|
3294
|
+
|
|
3295
|
+
// smooth noise around the center, wrapping over a full turn (t in 0..1)
|
|
3296
|
+
float shaftNoise(float t, float n, float seed) {
|
|
3297
|
+
float x = t * n;
|
|
3298
|
+
float i = floor(x);
|
|
3299
|
+
float f = x - i;
|
|
3300
|
+
float a = hash12(vec2(mod(i, n), seed));
|
|
3301
|
+
float b = hash12(vec2(mod(i + 1.0, n), seed));
|
|
3302
|
+
return mix(a, b, f * f * (3.0 - 2.0 * f));
|
|
3303
|
+
}
|
|
3304
|
+
|
|
3305
|
+
vec2 mirror(vec2 v) {
|
|
3306
|
+
return 1.0 - abs(1.0 - mod(v, 2.0));
|
|
3307
|
+
}
|
|
3308
|
+
|
|
3309
|
+
vec3 glow(vec4 c, float knee) {
|
|
3310
|
+
float lum = dot(c.rgb, vec3(0.2126, 0.7152, 0.0722));
|
|
3311
|
+
return c.rgb * c.a * smoothstep(knee, knee + 0.2, lum);
|
|
3312
|
+
}
|
|
3313
|
+
|
|
3314
|
+
vec3 light(vec2 st, float knee, float m) {
|
|
3315
|
+
if (m <= 0.0) return glow(getFromColor(st), knee);
|
|
3316
|
+
if (m >= 1.0) return glow(getToColor(st), knee);
|
|
3317
|
+
return mix(glow(getFromColor(st), knee), glow(getToColor(st), knee), m);
|
|
3318
|
+
}
|
|
3319
|
+
|
|
3320
|
+
vec4 transition(vec2 uv) {
|
|
3321
|
+
float p = progress;
|
|
3322
|
+
float amount = p < 0.5 ? smoothstep(0.0, 0.5, p) : 1.0 - smoothstep(0.5, 1.0, p);
|
|
3323
|
+
float peak = amount * amount * amount;
|
|
3324
|
+
float m = smoothstep(0.46, 0.54, p);
|
|
3325
|
+
vec4 fromColor = getFromColor(uv);
|
|
3326
|
+
vec4 toColor = getToColor(uv);
|
|
3327
|
+
if (amount <= 0.0) return m < 0.5 ? fromColor : toColor;
|
|
3328
|
+
|
|
3329
|
+
vec2 origin = center + vec2(drift * (p - 0.5), 0.0);
|
|
3330
|
+
float len = reach * amount;
|
|
3331
|
+
float knee = mix(threshold, 0.75 * threshold, peak);
|
|
3332
|
+
// a small shift of the taps, under their spacing, blends them into smooth shafts;
|
|
3333
|
+
// hashed by integer cell so that every GPU computes the same shift
|
|
3334
|
+
float jitter = hash12(floor(uv * vec2(ratio, 1.0) * 997.0));
|
|
3335
|
+
|
|
3336
|
+
vec3 rays = vec3(0.0);
|
|
3337
|
+
float total = 0.0;
|
|
3338
|
+
for (int i = 0; i < TAPS; i++) {
|
|
3339
|
+
float s = (float(i) + jitter) / float(TAPS);
|
|
3340
|
+
float w = exp(-2.0 * s);
|
|
3341
|
+
vec3 hue = mix(vec3(1.0), tint, smoothstep(0.0, 0.6, s));
|
|
3342
|
+
rays += w * hue * light(mirror(mix(uv, origin, s * len)), knee, m);
|
|
3343
|
+
total += w;
|
|
3344
|
+
}
|
|
3345
|
+
vec2 d = (uv - origin) * vec2(ratio, 1.0);
|
|
3346
|
+
// atan is undefined at the center itself
|
|
3347
|
+
float turn = length(d) > 1e-6 ? atan(d.y, d.x) / (2.0 * PI) + 0.5 : 0.0;
|
|
3348
|
+
float shafts = 0.6 * shaftNoise(fract(turn + 0.03 * p), SHAFTS, 1.0) + 0.4 * shaftNoise(fract(turn - 0.05 * p), 2.0 * SHAFTS + 1.0, 7.0);
|
|
3349
|
+
// merged back into a soft glow close to the center, where the shafts would meet in a point
|
|
3350
|
+
rays *= mix(1.0, mix(0.2, 1.6, smoothstep(0.15, 0.85, shafts)), smoothstep(0.0, 0.3, length(d)));
|
|
3351
|
+
rays *= intensity * amount * (1.0 + 3.0 * peak) / total;
|
|
3352
|
+
// compressed, so that bright areas never flatten into white
|
|
3353
|
+
rays = 0.9 * (1.0 - exp(-rays));
|
|
3354
|
+
|
|
3355
|
+
// the image stays sharp, with a slight lift at the peak; the rays are screened on top and add nothing to its alpha
|
|
3356
|
+
vec4 c = mix(vec4(fromColor.rgb * fromColor.a, fromColor.a), vec4(toColor.rgb * toColor.a, toColor.a), m);
|
|
3357
|
+
if (c.a <= 0.0) return vec4(0.0);
|
|
3358
|
+
vec3 base = min(c.rgb / c.a * (1.0 + 0.2 * peak), 1.0);
|
|
3359
|
+
return vec4(base + rays - base * rays, c.a);
|
|
3360
|
+
}`,prisms:`// Author: gre
|
|
3361
|
+
// License: MIT
|
|
3362
|
+
// Description: The frame is cut into 3D prisms that turn in a cascade, like a rotating billboard, from the outgoing image on one face to the incoming one on the next
|
|
3363
|
+
// Tags: 3d, rotate, stripes
|
|
3364
|
+
|
|
3365
|
+
// @range(2, 40, 1) Number of prisms
|
|
3366
|
+
const int slats = 8;
|
|
3367
|
+
// @range(0, 0.9) Delay of the last prism's turn, as a part of the transition
|
|
3368
|
+
const float stagger = 0.45;
|
|
3369
|
+
// @range(0, 4) Amount of perspective
|
|
3370
|
+
const float perspective = 1.0;
|
|
3371
|
+
// @range(0, 1) How much the faces darken as they turn away
|
|
3372
|
+
const float shading = 0.6;
|
|
3373
|
+
// @param Cut the frame into horizontal prisms instead
|
|
3374
|
+
const bool horizontal = false;
|
|
3375
|
+
// @color Color seen where the turning prisms leave the frame uncovered
|
|
3376
|
+
const vec4 backColor = vec4(0.0, 0.0, 0.0, 1.0);
|
|
3377
|
+
|
|
3378
|
+
const float PI = 3.141592653589793;
|
|
3379
|
+
const float EDGE = 0.002;
|
|
3380
|
+
|
|
3381
|
+
vec4 transition (vec2 uv) {
|
|
3382
|
+
float n = float(slats);
|
|
3383
|
+
// a: the axis across the prisms, b: the axis they turn around
|
|
3384
|
+
float a = horizontal ? uv.y : uv.x;
|
|
3385
|
+
float b = horizontal ? uv.x : uv.y;
|
|
3386
|
+
// the prisms' half width in frame heights, and the perspective from their depth
|
|
3387
|
+
float hw = 0.5 / n * (horizontal ? 1.0 : ratio);
|
|
3388
|
+
float k = min(perspective * hw, 0.5);
|
|
3389
|
+
float bScale = horizontal ? ratio : 1.0;
|
|
3390
|
+
// a turning prism is wider than its strip: keep the two nearest faces
|
|
3391
|
+
vec4 near1 = vec4(0.0), near2 = vec4(0.0);
|
|
3392
|
+
float cover1 = 0.0, cover2 = 0.0;
|
|
3393
|
+
float z1 = -2.0, z2 = -2.0;
|
|
3394
|
+
for (int d = -1; d <= 1; d++) {
|
|
3395
|
+
float i = floor(a * n) + float(d);
|
|
3396
|
+
if (i < 0.0 || i > n - 1.0) continue;
|
|
3397
|
+
float order = (horizontal ? n - 1.0 - i : i) / (n - 1.0);
|
|
3398
|
+
float t = clamp((progress - stagger * order) / (1.0 - stagger), 0.0, 1.0);
|
|
3399
|
+
t = mix(t, t * t * (3.0 - 2.0 * t), 0.7);
|
|
3400
|
+
float c = cos(0.5 * PI * t);
|
|
3401
|
+
float s = sin(0.5 * PI * t);
|
|
3402
|
+
// soft edges while turning (sharp at rest, to keep the first and last frames exact)
|
|
3403
|
+
float edge = EDGE * min(1.0, 20.0 * s * c) + 1e-6;
|
|
3404
|
+
// x: position across the strip, -1 to 1; the prism's square section has its faces at distance 1
|
|
3405
|
+
float x = 2.0 * (a * n - i) - 1.0;
|
|
3406
|
+
for (int f = 0; f < 2; f++) {
|
|
3407
|
+
// f = 0: the outgoing face turning away, f = 1: the incoming face turning in
|
|
3408
|
+
float cf = f == 0 ? c : s;
|
|
3409
|
+
if (cf < 1e-4) continue;
|
|
3410
|
+
// u: position on the face, z: depth (1 for a face at rest)
|
|
3411
|
+
float u = f == 0 ? (x + s) / c : (x - c) / s;
|
|
3412
|
+
float z = f == 0 ? u * s + c : s - u * c;
|
|
3413
|
+
if (abs(u) > 1.0 || z <= z2) continue;
|
|
3414
|
+
float scale = 1.0 - k * (z - 1.0);
|
|
3415
|
+
float y = (b - 0.5) * scale + 0.5;
|
|
3416
|
+
if (y < 0.0 || y > 1.0) continue;
|
|
3417
|
+
// soften the outer edges only: the faces meet at the prism's corner
|
|
3418
|
+
float outer = f == 0 ? 1.0 + u : 1.0 - u;
|
|
3419
|
+
float cover = clamp(outer * hw * cf / edge, 0.0, 1.0)
|
|
3420
|
+
* clamp(min(y, 1.0 - y) * bScale / scale / edge, 0.0, 1.0);
|
|
3421
|
+
float sa = (i + 0.5 + 0.5 * u) / n;
|
|
3422
|
+
vec2 p = horizontal ? vec2(y, sa) : vec2(sa, y);
|
|
3423
|
+
vec4 img = f == 0 ? getFromColor(p) : getToColor(p);
|
|
3424
|
+
float lambert = clamp(f == 0 ? c - 0.6 * s : s + 0.6 * c, 0.0, 1.0);
|
|
3425
|
+
vec4 color = vec4(img.rgb * mix(1.0 - shading, 1.0, lambert), img.a);
|
|
3426
|
+
if (z > z1) {
|
|
3427
|
+
near2 = near1; cover2 = cover1; z2 = z1;
|
|
3428
|
+
near1 = color; cover1 = cover; z1 = z;
|
|
3429
|
+
} else {
|
|
3430
|
+
near2 = color; cover2 = cover; z2 = z;
|
|
3431
|
+
}
|
|
3432
|
+
}
|
|
3433
|
+
}
|
|
3434
|
+
return mix(mix(backColor, near2, cover2), near1, cover1);
|
|
3435
|
+
}`,"reeded-glass":`// Author: gre
|
|
3436
|
+
// License: MIT
|
|
3437
|
+
// Description: A wide pane of reeded glass slides across the frame: behind its rounded vertical ribs the picture breaks into narrow, flipped and squeezed slices with faint color fringes, the outgoing image on the far side of the pane and the incoming one behind it, and where the pane has passed the incoming image is left clear
|
|
3438
|
+
// Tags: glass, refraction, stripes, wipe
|
|
3439
|
+
|
|
3440
|
+
// @range(0.1, 1) Width of the pane, in frame widths
|
|
3441
|
+
const float paneWidth = 0.55;
|
|
3442
|
+
// @range(4, 60) Number of ribs across the frame width
|
|
3443
|
+
const float ribs = 20.0;
|
|
3444
|
+
// @range(0, 2) How strongly each rib flips and squeezes the slice behind it
|
|
3445
|
+
const float strength = 1.0;
|
|
3446
|
+
// @range(0, 1) Strength of the highlights, seams and shadow of the glass
|
|
3447
|
+
const float shine = 0.6;
|
|
3448
|
+
|
|
3449
|
+
const float AA = 0.002;
|
|
3450
|
+
// width of the pane's shadow, in frame heights
|
|
3451
|
+
const float SHADOW = 0.03;
|
|
3452
|
+
|
|
3453
|
+
vec2 mirror(vec2 v) {
|
|
3454
|
+
return 1.0 - abs(1.0 - mod(v, 2.0));
|
|
3455
|
+
}
|
|
3456
|
+
|
|
3457
|
+
vec4 behind(float x, float y, float cut, float soft) {
|
|
3458
|
+
vec2 p = mirror(vec2(x, y));
|
|
3459
|
+
return mix(getToColor(p), getFromColor(p), smoothstep(cut - soft, cut + soft, x));
|
|
3460
|
+
}
|
|
3461
|
+
|
|
3462
|
+
vec4 transition(vec2 uv) {
|
|
3463
|
+
float pw = clamp(paneWidth, 0.05, 1.0);
|
|
3464
|
+
float t = mix(progress, progress * progress * (3.0 - 2.0 * progress), 0.6);
|
|
3465
|
+
// the pane starts and ends far enough off frame that its shadow is off frame too
|
|
3466
|
+
float margin = SHADOW / ratio + 0.005;
|
|
3467
|
+
float left = mix(-pw - margin, 1.0 + margin, t);
|
|
3468
|
+
float right = left + pw;
|
|
3469
|
+
float cut = left + 0.5 * pw;
|
|
3470
|
+
float x = uv.x;
|
|
3471
|
+
|
|
3472
|
+
float rw = pw / max(floor(pw * ribs + 0.5), 1.0);
|
|
3473
|
+
float r = (x - left) / rw;
|
|
3474
|
+
float u = 2.0 * fract(r) - 1.0;
|
|
3475
|
+
// strength 0 leaves the image as is; from about 0.25 each rib flips the slice behind it
|
|
3476
|
+
float bend = rw * strength * (0.5 * u + 1.6 * u * sqrt(1.0 - 0.6 * u * u));
|
|
3477
|
+
float soft = 0.5 * rw;
|
|
3478
|
+
float disp = 0.05 * strength;
|
|
3479
|
+
vec4 g = behind(x - bend, uv.y, cut, soft);
|
|
3480
|
+
vec4 c = vec4(
|
|
3481
|
+
behind(x - bend * (1.0 + disp), uv.y, cut, soft).r,
|
|
3482
|
+
g.g,
|
|
3483
|
+
behind(x - bend * (1.0 - disp), uv.y, cut, soft).b,
|
|
3484
|
+
g.a
|
|
3485
|
+
);
|
|
3486
|
+
|
|
3487
|
+
float seam = smoothstep(0.82, 1.0, abs(u));
|
|
3488
|
+
float hl = (u + 0.45) / 0.16;
|
|
3489
|
+
float rim = 1.0 - smoothstep(0.0, 0.006, min(x - left, right - x) * ratio);
|
|
3490
|
+
vec3 lit = c.rgb * (1.0 - shine * (0.08 * u + 0.45 * seam + 0.4 * rim));
|
|
3491
|
+
lit += shine * (0.22 * exp(-hl * hl) + 0.05) * c.a;
|
|
3492
|
+
c.rgb = mix(lit, vec3(0.93, 0.96, 0.97) * c.a, 0.05 * shine);
|
|
3493
|
+
|
|
3494
|
+
float inside = smoothstep(left - AA, left + AA, x) * (1.0 - smoothstep(right - AA, right + AA, x));
|
|
3495
|
+
vec4 clear = x < cut ? getToColor(uv) : getFromColor(uv);
|
|
3496
|
+
float shadow = 0.2 * shine * smoothstep(right - AA, right + AA, x) * (1.0 - smoothstep(0.0, SHADOW, (x - right) * ratio));
|
|
3497
|
+
clear.rgb *= 1.0 - shadow;
|
|
3498
|
+
return mix(clear, c, inside);
|
|
3499
|
+
}`,swim:`// Author: gre
|
|
3500
|
+
// License: MIT
|
|
3501
|
+
// Description: The outgoing image turns into a fish and swims out of the frame head first: its body narrows into a forked tail, a bending wave runs from its head to its tail and swings wider beat by beat, lighting and shading its flanks as it bends and driving it faster until it is gone, revealing the incoming image under its soft shadow
|
|
3502
|
+
// Tags: organic, swim, wave, bend, directional, shadow
|
|
3503
|
+
|
|
3504
|
+
// @range(0.0, 0.25) How far the tail swings, as a part of the frame's short side
|
|
3505
|
+
const float swing = 0.12;
|
|
3506
|
+
// @range(1.0, 4.0) Number of tail beats
|
|
3507
|
+
const float beats = 2.5;
|
|
3508
|
+
// @range(0.0, 0.9) How much the body narrows toward the tail
|
|
3509
|
+
const float taper = 0.65;
|
|
3510
|
+
// @range(0.0, 1.0) Strength of the shading on the bends and of the shadow
|
|
3511
|
+
const float shading = 0.7;
|
|
3512
|
+
|
|
3513
|
+
const float PI = 3.141592653589793;
|
|
3514
|
+
const float AA = 0.003;
|
|
3515
|
+
const float HEAD = 0.38;
|
|
3516
|
+
const float PEDUNCLE = 0.8;
|
|
3517
|
+
const float FORK = 0.17;
|
|
3518
|
+
const float K = 2.0 * PI * 0.8;
|
|
3519
|
+
|
|
3520
|
+
float wave(float u, float amp, float ph) {
|
|
3521
|
+
return amp * (0.1 + 0.9 * u * u) * sin(K * u - ph);
|
|
3522
|
+
}
|
|
3523
|
+
|
|
3524
|
+
float dwave(float u, float amp, float ph) {
|
|
3525
|
+
return amp * (1.8 * u * sin(K * u - ph) + (0.1 + 0.9 * u * u) * K * cos(K * u - ph));
|
|
3526
|
+
}
|
|
3527
|
+
|
|
3528
|
+
float ddwave(float u, float amp, float ph) {
|
|
3529
|
+
float a = K * u - ph;
|
|
3530
|
+
return amp * (1.8 * sin(a) + 3.6 * u * K * cos(a) - (0.1 + 0.9 * u * u) * K * K * sin(a));
|
|
3531
|
+
}
|
|
3532
|
+
|
|
3533
|
+
// the tail fin stays straight, continuing the peduncle, so the bent body never folds over itself
|
|
3534
|
+
float centerline(float u, float amp, float ph) {
|
|
3535
|
+
return wave(clamp(u, -0.1, PEDUNCLE), amp, ph) + dwave(PEDUNCLE, amp, ph) * max(u - PEDUNCLE, 0.0);
|
|
3536
|
+
}
|
|
3537
|
+
|
|
3538
|
+
float slope(float u, float amp, float ph) {
|
|
3539
|
+
return u < -0.1 ? 0.0 : dwave(min(u, PEDUNCLE), amp, ph);
|
|
3540
|
+
}
|
|
3541
|
+
|
|
3542
|
+
float trunk(float u) {
|
|
3543
|
+
return 1.0 - taper * smoothstep(0.3, PEDUNCLE, u);
|
|
3544
|
+
}
|
|
3545
|
+
|
|
3546
|
+
// outline half width along the body, 1 = the full frame
|
|
3547
|
+
float profile(float u, float m) {
|
|
3548
|
+
float h = pow(sin(0.5 * PI * clamp(u / HEAD, 0.0, 1.0)), 0.6);
|
|
3549
|
+
float body = trunk(u);
|
|
3550
|
+
float fin = mix(1.0 - taper, 0.95, smoothstep(PEDUNCLE, 0.97, u));
|
|
3551
|
+
float w = u < PEDUNCLE ? h * body : max(body, fin);
|
|
3552
|
+
return mix(1.0, w, m);
|
|
3553
|
+
}
|
|
3554
|
+
|
|
3555
|
+
// body coordinates of P: (along, across) in short sides of the frame, found by projecting P on the bent centerline
|
|
3556
|
+
vec2 bodyCoords(vec2 P, float head, float len, float amp, float ph) {
|
|
3557
|
+
float u = (P.x - head) / len;
|
|
3558
|
+
for (int i = 0; i < 4; i++) {
|
|
3559
|
+
vec2 T = normalize(vec2(len, slope(u, amp, ph)));
|
|
3560
|
+
u += dot(P - vec2(head + u * len, 0.5 + centerline(u, amp, ph)), T) / len;
|
|
3561
|
+
}
|
|
3562
|
+
vec2 T = normalize(vec2(len, slope(u, amp, ph)));
|
|
3563
|
+
return vec2(u, dot(P - vec2(head + u * len, 0.5 + centerline(u, amp, ph)), vec2(-T.y, T.x)));
|
|
3564
|
+
}
|
|
3565
|
+
|
|
3566
|
+
// approximate signed distance to the fish, in short sides of the frame
|
|
3567
|
+
float fish(vec2 b, float len, float hh, float m) {
|
|
3568
|
+
float e = 0.002;
|
|
3569
|
+
float hw = hh * profile(b.x, m);
|
|
3570
|
+
float dw = clamp(hh * (profile(b.x + e, m) - profile(b.x - e, m)) / (2.0 * e * len), -4.0, 4.0);
|
|
3571
|
+
float side = (abs(b.y) - hw) / sqrt(1.0 + dw * dw);
|
|
3572
|
+
float tail = len * (1.0 - m * FORK * (1.0 - min(abs(b.y) / max(hw, 1e-3), 1.0)));
|
|
3573
|
+
float s = b.x * len;
|
|
3574
|
+
return max(max(side, -s), s - tail) - 2.0 * AA * (1.0 - m);
|
|
3575
|
+
}
|
|
3576
|
+
|
|
3577
|
+
vec2 mirror(vec2 v) {
|
|
3578
|
+
return 1.0 - abs(1.0 - mod(v, 2.0));
|
|
3579
|
+
}
|
|
3580
|
+
|
|
3581
|
+
vec4 transition(vec2 uv) {
|
|
3582
|
+
float t = progress;
|
|
3583
|
+
bool tall = ratio < 1.0;
|
|
3584
|
+
float L = tall ? 1.0 / ratio : ratio;
|
|
3585
|
+
vec2 P = tall ? vec2((1.0 - uv.y) * L, uv.x) : vec2(uv.x * L, uv.y);
|
|
3586
|
+
|
|
3587
|
+
float m = smoothstep(0.0, 0.35, t);
|
|
3588
|
+
float len = L * mix(1.0, 0.6, m);
|
|
3589
|
+
float hh = 0.5 * mix(1.0, 0.6, m);
|
|
3590
|
+
// a short body bends tighter for the same swing, so near-square frames swing less
|
|
3591
|
+
float amp = swing * min(1.0, L / 1.6) * smoothstep(0.0, 0.6, t);
|
|
3592
|
+
float g = t * (0.5 + 0.5 * t);
|
|
3593
|
+
float ph = 2.0 * PI * beats * g;
|
|
3594
|
+
float travel = 0.6 * L + 0.3 + swing;
|
|
3595
|
+
// the head draws back into the frame first; each tail beat adds a small surge to the acceleration
|
|
3596
|
+
float head = 0.12 * L * m * (1.0 - t) - travel * (pow(t, 2.4) + 0.012 * sin(4.0 * PI * beats * g) * t * (1.0 - t));
|
|
3597
|
+
|
|
3598
|
+
vec2 b = bodyCoords(P, head, len, amp, ph);
|
|
3599
|
+
float inBody = 1.0 - smoothstep(-AA, AA, fish(b, len, hh, m));
|
|
3600
|
+
|
|
3601
|
+
float u = b.x;
|
|
3602
|
+
float hw = hh * profile(u, m);
|
|
3603
|
+
float body = hh * mix(1.0, trunk(u), m);
|
|
3604
|
+
vec2 src = mirror(vec2(u, 0.5 + 0.5 * b.y / max(hw, 0.6 * body)));
|
|
3605
|
+
vec4 c = getFromColor(tall ? vec2(src.y, 1.0 - src.x) : src);
|
|
3606
|
+
|
|
3607
|
+
vec2 T = normalize(vec2(len, slope(u, amp, ph)));
|
|
3608
|
+
vec2 lat = tall ? vec2(T.x, T.y) : vec2(-T.y, T.x);
|
|
3609
|
+
float vn = clamp(b.y / max(body, 1e-3), -1.0, 1.0);
|
|
3610
|
+
float fin = smoothstep(PEDUNCLE - 0.05, PEDUNCLE + 0.05, u);
|
|
3611
|
+
vec3 N = normalize(vec3(lat * vn * (1.0 - fin), mix(sqrt(1.0 - vn * vn), 1.0, fin)));
|
|
3612
|
+
vec3 Ld = normalize(vec3(-0.35, 0.55, 0.75));
|
|
3613
|
+
float diff = max(dot(N, Ld), 0.0) / Ld.z;
|
|
3614
|
+
float spec = pow(max(dot(reflect(-Ld, N), vec3(0.0, 0.0, 1.0)), 0.0), 16.0);
|
|
3615
|
+
float k = shading * m;
|
|
3616
|
+
float curv = ddwave(clamp(u, 0.0, PEDUNCLE), amp, ph) / (len * len);
|
|
3617
|
+
// the inside of a bend is creased and darker, the outside stretched and lighter
|
|
3618
|
+
float crease = clamp(0.25 * curv * vn, -1.0, 1.0) * (1.0 - fin);
|
|
3619
|
+
c.rgb = c.rgb * mix(1.0, min(diff, 1.1) * (1.0 - 0.3 * crease), 0.7 * k) + 0.08 * k * spec * c.a;
|
|
3620
|
+
|
|
3621
|
+
vec2 off = 0.06 * m * (tall ? vec2(1.0, 1.0) : vec2(1.0, -1.0));
|
|
3622
|
+
// the shadow is soft, so moving it in the body frame found for P is close enough
|
|
3623
|
+
float sd = fish(b - vec2(dot(off, T) / len, dot(off, vec2(-T.y, T.x))), len, hh, m);
|
|
3624
|
+
vec4 bg = getToColor(uv);
|
|
3625
|
+
bg.rgb *= 1.0 - 0.5 * k * (1.0 - smoothstep(-0.04, 0.08, sd));
|
|
3626
|
+
|
|
3627
|
+
return mix(bg, c, inBody * (1.0 - 0.15 * m * fin));
|
|
3628
|
+
}`,"heat-haze":`// Author: gre
|
|
3629
|
+
// License: MIT
|
|
3630
|
+
// Description: Shimmering heat waves rise through the frame, strongest at the bottom, making the outgoing image wobble like the air over hot asphalt; the incoming image shows through the haze and settles as it calms
|
|
3631
|
+
// Tags: distort, heat, shimmer, noise, organic, blend
|
|
3632
|
+
|
|
3633
|
+
// @range(0, 0.1) How far the haze bends the image, in frame heights (the strongest waves bend it about 1.5 times as far)
|
|
3634
|
+
const float strength = 0.04;
|
|
3635
|
+
// @range(1, 12) Size of the heat waves: more, smaller ones with a larger value
|
|
3636
|
+
const float scale = 6.0;
|
|
3637
|
+
// @range(0, 6) How fast the heat waves rise
|
|
3638
|
+
const float speed = 2.0;
|
|
3639
|
+
|
|
3640
|
+
vec2 mirror(vec2 v) {
|
|
3641
|
+
return 1.0 - abs(1.0 - mod(v, 2.0));
|
|
3642
|
+
}
|
|
3643
|
+
|
|
3644
|
+
float hash12(vec2 v) {
|
|
3645
|
+
vec3 v3 = fract(vec3(v.xyx) * 0.1031);
|
|
3646
|
+
v3 += dot(v3, v3.yzx + 33.33);
|
|
3647
|
+
return fract((v3.x + v3.y) * v3.z);
|
|
3648
|
+
}
|
|
3649
|
+
|
|
3650
|
+
float vnoise(vec2 v) {
|
|
3651
|
+
vec2 i = floor(v);
|
|
3652
|
+
vec2 f = fract(v);
|
|
3653
|
+
f = f * f * (3.0 - 2.0 * f);
|
|
3654
|
+
return mix(
|
|
3655
|
+
mix(hash12(i), hash12(i + vec2(1.0, 0.0)), f.x),
|
|
3656
|
+
mix(hash12(i + vec2(0.0, 1.0)), hash12(i + vec2(1.0, 1.0)), f.x),
|
|
3657
|
+
f.y
|
|
3658
|
+
);
|
|
3659
|
+
}
|
|
3660
|
+
|
|
3661
|
+
// centered on 0, within [-1.5, 1.5]
|
|
3662
|
+
float fbm(vec2 v) {
|
|
3663
|
+
float sum = 0.0;
|
|
3664
|
+
float amp = 0.5;
|
|
3665
|
+
for (int i = 0; i < 4; i++) {
|
|
3666
|
+
sum += amp * vnoise(v);
|
|
3667
|
+
v = mat2(1.6, 1.2, -1.2, 1.6) * v + 5.3;
|
|
3668
|
+
amp *= 0.5;
|
|
3669
|
+
}
|
|
3670
|
+
return (sum / 0.9375 - 0.5) * 3.0;
|
|
3671
|
+
}
|
|
3672
|
+
|
|
3673
|
+
vec4 transition(vec2 uv) {
|
|
3674
|
+
const float PI = 3.141592653589793;
|
|
3675
|
+
float p = progress;
|
|
3676
|
+
float amount = sin(PI * p);
|
|
3677
|
+
float t = p * speed;
|
|
3678
|
+
vec2 q = vec2(uv.x * ratio, uv.y * 2.5) * scale;
|
|
3679
|
+
q.y -= t * scale;
|
|
3680
|
+
vec2 w = vec2(fbm(q * 0.35 + vec2(0.0, t)), fbm(q * 0.35 + vec2(7.1, -t)));
|
|
3681
|
+
q += 1.5 * w;
|
|
3682
|
+
vec2 offset = vec2(fbm(q), 0.5 * fbm(q + vec2(3.7, 1.9)));
|
|
3683
|
+
float ground = mix(1.0, 0.3, uv.y);
|
|
3684
|
+
offset *= strength * amount * ground * vec2(1.0 / ratio, 1.0);
|
|
3685
|
+
|
|
3686
|
+
vec2 d = mirror(uv + offset);
|
|
3687
|
+
float m = smoothstep(0.3, 0.7, p);
|
|
3688
|
+
if (m <= 0.0) return getFromColor(d);
|
|
3689
|
+
if (m >= 1.0) return getToColor(d);
|
|
3690
|
+
vec4 a = getFromColor(d);
|
|
3691
|
+
vec4 b = getToColor(d);
|
|
3692
|
+
// mixed premultiplied, so transparent images do not bleed their color
|
|
3693
|
+
vec4 c = mix(vec4(a.rgb * a.a, a.a), vec4(b.rgb * b.a, b.a), m);
|
|
3694
|
+
return c.a > 0.0 ? vec4(c.rgb / c.a, c.a) : vec4(0.0);
|
|
3695
|
+
}`});export{L as D,re as G,q as L,ee as a,$ as b,Q as c,z as d,oe as e,ae as f,te as g,V as h,ne as i,K as l,G as z};
|