diff --git a/AGENTS.md b/AGENTS.md index 7cde4cdb6..bffe3e89a 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -1,6 +1,6 @@ # Project specifics -- **Next.js 16.2.10 (stable), webpack, Cache Components on.** `cacheComponents: true` + `cacheLife: { default: sanity }` in `next.config.ts`. Do not switch to Turbopack — it doesn't run this project's Tailwind v3 PostCSS pipeline or the GLSL shader loaders. `dev`/`build` use `--webpack`. +- **Next.js 16.2.10 (stable), Turbopack, Cache Components on.** `cacheComponents: true` + `cacheLife: { default: sanity }` in `next.config.ts`. `dev`/`build` run on Turbopack (the Next 16 default — no `--webpack` flag). GLSL shaders load through `raw-loader` only, declared in `turbopack.rules` in `next.config.ts`; shaders must be plain GLSL with **no `glslify` `#pragma`** (the glslify requires were flattened into the `.glsl` files so `raw-loader` suffices). Tailwind v3 + the `postcss.config.mjs` chain (`postcss-import` → `tailwindcss/nesting` → `tailwindcss`) is verified working under Turbopack — `postcss-import` is now an explicit dep. - **Sanity data has three fetch modes (`src/service/sanity/index.ts`) — pick by context:** - `sanityFetch` — Live; only valid **inside a `"use cache"` scope** (its `cacheTag()` throws otherwise). For draft/preview render. - `sanityFetchCached` — Live wrapped in `"use cache"`; the default for published page/route content. Revalidates via Sanity Live tags. diff --git a/next.config.ts b/next.config.ts index 12dac4bd9..d755cda94 100644 --- a/next.config.ts +++ b/next.config.ts @@ -12,7 +12,7 @@ const nextConfig: NextConfig = { turbopack: { rules: { "*.{glsl,vert,frag,vs,fs}": { - loaders: ["raw-loader", "glslify-loader"], + loaders: ["raw-loader"], as: "*.js" } } @@ -32,15 +32,6 @@ const nextConfig: NextConfig = { ] }, - webpack: (config) => { - config.module.rules.push({ - test: /\.(glsl|vs|fs|vert|frag)$/, - use: ["raw-loader", "glslify-loader"] - }) - - return config - }, - async headers() { return [ { diff --git a/package.json b/package.json index 9358eda06..aadac8c76 100644 --- a/package.json +++ b/package.json @@ -3,8 +3,8 @@ "version": "0.1.0", "private": true, "scripts": { - "dev": "next dev --webpack", - "build": "next build --webpack", + "dev": "next dev", + "build": "next build", "prettier": "prettier --write .", "start": "next start", "lint": "eslint src sanity next.config.ts sanity.config.ts sanity.cli.ts --ext .js,.jsx,.ts,.tsx", @@ -42,8 +42,6 @@ "@vercel/speed-insights": "^1.2.0", "clsx": "^2.1.1", "emulators": "^8.3.9", - "glsl-noise": "^0.0.0", - "glslify-loader": "^2.0.0", "jquery": "^3.7.1", "js-dos": "^8.3.20", "leva": "^0.9.35", @@ -93,9 +91,8 @@ "eslint-config-prettier": "^10.1.1", "eslint-plugin-prettier": "^5.2.3", "eslint-plugin-simple-import-sort": "^12.1.1", - "glsl-constants": "^2.0.1", - "glslify-loader": "^2.0.0", - "postcss": "^8", + "postcss": "^8.5.10", + "postcss-import": "^16.1.1", "postcss-nesting": "^13.0.1", "prettier": "^3.3.3", "prettier-plugin-glsl": "^0.2.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index b22ec3e40..d11fd98c2 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -98,12 +98,6 @@ importers: emulators: specifier: ^8.3.9 version: 8.3.9 - glsl-noise: - specifier: ^0.0.0 - version: 0.0.0 - glslify-loader: - specifier: ^2.0.0 - version: 2.0.0 jquery: specifier: ^3.7.1 version: 3.7.1 @@ -246,15 +240,15 @@ importers: eslint-plugin-simple-import-sort: specifier: ^12.1.1 version: 12.1.1(eslint@9.23.0(jiti@2.7.0)) - glsl-constants: - specifier: ^2.0.1 - version: 2.0.1 postcss: - specifier: ^8 - version: 8.0.0 + specifier: ^8.5.10 + version: 8.5.10 + postcss-import: + specifier: ^16.1.1 + version: 16.1.1(postcss@8.5.10) postcss-nesting: specifier: ^13.0.1 - version: 13.0.1(postcss@8.0.0) + version: 13.0.1(postcss@8.5.10) prettier: specifier: ^3.3.3 version: 3.3.3 @@ -1032,10 +1026,6 @@ packages: '@chevrotain/utils@10.5.0': resolution: {integrity: sha512-hBzuU5+JjB2cqNZyszkDHZgOSrUUT8V3dhgRl8Q9Gp6dAj/H5+KILGjbhDpc3Iy9qmqlm/akuOI2ut9VUtzJxQ==} - '@choojs/findup@0.2.1': - resolution: {integrity: sha512-YstAqNb0MCN8PjdLCDfRsBcGVRN41f3vgLvaI0IrIcBp4AqILRSS0DeWNGkicC+f/zRIPJLc+9RURVSepwvfBw==} - hasBin: true - '@clack/core@0.3.5': resolution: {integrity: sha512-5cfhQNH+1VQ2xLQlmzXMqUoiaH0lRBq9/CLW9lTyMbuKLC3+xEK01tHVvyut++mLOn5urSHmkm6I0Lg9MaJSTQ==} @@ -5344,9 +5334,6 @@ packages: colord@2.9.3: resolution: {integrity: sha512-jeC1axXpnb0/2nn/Y1LPuLdgXBLH7aDcHu4KEKfqw3CUhX7ZpfBSlPKyqXE6btIgEzfWtrX3/tyBCaCvXvMkOw==} - colorette@1.4.0: - resolution: {integrity: sha512-Y2oEozpomLn7Q3HFP7dpww7AtMJplbM9lGZP6RDfHqmbeRjiwRg4n6VM6j4KLmRke85uWEI7JqF17f3pqdRA0g==} - combined-stream@1.0.8: resolution: {integrity: sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==} engines: {node: '>= 0.8'} @@ -6367,59 +6354,9 @@ packages: globrex@0.1.2: resolution: {integrity: sha512-uHJgbwAMwNFf5mLst7IWLNg14x1CkeqglJb/K3doi4dw6q2IvAAmM/Y81kevy83wP+Sst+nutFTYOGg3d1lsxg==} - glsl-constants@2.0.1: - resolution: {integrity: sha512-+92w2eioJ6df1R+nd4BAbaCOZxYCJ6n33JgglwId1TlQ/w4kjPdnnNLxrLY4UjTk0C2XX43x7cFL2h62HtefwA==} - engines: {node: '>=16.0.0', npm: '>=7.0.0'} - - glsl-inject-defines@1.0.3: - resolution: {integrity: sha512-W49jIhuDtF6w+7wCMcClk27a2hq8znvHtlGnrYkSWEr8tHe9eA2dcnohlcAmxLYBSpSSdzOkRdyPTrx9fw49+A==} - glsl-noise@0.0.0: resolution: {integrity: sha512-b/ZCF6amfAUb7dJM/MxRs7AetQEahYzJ8PtgfrmEdtw6uyGOr+ZSGtgjFm6mfsBkxJ4d2W7kg+Nlqzqvn3Bc0w==} - glsl-resolve@0.0.1: - resolution: {integrity: sha512-xxFNsfnhZTK9NBhzJjSBGX6IOqYpvBHxxmo+4vapiljyGNCY0Bekzn0firQkQrazK59c1hYxMDxYS8MDlhw4gA==} - - glsl-token-assignments@2.0.2: - resolution: {integrity: sha512-OwXrxixCyHzzA0U2g4btSNAyB2Dx8XrztY5aVUCjRSh4/D0WoJn8Qdps7Xub3sz6zE73W3szLrmWtQ7QMpeHEQ==} - - glsl-token-defines@1.0.0: - resolution: {integrity: sha512-Vb5QMVeLjmOwvvOJuPNg3vnRlffscq2/qvIuTpMzuO/7s5kT+63iL6Dfo2FYLWbzuiycWpbC0/KV0biqFwHxaQ==} - - glsl-token-depth@1.1.2: - resolution: {integrity: sha512-eQnIBLc7vFf8axF9aoi/xW37LSWd2hCQr/3sZui8aBJnksq9C7zMeUYHVJWMhFzXrBU7fgIqni4EhXVW4/krpg==} - - glsl-token-descope@1.0.2: - resolution: {integrity: sha512-kS2PTWkvi/YOeicVjXGgX5j7+8N7e56srNDEHDTVZ1dcESmbmpmgrnpjPcjxJjMxh56mSXYoFdZqb90gXkGjQw==} - - glsl-token-inject-block@1.1.0: - resolution: {integrity: sha512-q/m+ukdUBuHCOtLhSr0uFb/qYQr4/oKrPSdIK2C4TD+qLaJvqM9wfXIF/OOBjuSA3pUoYHurVRNao6LTVVUPWA==} - - glsl-token-properties@1.0.1: - resolution: {integrity: sha512-dSeW1cOIzbuUoYH0y+nxzwK9S9O3wsjttkq5ij9ZGw0OS41BirKJzzH48VLm8qLg+au6b0sINxGC0IrGwtQUcA==} - - glsl-token-scope@1.1.2: - resolution: {integrity: sha512-YKyOMk1B/tz9BwYUdfDoHvMIYTGtVv2vbDSLh94PT4+f87z21FVdou1KNKgF+nECBTo0fJ20dpm0B1vZB1Q03A==} - - glsl-token-string@1.0.1: - resolution: {integrity: sha512-1mtQ47Uxd47wrovl+T6RshKGkRRCYWhnELmkEcUAPALWGTFe2XZpH3r45XAwL2B6v+l0KNsCnoaZCSnhzKEksg==} - - glsl-token-whitespace-trim@1.0.0: - resolution: {integrity: sha512-ZJtsPut/aDaUdLUNtmBYhaCmhIjpKNg7IgZSfX5wFReMc2vnj8zok+gB/3Quqs0TsBSX/fGnqUUYZDqyuc2xLQ==} - - glsl-tokenizer@2.1.5: - resolution: {integrity: sha512-XSZEJ/i4dmz3Pmbnpsy3cKh7cotvFlBiZnDOwnj/05EwNp2XrhQ4XKJxT7/pDt4kp4YcpRSKz8eTV7S+mwV6MA==} - - glslify-bundle@5.1.1: - resolution: {integrity: sha512-plaAOQPv62M1r3OsWf2UbjN0hUYAB7Aph5bfH58VxJZJhloRNbxOL9tl/7H71K7OLJoSJ2ZqWOKk3ttQ6wy24A==} - - glslify-deps@1.3.2: - resolution: {integrity: sha512-7S7IkHWygJRjcawveXQjRXLO2FTjijPDYC7QfZyAQanY+yGLCFHYnPtsGT9bdyHiwPTw/5a1m1M9hamT2aBpag==} - - glslify-loader@2.0.0: - resolution: {integrity: sha512-oOdmTX1BSPG75o3gNZToemfbbuN5dgi4Pco/aRfjbwGxPIfflYLuok6JCf2kDBPHjP+tV+imNsj6YRJg9gKJ1A==} - engines: {node: '>=6'} - gopd@1.2.0: resolution: {integrity: sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==} engines: {node: '>= 0.4'} @@ -6922,9 +6859,6 @@ packages: is-yarn-global@0.3.0: resolution: {integrity: sha512-VjSeb/lHmkoyd8ryPVIKvOCn4D1koMqY+vqyjjUfc3xyKtP4dYOxM44sZrnqQSzSds3xyOrUTLTC9LVCVgLngw==} - isarray@0.0.1: - resolution: {integrity: sha512-D2S+3GLxWH+uhrNEcoh/fnmYeP8E8/zHl644d/jdA0g2uyXvy3sb0qxotE+ne0LtccHknQzWwZEzhak7oJ0COQ==} - isarray@1.0.0: resolution: {integrity: sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ==} @@ -6942,10 +6876,6 @@ packages: resolution: {integrity: sha512-gXkz5+KN7HrG0Q5UGqSMO2qB9AsbEeyLP54kF1YrMsIxmu+g4BdB7rflReZTSTZGpfj8wywu6pfPBCylPIzGQA==} engines: {node: '>=6.0'} - isobject@2.1.0: - resolution: {integrity: sha512-+OUdGJlgjOBZDfxnDjYYG6zp487z0JGNQq3cYQYg5f5hKR+syHMsaztzGeml/4kGG55CSpKSpWTY+jYGgsHLgA==} - engines: {node: '>=0.10.0'} - isobject@3.0.1: resolution: {integrity: sha512-WhB9zCku7EGTj/HQQRz5aUQEUeoQZH2bWcltRErOpymJ4boYE6wL9Tbr23krRPSZ+C5zqNSrSw+Cc7sZZ4b7vg==} engines: {node: '>=0.10.0'} @@ -7147,9 +7077,6 @@ packages: resolution: {integrity: sha512-/vlFKAoH5Cgt3Ie+JLhRbwOsCQePABiU3tJ1egGvyQ+33R/vcwM2Zl2QR/LzjsBeItPt3oSVXapn+m4nQDvpzw==} engines: {node: '>=14'} - line-column@1.0.2: - resolution: {integrity: sha512-Ktrjk5noGYlHsVnYWh62FLVs4hTb8A3e+vucNZMgPeAOITdshMSgv4cCZQeRDjm7+goqmo6+liZwTXo+U3sVww==} - lines-and-columns@1.2.4: resolution: {integrity: sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg==} @@ -7160,10 +7087,6 @@ packages: resolution: {integrity: sha512-3R/1M+yS3j5ou80Me59j7F9IMs4PXs3VqRrm0TU3AbKPxlmpoY1TNscJV/oGJXo8qCatFGTfDbY6W6ipGOYXfg==} engines: {node: '>=6.11.5'} - loader-utils@1.4.2: - resolution: {integrity: sha512-I5d00Pd/jwMD2QCduo657+YM/6L3KZu++pmX9VFncxaxvHcru9jx1lBaFft+r4Mt2jK0Yhp41XlRAihzPxHNCg==} - engines: {node: '>=4.0.0'} - loader-utils@2.0.4: resolution: {integrity: sha512-xXqpXoINfFhgua9xiqD8fPFHgkoq1mmmpE92WlDbm9rNRd/EbRb+Gqf908T2DMfuHjjJlksiK2RbHVOdD/MqSw==} engines: {node: '>=8.9.0'} @@ -7237,9 +7160,6 @@ packages: resolution: {integrity: sha512-g3FeP20LNwhALb/6Cz6Dd4F2ngze0jz7tbzrD2wAV+o9FeNHe4rL+yK2md0J/fiSf1sa1ADhXqi5+oVwOM/eGw==} engines: {node: '>=8'} - map-limit@0.0.1: - resolution: {integrity: sha512-pJpcfLPnIF/Sk3taPW21G/RQsEEirGaFpCW3oXRwH9dnFHPHNGjNyvh++rdmC2fNqEaTw2MhYJraoJWAHx8kEg==} - markdown-it@14.2.0: resolution: {integrity: sha512-1TGiQiJVRQ3NPmZH6sx5Cfnmg6GQm9jvC1ch4TK511NjSJvjzKLzn5pPfZRNZkRPZP0HqCioSndqH8v2nRaWVQ==} hasBin: true @@ -7417,9 +7337,6 @@ packages: ms@2.1.3: resolution: {integrity: sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==} - murmurhash-js@1.0.0: - resolution: {integrity: sha512-TvmkNhkv8yct0SVBSy+o8wYzXjE4Zz3PCesbfs8HiCXXdcTuocApFv11UWlNFWKYsP2okqrhb7JNlSm9InBhIw==} - mute-stream@2.0.0: resolution: {integrity: sha512-WWdIxpyjEn+FhQJQQv9aQAYlHoNVdzIzUySNV1gHUPDSdZJ3yZn7pAAbQcV7B56Mvu881q9FZV+0Vx2xC44VWA==} engines: {node: ^18.17.0 || >=20.5.0} @@ -7446,11 +7363,6 @@ packages: engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1} hasBin: true - nanoid@3.3.8: - resolution: {integrity: sha512-WNLf5Sd8oZxOm+TzppcYk8gVOgP+l58xNy58D0nbUnOxOWRWvlcCV4kUF7ltmI6PsrLl/BgKEyS4mqsGChFN0w==} - engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1} - hasBin: true - nanoid@5.1.16: resolution: {integrity: sha512-kVrnsrJqMR8+oLJnGEmSWw9BivK5mt7H3FZatVRjrc5wGqFYuBxX1yG7+A7Gi5AefkX6t/oCkizcQgpu0cY1dQ==} engines: {node: ^18 || >=20} @@ -7597,9 +7509,6 @@ packages: ohash@1.1.6: resolution: {integrity: sha512-TBu7PtV8YkAZn0tSxobKY2n2aAQva936lhRrj6957aDaCf9IEtqsKbgMzXE/F/sjqYOwmrukeORHNLe5glk7Cg==} - once@1.3.3: - resolution: {integrity: sha512-6vaNInhu+CHxtONf3zw3vq4SP2DOQhjBvIa3rNcG0+P7eKWlYH6Peu7rHizSloRU2EwMz6GraLieis9Ac9+p1w==} - once@1.4.0: resolution: {integrity: sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==} @@ -7837,6 +7746,12 @@ packages: peerDependencies: postcss: ^8.0.0 + postcss-import@16.1.1: + resolution: {integrity: sha512-2xVS1NCZAfjtVdvXiyegxzJ447GyqCeEI5V7ApgQVOWnros1p5lGNovJNapwPpMombyFBfqDwt7AD3n2l0KOfQ==} + engines: {node: '>=18.0.0'} + peerDependencies: + postcss: ^8.0.0 + postcss-js@4.0.1: resolution: {integrity: sha512-dDLF8pEO191hJMtlHFPRa8xsizHaM82MLfNkUHdUtVEV3tgTp5oj+8qbEqYM57SLfc74KSbw//4SeJma2LRVIw==} engines: {node: ^12 || ^14 || >= 16} @@ -7878,18 +7793,10 @@ packages: postcss-value-parser@4.2.0: resolution: {integrity: sha512-1NNCs6uurfkVbeXG4S8JFT9t19m45ICnif8zWLd5oPSZ50QnwMfK+H3jv408d4jw/7Bttv5axS5IiHoLaVNHeQ==} - postcss@8.0.0: - resolution: {integrity: sha512-BriaW5AeZHfyuuKhK3Z6yRDKI6NR2TdRWyZcj3+Pk2nczQsMBqavggAzTledsbyexPthW3nFA6XfgCWjZqmVPA==} - engines: {node: ^10 || ^12 || >=14} - postcss@8.4.31: resolution: {integrity: sha512-PS08Iboia9mts/2ygV3eLpY5ghnUcfLV/EXTOW1E2qYxJKGGBUtNjN76FYHnMs36RmARn41bC0AZmn+rR0OVpQ==} engines: {node: ^10 || ^12 || >=14} - postcss@8.4.49: - resolution: {integrity: sha512-OCVPnIObs4N29kxTjzLfUryOkvZEq+pf8jTF0lg8E7uETuWHA+v7j3c/xJmiqpX450191LlmZfUKkXxkTry7nA==} - engines: {node: ^10 || ^12 || >=14} - postcss@8.5.10: resolution: {integrity: sha512-pMMHxBOZKFU6HgAZ4eyGnwXF/EvPGGqUr0MnZ5+99485wwW41kW91A4LOGxSHhgugZmSChL5AlElNdwlNgcnLQ==} engines: {node: ^10 || ^12 || >=14} @@ -8366,9 +8273,6 @@ packages: resolution: {integrity: sha512-I8g2lArQiP78ll51UeMZojewtYgIRCKCWqZEgOO8c/uefTI+XDXvCSXu3+YNUaTNvZzobrL5+SqHjBrByRRTdg==} engines: {node: '>=20'} - readable-stream@1.0.34: - resolution: {integrity: sha512-ok1qVCJuRkNmvebYikljxJA/UEsKwLl2nI1OmaqAu4/UE+h0wKCHok4XkL/gvi39OacXvw59RJUOFUkDib2rHg==} - readable-stream@2.3.8: resolution: {integrity: sha512-8p0AUk4XODgIewSi0l8Epjs+EVnWiK7NoDIEGU0HhE7+ZyY8D1IMY7odu5lRrFXGg71L15KG8QrPmum45RTtdA==} @@ -8500,9 +8404,6 @@ packages: resolve-pkg-maps@1.0.0: resolution: {integrity: sha512-seS2Tj26TBVOC2NIc2rOe2y2ZO7efxITtLZcGSOnHHNOQ7CkiUBfw0Iw2ck6xkIhPwLhKNLS8BO+hEpngQlqzw==} - resolve@0.6.3: - resolution: {integrity: sha512-UHBY3viPlJKf85YijDUcikKX6tmF4SokIDp518ZDVT92JNDcG5uKIthaT/owt3Sar0lwtOafsQuwrg22/v2Dwg==} - resolve@1.22.11: resolution: {integrity: sha512-RfqAvLnMl313r7c9oclB1HhUEAezcpLjz95wFH4LVuhk9JF/r22qmVP9AMmOU4vMX7Q8pN8jwNg/CSpdFnMjTQ==} engines: {node: '>= 0.4'} @@ -8690,9 +8591,6 @@ packages: resolution: {integrity: sha512-/6KqX+GVUdqPuPPd2LxDDxzX6CAbjJehAAOKlNpqqUpAqPM6HeL8f+o3a+JsyGjn2lv0WY8UsTgUJjU9Ok55NA==} engines: {node: '>=8'} - shallow-copy@0.0.1: - resolution: {integrity: sha512-b6i4ZpVuUxB9h5gfCxPiusKYkqTMOjEbBs4wMaFbkfia4yFv92UKZ6Df8WXcKbn08JNL/abvg3FnMAOfakDvUw==} - shallow-equals@1.0.0: resolution: {integrity: sha512-xd/FKcdmfmMbyYCca3QTVEJtqUOGuajNzvAX6nt8dXILwjAIEkfHc4hI8/JMGApAmb7VeULO0Q30NTxnbH/15g==} @@ -8888,9 +8786,6 @@ packages: resolution: {integrity: sha512-UXSH262CSZY1tfu3G3Secr6uGLCFVPMhIqHjlgCUtCCcgihYc/xKs9djMTMUOb2j1mVSeU8EU6NWc/iQKU6Gfg==} engines: {node: '>= 0.4'} - string_decoder@0.10.31: - resolution: {integrity: sha512-ev2QzSzWPYmy9GuqfIVildA4OdcGLeFZQrq5ys6RtiuF+RQQiZWr8TZNyAcuVXyQRYfEO+MsoB/1BuQVhOJuoQ==} - string_decoder@1.1.1: resolution: {integrity: sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==} @@ -9087,9 +8982,6 @@ packages: three@0.180.0: resolution: {integrity: sha512-o+qycAMZrh+TsE01GqWUxUIKR1AL0S8pq7zDkYOQw8GqfX8b8VoCKYUoHbhiX5j+7hr8XsuHDVU6+gkQJQKg9w==} - through2@0.6.5: - resolution: {integrity: sha512-RkK/CCESdTKQZHdmKICijdKKsCRVHs5KsLZ6pACAmF/1GPUQhonHSXWNERctxEp7RmvjdNbZTL5z9V7nSCXKcg==} - through2@2.0.5: resolution: {integrity: sha512-/mrRod8xqpA+IHSLyGCQ2s8SPHiCDEeQJSep1jqLYeEUClOFG2Qsh+4FU6G9VeqpZnGW/Su8LQGc4YKni5rYSQ==} @@ -9784,10 +9676,6 @@ packages: xstate@5.32.2: resolution: {integrity: sha512-uDrojEQYYb4cEeB/SpKDBQlnL2969N5ltmVak4jUMUC6VVRuhi7PCnTBxe4YlQ8YLzdaOEOuVR48CRQPE2o0Uw==} - xtend@2.2.0: - resolution: {integrity: sha512-SLt5uylT+4aoXxXuwtQp5ZnMMzhDb1Xkg4pEqc00WUJCQifPfV9Ub1VrNhp9kXkrjZD2I2Hl8WnjP37jzZLPZw==} - engines: {node: '>=0.4'} - xtend@4.0.2: resolution: {integrity: sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==} engines: {node: '>=0.4'} @@ -10942,10 +10830,6 @@ snapshots: '@chevrotain/utils@10.5.0': {} - '@choojs/findup@0.2.1': - dependencies: - commander: 2.20.3 - '@clack/core@0.3.5': dependencies: picocolors: 1.1.1 @@ -15506,8 +15390,6 @@ snapshots: colord@2.9.3: {} - colorette@1.4.0: {} - combined-stream@1.0.8: dependencies: delayed-stream: 1.0.0 @@ -16746,81 +16628,8 @@ snapshots: globrex@0.1.2: {} - glsl-constants@2.0.1: {} - - glsl-inject-defines@1.0.3: - dependencies: - glsl-token-inject-block: 1.1.0 - glsl-token-string: 1.0.1 - glsl-tokenizer: 2.1.5 - glsl-noise@0.0.0: {} - glsl-resolve@0.0.1: - dependencies: - resolve: 0.6.3 - xtend: 2.2.0 - - glsl-token-assignments@2.0.2: {} - - glsl-token-defines@1.0.0: - dependencies: - glsl-tokenizer: 2.1.5 - - glsl-token-depth@1.1.2: {} - - glsl-token-descope@1.0.2: - dependencies: - glsl-token-assignments: 2.0.2 - glsl-token-depth: 1.1.2 - glsl-token-properties: 1.0.1 - glsl-token-scope: 1.1.2 - - glsl-token-inject-block@1.1.0: {} - - glsl-token-properties@1.0.1: {} - - glsl-token-scope@1.1.2: {} - - glsl-token-string@1.0.1: {} - - glsl-token-whitespace-trim@1.0.0: {} - - glsl-tokenizer@2.1.5: - dependencies: - through2: 0.6.5 - - glslify-bundle@5.1.1: - dependencies: - glsl-inject-defines: 1.0.3 - glsl-token-defines: 1.0.0 - glsl-token-depth: 1.1.2 - glsl-token-descope: 1.0.2 - glsl-token-scope: 1.1.2 - glsl-token-string: 1.0.1 - glsl-token-whitespace-trim: 1.0.0 - glsl-tokenizer: 2.1.5 - murmurhash-js: 1.0.0 - shallow-copy: 0.0.1 - - glslify-deps@1.3.2: - dependencies: - '@choojs/findup': 0.2.1 - events: 3.3.0 - glsl-resolve: 0.0.1 - glsl-tokenizer: 2.1.5 - graceful-fs: 4.2.11 - inherits: 2.0.4 - map-limit: 0.0.1 - resolve: 1.22.8 - - glslify-loader@2.0.0: - dependencies: - glslify-bundle: 5.1.1 - glslify-deps: 1.3.2 - loader-utils: 1.4.2 - resolve: 1.22.8 - gopd@1.2.0: {} graceful-fs@4.2.10: {} @@ -17265,8 +17074,6 @@ snapshots: is-yarn-global@0.3.0: {} - isarray@0.0.1: {} - isarray@1.0.0: {} isarray@2.0.5: {} @@ -17277,10 +17084,6 @@ snapshots: iso-639-1@3.1.5: {} - isobject@2.1.0: - dependencies: - isarray: 1.0.0 - isobject@3.0.1: {} isomorphic-dompurify@2.26.0: @@ -17556,11 +17359,6 @@ snapshots: lilconfig@3.1.3: {} - line-column@1.0.2: - dependencies: - isarray: 1.0.0 - isobject: 2.1.0 - lines-and-columns@1.2.4: {} linkify-it@5.0.1: @@ -17569,12 +17367,6 @@ snapshots: loader-runner@4.3.0: {} - loader-utils@1.4.2: - dependencies: - big.js: 5.2.2 - emojis-list: 3.0.0 - json5: 1.0.2 - loader-utils@2.0.4: dependencies: big.js: 5.2.2 @@ -17639,10 +17431,6 @@ snapshots: dependencies: semver: 6.3.1 - map-limit@0.0.1: - dependencies: - once: 1.3.3 - markdown-it@14.2.0: dependencies: argparse: 2.0.1 @@ -17812,8 +17600,6 @@ snapshots: ms@2.1.3: {} - murmurhash-js@1.0.0: {} - mute-stream@2.0.0: {} mute-stream@3.0.0: {} @@ -17832,8 +17618,6 @@ snapshots: nanoid@3.3.11: {} - nanoid@3.3.8: {} - nanoid@5.1.16: {} nanoid@5.1.2: {} @@ -17983,10 +17767,6 @@ snapshots: ohash@1.1.6: {} - once@1.3.3: - dependencies: - wrappy: 1.0.2 - once@1.4.0: dependencies: wrappy: 1.0.2 @@ -18228,35 +18008,42 @@ snapshots: possible-typed-array-names@1.0.0: {} - postcss-import@15.1.0(postcss@8.4.49): + postcss-import@15.1.0(postcss@8.5.10): dependencies: - postcss: 8.4.49 + postcss: 8.5.10 postcss-value-parser: 4.2.0 read-cache: 1.0.0 resolve: 1.22.8 - postcss-js@4.0.1(postcss@8.4.49): + postcss-import@16.1.1(postcss@8.5.10): + dependencies: + postcss: 8.5.10 + postcss-value-parser: 4.2.0 + read-cache: 1.0.0 + resolve: 1.22.11 + + postcss-js@4.0.1(postcss@8.5.10): dependencies: camelcase-css: 2.0.1 - postcss: 8.4.49 + postcss: 8.5.10 - postcss-load-config@4.0.2(postcss@8.4.49): + postcss-load-config@4.0.2(postcss@8.5.10): dependencies: lilconfig: 3.1.3 yaml: 2.6.1 optionalDependencies: - postcss: 8.4.49 + postcss: 8.5.10 - postcss-nested@6.2.0(postcss@8.4.49): + postcss-nested@6.2.0(postcss@8.5.10): dependencies: - postcss: 8.4.49 + postcss: 8.5.10 postcss-selector-parser: 6.1.2 - postcss-nesting@13.0.1(postcss@8.0.0): + postcss-nesting@13.0.1(postcss@8.5.10): dependencies: '@csstools/selector-resolve-nested': 3.0.0(postcss-selector-parser@7.1.0) '@csstools/selector-specificity': 5.0.0(postcss-selector-parser@7.1.0) - postcss: 8.0.0 + postcss: 8.5.10 postcss-selector-parser: 7.1.0 postcss-selector-parser@6.1.2: @@ -18271,25 +18058,12 @@ snapshots: postcss-value-parser@4.2.0: {} - postcss@8.0.0: - dependencies: - colorette: 1.4.0 - line-column: 1.0.2 - nanoid: 3.3.8 - source-map: 0.6.1 - postcss@8.4.31: dependencies: nanoid: 3.3.11 picocolors: 1.1.1 source-map-js: 1.2.1 - postcss@8.4.49: - dependencies: - nanoid: 3.3.8 - picocolors: 1.1.1 - source-map-js: 1.2.1 - postcss@8.5.10: dependencies: nanoid: 3.3.11 @@ -18454,7 +18228,7 @@ snapshots: dependencies: classnames: 2.5.1 lodash: 4.17.21 - nanoid: 3.3.8 + nanoid: 3.3.11 prop-types: 15.8.1 react: 19.2.7 @@ -18712,13 +18486,6 @@ snapshots: type-fest: 5.5.0 unicorn-magic: 0.4.0 - readable-stream@1.0.34: - dependencies: - core-util-is: 1.0.3 - inherits: 2.0.4 - isarray: 0.0.1 - string_decoder: 0.10.31 - readable-stream@2.3.8: dependencies: core-util-is: 1.0.3 @@ -18871,8 +18638,6 @@ snapshots: resolve-pkg-maps@1.0.0: {} - resolve@0.6.3: {} - resolve@1.22.11: dependencies: is-core-module: 2.16.1 @@ -19275,8 +19040,6 @@ snapshots: dependencies: kind-of: 6.0.3 - shallow-copy@0.0.1: {} - shallow-equals@1.0.0: {} sharp@0.34.5: @@ -19560,8 +19323,6 @@ snapshots: define-properties: 1.2.1 es-object-atoms: 1.1.1 - string_decoder@0.10.31: {} - string_decoder@1.1.1: dependencies: safe-buffer: 5.1.2 @@ -19688,11 +19449,11 @@ snapshots: normalize-path: 3.0.0 object-hash: 3.0.0 picocolors: 1.1.1 - postcss: 8.4.49 - postcss-import: 15.1.0(postcss@8.4.49) - postcss-js: 4.0.1(postcss@8.4.49) - postcss-load-config: 4.0.2(postcss@8.4.49) - postcss-nested: 6.2.0(postcss@8.4.49) + postcss: 8.5.10 + postcss-import: 15.1.0(postcss@8.5.10) + postcss-js: 4.0.1(postcss@8.5.10) + postcss-load-config: 4.0.2(postcss@8.5.10) + postcss-nested: 6.2.0(postcss@8.5.10) postcss-selector-parser: 6.1.2 resolve: 1.22.8 sucrase: 3.35.0 @@ -19800,11 +19561,6 @@ snapshots: three@0.180.0: {} - through2@0.6.5: - dependencies: - readable-stream: 1.0.34 - xtend: 4.0.2 - through2@2.0.5: dependencies: readable-stream: 2.3.8 @@ -20509,8 +20265,6 @@ snapshots: xstate@5.32.2: {} - xtend@2.2.0: {} - xtend@4.0.2: {} xycolors@0.1.2: {} diff --git a/src/shaders/material-flow/fragment.glsl b/src/shaders/material-flow/fragment.glsl index 031deafe5..41dd2e425 100644 --- a/src/shaders/material-flow/fragment.glsl +++ b/src/shaders/material-flow/fragment.glsl @@ -1,4 +1,5 @@ precision highp float; +#define GLSLIFY 1 in vec2 vUv; in vec2 vFlowSize; @@ -13,7 +14,78 @@ uniform sampler2D uFeedbackTexture; uniform int uFrame; uniform float uMouseMoving; -#pragma glslify: cnoise2 = require(glsl-noise/classic/2d) +// +// GLSL textureless classic 2D noise "cnoise", +// with an RSL-style periodic variant "pnoise". +// Author: Stefan Gustavson (stefan.gustavson@liu.se) +// Version: 2011-08-22 +// +// Many thanks to Ian McEwan of Ashima Arts for the +// ideas for permutation and gradient selection. +// +// Copyright (c) 2011 Stefan Gustavson. All rights reserved. +// Distributed under the MIT license. See LICENSE file. +// https://github.com/ashima/webgl-noise +// + +vec4 mod289(vec4 x) +{ + return x - floor(x * (1.0 / 289.0)) * 289.0; +} + +vec4 permute(vec4 x) +{ + return mod289(((x*34.0)+1.0)*x); +} + +vec4 taylorInvSqrt(vec4 r) +{ + return 1.79284291400159 - 0.85373472095314 * r; +} + +vec2 fade(vec2 t) { + return t*t*t*(t*(t*6.0-15.0)+10.0); +} + +// Classic Perlin noise +float cnoise(vec2 P) +{ + vec4 Pi = floor(P.xyxy) + vec4(0.0, 0.0, 1.0, 1.0); + vec4 Pf = fract(P.xyxy) - vec4(0.0, 0.0, 1.0, 1.0); + Pi = mod289(Pi); // To avoid truncation effects in permutation + vec4 ix = Pi.xzxz; + vec4 iy = Pi.yyww; + vec4 fx = Pf.xzxz; + vec4 fy = Pf.yyww; + + vec4 i = permute(permute(ix) + iy); + + vec4 gx = fract(i * (1.0 / 41.0)) * 2.0 - 1.0 ; + vec4 gy = abs(gx) - 0.5 ; + vec4 tx = floor(gx + 0.5); + gx = gx - tx; + + vec2 g00 = vec2(gx.x,gy.x); + vec2 g10 = vec2(gx.y,gy.y); + vec2 g01 = vec2(gx.z,gy.z); + vec2 g11 = vec2(gx.w,gy.w); + + vec4 norm = taylorInvSqrt(vec4(dot(g00, g00), dot(g01, g01), dot(g10, g10), dot(g11, g11))); + g00 *= norm.x; + g01 *= norm.y; + g10 *= norm.z; + g11 *= norm.w; + + float n00 = dot(g00, vec2(fx.x, fy.x)); + float n10 = dot(g10, vec2(fx.y, fy.y)); + float n01 = dot(g01, vec2(fx.z, fy.z)); + float n11 = dot(g11, vec2(fx.w, fy.w)); + + vec2 fade_xy = fade(Pf.xy); + vec2 n_x = mix(vec2(n00, n01), vec2(n10, n11), fade_xy.x); + float n_xy = mix(n_x.x, n_x.y, fade_xy.y); + return 2.3 * n_xy; +} float circleSdf(vec2 pos, vec2 center, float radius) { return length(pos - center) - radius; @@ -25,7 +97,6 @@ float valueRemap(float value, float min, float max, float newMin, float newMax) const int gridSize = 3; - // FLOW CHANNELS // r - depht of pointer // g - growth of wave @@ -62,7 +133,7 @@ vec4 samplePrev(vec2 uv) { } finalSample.g += 0.02; - float noise = cnoise2(pixel); + float noise = cnoise(pixel); if(finalSample.g > 2. + 1. * noise) { finalSample.g = 1000.; diff --git a/src/shaders/material-global-shader/fragment.glsl b/src/shaders/material-global-shader/fragment.glsl index 4270a13fe..0c93301fb 100644 --- a/src/shaders/material-global-shader/fragment.glsl +++ b/src/shaders/material-global-shader/fragment.glsl @@ -1,4 +1,5 @@ precision highp float; +#define GLSLIFY 1 varying vec2 vUv; varying vec2 vUv2; @@ -91,8 +92,45 @@ uniform float fadeFactor; uniform sampler2D lampLightmap; uniform bool lightLampEnabled; -#pragma glslify: valueRemap = require('../utils/value-remap.glsl') -#pragma glslify: basicLight = require('../utils/basic-light.glsl') +float valueRemap(float value, float min, float max) { + return (value - min) / (max - min); +} + +float valueRemap( + float value, + float min, + float max, + float newMin, + float newMax +) { + return (value - min) / (max - min) * (newMax - newMin) + newMin; +} + +vec2 valueRemap(vec2 value, vec2 min, vec2 max, vec2 newMin, vec2 newMax) { + return vec2( + valueRemap(value.x, min.x, max.x, newMin.x, newMax.x), + valueRemap(value.y, min.y, max.y, newMin.y, newMax.y) + ); +} + +vec3 valueRemap(vec3 value, vec3 min, vec3 max, vec3 newMin, vec3 newMax) { + return vec3( + valueRemap(value.x, min.x, max.x, newMin.x, newMax.x), + valueRemap(value.y, min.y, max.y, newMin.y, newMax.y), + valueRemap(value.z, min.z, max.z, newMin.z, newMax.z) + ); +} + +float basicLight(vec3 normal, vec3 lightDir, float intensity) { + float lightFactor = dot(lightDir, normalize(normal)); + lightFactor = valueRemap(lightFactor, 0.2, 1.0, 0.1, 1.0); + lightFactor = clamp(lightFactor, 0.0, 1.0); + lightFactor = pow(lightFactor, 2.0); + lightFactor *= intensity; + lightFactor += 1.0; + + return lightFactor; +} void main() { vec3 normalizedNormal = normalize(vNormal); diff --git a/src/shaders/material-solid-reveal/fragment.glsl b/src/shaders/material-solid-reveal/fragment.glsl index ac33bb840..cc02282a7 100644 --- a/src/shaders/material-solid-reveal/fragment.glsl +++ b/src/shaders/material-solid-reveal/fragment.glsl @@ -1,4 +1,5 @@ precision highp float; +#define GLSLIFY 1 in vec3 vWorldPosition; in float vDepth; @@ -15,8 +16,281 @@ uniform vec3 cameraPosition; uniform mat4 viewMatrix; uniform mat4 projectionMatrix; -#pragma glslify: cnoise3 = require(glsl-noise/classic/3d) -#pragma glslify: cnoise4 = require(glsl-noise/classic/4d) +// +// GLSL textureless classic 3D noise "cnoise", +// with an RSL-style periodic variant "pnoise". +// Author: Stefan Gustavson (stefan.gustavson@liu.se) +// Version: 2011-10-11 +// +// Many thanks to Ian McEwan of Ashima Arts for the +// ideas for permutation and gradient selection. +// +// Copyright (c) 2011 Stefan Gustavson. All rights reserved. +// Distributed under the MIT license. See LICENSE file. +// https://github.com/ashima/webgl-noise +// + +vec3 mod289_0(vec3 x) +{ + return x - floor(x * (1.0 / 289.0)) * 289.0; +} + +vec4 mod289_0(vec4 x) +{ + return x - floor(x * (1.0 / 289.0)) * 289.0; +} + +vec4 permute_0(vec4 x) +{ + return mod289_0(((x*34.0)+1.0)*x); +} + +vec4 taylorInvSqrt_0(vec4 r) +{ + return 1.79284291400159 - 0.85373472095314 * r; +} + +vec3 fade_0(vec3 t) { + return t*t*t*(t*(t*6.0-15.0)+10.0); +} + +// Classic Perlin noise +float cnoise_0(vec3 P) +{ + vec3 Pi0 = floor(P); // Integer part for indexing + vec3 Pi1 = Pi0 + vec3(1.0); // Integer part + 1 + Pi0 = mod289_0(Pi0); + Pi1 = mod289_0(Pi1); + vec3 Pf0 = fract(P); // Fractional part for interpolation + vec3 Pf1 = Pf0 - vec3(1.0); // Fractional part - 1.0 + vec4 ix = vec4(Pi0.x, Pi1.x, Pi0.x, Pi1.x); + vec4 iy = vec4(Pi0.yy, Pi1.yy); + vec4 iz0 = Pi0.zzzz; + vec4 iz1 = Pi1.zzzz; + + vec4 ixy = permute_0(permute_0(ix) + iy); + vec4 ixy0 = permute_0(ixy + iz0); + vec4 ixy1 = permute_0(ixy + iz1); + + vec4 gx0 = ixy0 * (1.0 / 7.0); + vec4 gy0 = fract(floor(gx0) * (1.0 / 7.0)) - 0.5; + gx0 = fract(gx0); + vec4 gz0 = vec4(0.5) - abs(gx0) - abs(gy0); + vec4 sz0 = step(gz0, vec4(0.0)); + gx0 -= sz0 * (step(0.0, gx0) - 0.5); + gy0 -= sz0 * (step(0.0, gy0) - 0.5); + + vec4 gx1 = ixy1 * (1.0 / 7.0); + vec4 gy1 = fract(floor(gx1) * (1.0 / 7.0)) - 0.5; + gx1 = fract(gx1); + vec4 gz1 = vec4(0.5) - abs(gx1) - abs(gy1); + vec4 sz1 = step(gz1, vec4(0.0)); + gx1 -= sz1 * (step(0.0, gx1) - 0.5); + gy1 -= sz1 * (step(0.0, gy1) - 0.5); + + vec3 g000 = vec3(gx0.x,gy0.x,gz0.x); + vec3 g100 = vec3(gx0.y,gy0.y,gz0.y); + vec3 g010 = vec3(gx0.z,gy0.z,gz0.z); + vec3 g110 = vec3(gx0.w,gy0.w,gz0.w); + vec3 g001 = vec3(gx1.x,gy1.x,gz1.x); + vec3 g101 = vec3(gx1.y,gy1.y,gz1.y); + vec3 g011 = vec3(gx1.z,gy1.z,gz1.z); + vec3 g111 = vec3(gx1.w,gy1.w,gz1.w); + + vec4 norm0 = taylorInvSqrt_0(vec4(dot(g000, g000), dot(g010, g010), dot(g100, g100), dot(g110, g110))); + g000 *= norm0.x; + g010 *= norm0.y; + g100 *= norm0.z; + g110 *= norm0.w; + vec4 norm1 = taylorInvSqrt_0(vec4(dot(g001, g001), dot(g011, g011), dot(g101, g101), dot(g111, g111))); + g001 *= norm1.x; + g011 *= norm1.y; + g101 *= norm1.z; + g111 *= norm1.w; + + float n000 = dot(g000, Pf0); + float n100 = dot(g100, vec3(Pf1.x, Pf0.yz)); + float n010 = dot(g010, vec3(Pf0.x, Pf1.y, Pf0.z)); + float n110 = dot(g110, vec3(Pf1.xy, Pf0.z)); + float n001 = dot(g001, vec3(Pf0.xy, Pf1.z)); + float n101 = dot(g101, vec3(Pf1.x, Pf0.y, Pf1.z)); + float n011 = dot(g011, vec3(Pf0.x, Pf1.yz)); + float n111 = dot(g111, Pf1); + + vec3 fade_xyz = fade_0(Pf0); + vec4 n_z = mix(vec4(n000, n100, n010, n110), vec4(n001, n101, n011, n111), fade_xyz.z); + vec2 n_yz = mix(n_z.xy, n_z.zw, fade_xyz.y); + float n_xyz = mix(n_yz.x, n_yz.y, fade_xyz.x); + return 2.2 * n_xyz; +} + +// +// GLSL textureless classic 4D noise "cnoise", +// with an RSL-style periodic variant "pnoise". +// Author: Stefan Gustavson (stefan.gustavson@liu.se) +// Version: 2011-08-22 +// +// Many thanks to Ian McEwan of Ashima Arts for the +// ideas for permutation and gradient selection. +// +// Copyright (c) 2011 Stefan Gustavson. All rights reserved. +// Distributed under the MIT license. See LICENSE file. +// https://github.com/ashima/webgl-noise +// + +vec4 mod289_1(vec4 x) +{ + return x - floor(x * (1.0 / 289.0)) * 289.0; +} + +vec4 permute_1(vec4 x) +{ + return mod289_1(((x*34.0)+1.0)*x); +} + +vec4 taylorInvSqrt_1(vec4 r) +{ + return 1.79284291400159 - 0.85373472095314 * r; +} + +vec4 fade_1(vec4 t) { + return t*t*t*(t*(t*6.0-15.0)+10.0); +} + +// Classic Perlin noise +float cnoise_1(vec4 P) +{ + vec4 Pi0 = floor(P); // Integer part for indexing + vec4 Pi1 = Pi0 + 1.0; // Integer part + 1 + Pi0 = mod289_1(Pi0); + Pi1 = mod289_1(Pi1); + vec4 Pf0 = fract(P); // Fractional part for interpolation + vec4 Pf1 = Pf0 - 1.0; // Fractional part - 1.0 + vec4 ix = vec4(Pi0.x, Pi1.x, Pi0.x, Pi1.x); + vec4 iy = vec4(Pi0.yy, Pi1.yy); + vec4 iz0 = vec4(Pi0.zzzz); + vec4 iz1 = vec4(Pi1.zzzz); + vec4 iw0 = vec4(Pi0.wwww); + vec4 iw1 = vec4(Pi1.wwww); + + vec4 ixy = permute_1(permute_1(ix) + iy); + vec4 ixy0 = permute_1(ixy + iz0); + vec4 ixy1 = permute_1(ixy + iz1); + vec4 ixy00 = permute_1(ixy0 + iw0); + vec4 ixy01 = permute_1(ixy0 + iw1); + vec4 ixy10 = permute_1(ixy1 + iw0); + vec4 ixy11 = permute_1(ixy1 + iw1); + + vec4 gx00 = ixy00 * (1.0 / 7.0); + vec4 gy00 = floor(gx00) * (1.0 / 7.0); + vec4 gz00 = floor(gy00) * (1.0 / 6.0); + gx00 = fract(gx00) - 0.5; + gy00 = fract(gy00) - 0.5; + gz00 = fract(gz00) - 0.5; + vec4 gw00 = vec4(0.75) - abs(gx00) - abs(gy00) - abs(gz00); + vec4 sw00 = step(gw00, vec4(0.0)); + gx00 -= sw00 * (step(0.0, gx00) - 0.5); + gy00 -= sw00 * (step(0.0, gy00) - 0.5); + + vec4 gx01 = ixy01 * (1.0 / 7.0); + vec4 gy01 = floor(gx01) * (1.0 / 7.0); + vec4 gz01 = floor(gy01) * (1.0 / 6.0); + gx01 = fract(gx01) - 0.5; + gy01 = fract(gy01) - 0.5; + gz01 = fract(gz01) - 0.5; + vec4 gw01 = vec4(0.75) - abs(gx01) - abs(gy01) - abs(gz01); + vec4 sw01 = step(gw01, vec4(0.0)); + gx01 -= sw01 * (step(0.0, gx01) - 0.5); + gy01 -= sw01 * (step(0.0, gy01) - 0.5); + + vec4 gx10 = ixy10 * (1.0 / 7.0); + vec4 gy10 = floor(gx10) * (1.0 / 7.0); + vec4 gz10 = floor(gy10) * (1.0 / 6.0); + gx10 = fract(gx10) - 0.5; + gy10 = fract(gy10) - 0.5; + gz10 = fract(gz10) - 0.5; + vec4 gw10 = vec4(0.75) - abs(gx10) - abs(gy10) - abs(gz10); + vec4 sw10 = step(gw10, vec4(0.0)); + gx10 -= sw10 * (step(0.0, gx10) - 0.5); + gy10 -= sw10 * (step(0.0, gy10) - 0.5); + + vec4 gx11 = ixy11 * (1.0 / 7.0); + vec4 gy11 = floor(gx11) * (1.0 / 7.0); + vec4 gz11 = floor(gy11) * (1.0 / 6.0); + gx11 = fract(gx11) - 0.5; + gy11 = fract(gy11) - 0.5; + gz11 = fract(gz11) - 0.5; + vec4 gw11 = vec4(0.75) - abs(gx11) - abs(gy11) - abs(gz11); + vec4 sw11 = step(gw11, vec4(0.0)); + gx11 -= sw11 * (step(0.0, gx11) - 0.5); + gy11 -= sw11 * (step(0.0, gy11) - 0.5); + + vec4 g0000 = vec4(gx00.x,gy00.x,gz00.x,gw00.x); + vec4 g1000 = vec4(gx00.y,gy00.y,gz00.y,gw00.y); + vec4 g0100 = vec4(gx00.z,gy00.z,gz00.z,gw00.z); + vec4 g1100 = vec4(gx00.w,gy00.w,gz00.w,gw00.w); + vec4 g0010 = vec4(gx10.x,gy10.x,gz10.x,gw10.x); + vec4 g1010 = vec4(gx10.y,gy10.y,gz10.y,gw10.y); + vec4 g0110 = vec4(gx10.z,gy10.z,gz10.z,gw10.z); + vec4 g1110 = vec4(gx10.w,gy10.w,gz10.w,gw10.w); + vec4 g0001 = vec4(gx01.x,gy01.x,gz01.x,gw01.x); + vec4 g1001 = vec4(gx01.y,gy01.y,gz01.y,gw01.y); + vec4 g0101 = vec4(gx01.z,gy01.z,gz01.z,gw01.z); + vec4 g1101 = vec4(gx01.w,gy01.w,gz01.w,gw01.w); + vec4 g0011 = vec4(gx11.x,gy11.x,gz11.x,gw11.x); + vec4 g1011 = vec4(gx11.y,gy11.y,gz11.y,gw11.y); + vec4 g0111 = vec4(gx11.z,gy11.z,gz11.z,gw11.z); + vec4 g1111 = vec4(gx11.w,gy11.w,gz11.w,gw11.w); + + vec4 norm00 = taylorInvSqrt_1(vec4(dot(g0000, g0000), dot(g0100, g0100), dot(g1000, g1000), dot(g1100, g1100))); + g0000 *= norm00.x; + g0100 *= norm00.y; + g1000 *= norm00.z; + g1100 *= norm00.w; + + vec4 norm01 = taylorInvSqrt_1(vec4(dot(g0001, g0001), dot(g0101, g0101), dot(g1001, g1001), dot(g1101, g1101))); + g0001 *= norm01.x; + g0101 *= norm01.y; + g1001 *= norm01.z; + g1101 *= norm01.w; + + vec4 norm10 = taylorInvSqrt_1(vec4(dot(g0010, g0010), dot(g0110, g0110), dot(g1010, g1010), dot(g1110, g1110))); + g0010 *= norm10.x; + g0110 *= norm10.y; + g1010 *= norm10.z; + g1110 *= norm10.w; + + vec4 norm11 = taylorInvSqrt_1(vec4(dot(g0011, g0011), dot(g0111, g0111), dot(g1011, g1011), dot(g1111, g1111))); + g0011 *= norm11.x; + g0111 *= norm11.y; + g1011 *= norm11.z; + g1111 *= norm11.w; + + float n0000 = dot(g0000, Pf0); + float n1000 = dot(g1000, vec4(Pf1.x, Pf0.yzw)); + float n0100 = dot(g0100, vec4(Pf0.x, Pf1.y, Pf0.zw)); + float n1100 = dot(g1100, vec4(Pf1.xy, Pf0.zw)); + float n0010 = dot(g0010, vec4(Pf0.xy, Pf1.z, Pf0.w)); + float n1010 = dot(g1010, vec4(Pf1.x, Pf0.y, Pf1.z, Pf0.w)); + float n0110 = dot(g0110, vec4(Pf0.x, Pf1.yz, Pf0.w)); + float n1110 = dot(g1110, vec4(Pf1.xyz, Pf0.w)); + float n0001 = dot(g0001, vec4(Pf0.xyz, Pf1.w)); + float n1001 = dot(g1001, vec4(Pf1.x, Pf0.yz, Pf1.w)); + float n0101 = dot(g0101, vec4(Pf0.x, Pf1.y, Pf0.z, Pf1.w)); + float n1101 = dot(g1101, vec4(Pf1.xy, Pf0.z, Pf1.w)); + float n0011 = dot(g0011, vec4(Pf0.xy, Pf1.zw)); + float n1011 = dot(g1011, vec4(Pf1.x, Pf0.y, Pf1.zw)); + float n0111 = dot(g0111, vec4(Pf0.x, Pf1.yzw)); + float n1111 = dot(g1111, Pf1); + + vec4 fade_xyzw = fade_1(Pf0); + vec4 n_0w = mix(vec4(n0000, n1000, n0100, n1100), vec4(n0001, n1001, n0101, n1101), fade_xyzw.w); + vec4 n_1w = mix(vec4(n0010, n1010, n0110, n1110), vec4(n0011, n1011, n0111, n1111), fade_xyzw.w); + vec4 n_zw = mix(n_0w, n_1w, fade_xyzw.z); + vec2 n_yzw = mix(n_zw.xy, n_zw.zw, fade_xyzw.y); + float n_xyzw = mix(n_yzw.x, n_yzw.y, fade_xyzw.x); + return 2.2 * n_xyzw; +} float isEdge(vec3 p, float voxelSize) { float edgeLimit = 0.94; @@ -48,8 +322,8 @@ VoxelData getVoxel( vec3 voxelCenter = round(pWorld * voxelSize) / voxelSize; vec3 noiseP = voxelCenter; - float noiseBig = cnoise4(vec4( noiseP * noiseBigScale, uTime * 0.05)); - float noiseSmall = cnoise3( noiseP * noiseSmallScale); + float noiseBig = cnoise_1(vec4( noiseP * noiseBigScale, uTime * 0.05)); + float noiseSmall = cnoise_0( noiseP * noiseSmallScale); // float edgeFactor = isEdge(voxelCenter - pWorld, voxelSize); float edgeFactor = 0.0; float fillFactor = 1.0 - edgeFactor; @@ -116,7 +390,6 @@ void main() { vec4 flowColor = texture(uFlowTexture, screenUv); - float distanceToCamera = distance(cameraPosition, voxel.center); float flowCenter = flowColor.r; @@ -130,7 +403,6 @@ void main() { flowSdf = clamp(flowSdf, 0.0, 1.0); flowSdf = pow(flowSdf, 4.); - fragColor.rgb = vec3(clamp(flowSdf + colorBump, 0., 1.)); fragColor.a = 1.0; return; diff --git a/src/shaders/utils/basic-light.glsl b/src/shaders/utils/basic-light.glsl deleted file mode 100644 index c6044954f..000000000 --- a/src/shaders/utils/basic-light.glsl +++ /dev/null @@ -1,14 +0,0 @@ -#pragma glslify: valueRemap = require('../utils/value-remap.glsl') - -float basicLight(vec3 normal, vec3 lightDir, float intensity) { - float lightFactor = dot(lightDir, normalize(normal)); - lightFactor = valueRemap(lightFactor, 0.2, 1.0, 0.1, 1.0); - lightFactor = clamp(lightFactor, 0.0, 1.0); - lightFactor = pow(lightFactor, 2.0); - lightFactor *= intensity; - lightFactor += 1.0; - - return lightFactor; -} - -#pragma glslify: export(basicLight) diff --git a/src/shaders/utils/value-remap.glsl b/src/shaders/utils/value-remap.glsl deleted file mode 100644 index c600d70a6..000000000 --- a/src/shaders/utils/value-remap.glsl +++ /dev/null @@ -1,30 +0,0 @@ -float valueRemap(float value, float min, float max) { - return (value - min) / (max - min); -} - -float valueRemap( - float value, - float min, - float max, - float newMin, - float newMax -) { - return (value - min) / (max - min) * (newMax - newMin) + newMin; -} - -vec2 valueRemap(vec2 value, vec2 min, vec2 max, vec2 newMin, vec2 newMax) { - return vec2( - valueRemap(value.x, min.x, max.x, newMin.x, newMax.x), - valueRemap(value.y, min.y, max.y, newMin.y, newMax.y) - ); -} - -vec3 valueRemap(vec3 value, vec3 min, vec3 max, vec3 newMin, vec3 newMax) { - return vec3( - valueRemap(value.x, min.x, max.x, newMin.x, newMax.x), - valueRemap(value.y, min.y, max.y, newMin.y, newMax.y), - valueRemap(value.z, min.z, max.z, newMin.z, newMax.z) - ); -} - -#pragma glslify: export(valueRemap)