feat: clear liquid glass and a first-screen stage that shows the blade reflection
This commit is contained in:
1 parent
ed5f6b6282
commit
3d1c60476a
4 files changed
+469
-198
No files matched your search
@@ -1,6 +1,6 @@
|
||||
# bd2-site
|
||||
|
||||
BD2 私服的客户端与服务端下载站,部署在 <https://bd2.flechazo.xin>。纯静态页面,无构建步骤。
|
||||
BD2 离线版的客户端与服务端下载站,部署在 <https://bd2.flechazo.xin>。纯静态页面,无构建步骤。
|
||||
|
||||
- `site/`:站点根目录。背景 `assets/bg.webp` 裁自 SpecialIllust291(2048×1100);`app.js` 用 WebGL 着色器绘制背景光影和所有液态玻璃(按元素实时矩形计算折射、色散、高光,跟随鼠标形变),不支持 WebGL 时退回 CSS `backdrop-filter` 玻璃。`data/latest.json` 记录当前下载文件的版本、大小与 SHA-256;更新日志在浏览器中读取 `/releases/CHANGELOG.md`。
|
||||
- `/releases/` 由 Caddy 只读反代到 BD2 服务端的签名发布目录(`DATA_DIR/releases`),与启动器、服务端自动更新使用同一套文件。
|
||||
|
||||
+50
-2
@@ -62,7 +62,7 @@ a { color: inherit; }
|
||||
.scene .shader { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; transition: opacity 1.4s ease; }
|
||||
.scene.gl.ready .shader { opacity: 1; }
|
||||
.scene.gl .art, .scene.gl .glow, .scene.gl .cursor { display: none; }
|
||||
.scene.gl .grade { background: linear-gradient(90deg, rgba(20, 8, 40, .7) 0%, rgba(20, 8, 40, .28) 45%, rgba(20, 8, 40, 0) 70%), linear-gradient(180deg, rgba(20, 8, 40, .15) 0%, rgba(20, 8, 40, .1) 40%, rgba(14, 5, 28, .75) 100%), rgba(14, 5, 28, var(--dim, 0)); }
|
||||
.scene.gl .grade { background: radial-gradient(42% 34% at 24% 32%, rgba(18, 7, 36, .78), rgba(18, 7, 36, 0) 78%), linear-gradient(180deg, rgba(20, 8, 40, .1) 0%, rgba(20, 8, 40, 0) 45%, rgba(14, 5, 28, .4) 100%), rgba(14, 5, 28, var(--dim, 0)); }
|
||||
|
||||
/* ---------- Liquid glass ---------- */
|
||||
.glass {
|
||||
@@ -144,7 +144,8 @@ a { color: inherit; }
|
||||
main { width: min(1080px, calc(100% - 28px)); margin: 0 auto; }
|
||||
|
||||
/* ---------- Hero ---------- */
|
||||
.hero { padding: clamp(72px, 14vh, 150px) 8px clamp(48px, 9vh, 96px); max-width: 640px; }
|
||||
.stage { min-height: calc(100svh - 70px); display: flex; flex-direction: column; justify-content: space-between; gap: 40px; padding-bottom: clamp(24px, 5vh, 48px); }
|
||||
.hero { padding: clamp(56px, 11vh, 130px) 8px 0; max-width: 600px; }
|
||||
.eyebrow {
|
||||
display: inline-flex; gap: 8px; margin: 0 0 22px; padding: 6px 12px; border-radius: 999px;
|
||||
font: 500 12px/1 var(--mono); letter-spacing: .06em; color: var(--muted);
|
||||
@@ -158,6 +159,8 @@ main { width: min(1080px, calc(100% - 28px)); margin: 0 auto; }
|
||||
}
|
||||
.lede { margin: 18px 0 0; color: var(--muted); font-size: clamp(16px, 1.7vw, 18px); max-width: 30em; text-shadow: 0 1px 16px rgba(20, 8, 40, .7); }
|
||||
.stamp { margin: 22px 0 0; font: 12px var(--mono); color: var(--faint); }
|
||||
html.liquid .lede { color: rgba(246, 240, 255, .9); }
|
||||
html.liquid .stamp { color: rgba(246, 240, 255, .66); }
|
||||
|
||||
/* ---------- Download cards ---------- */
|
||||
.cards { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; align-items: start; }
|
||||
@@ -298,3 +301,48 @@ html.liquid .pill:active { transform: scale(.93); }
|
||||
html.liquid .file { transition: transform .6s var(--spring); }
|
||||
html.liquid .file:hover { transform: scale(1.012); }
|
||||
html.liquid .filter { background: rgba(10, 4, 22, .35); }
|
||||
|
||||
/* ---------- User preferences ---------- */
|
||||
/* Reduced transparency or more contrast: solid panels instead of glass. */
|
||||
html.solid .glass, html.solid .file, html.solid .shell pre {
|
||||
background: rgb(30, 14, 52); -webkit-backdrop-filter: none; backdrop-filter: none;
|
||||
box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .16), 0 16px 40px -20px rgba(0, 0, 0, .8);
|
||||
}
|
||||
html.solid .file, html.solid .shell pre { background: rgb(44, 24, 72); }
|
||||
html.solid .glass::before, html.solid .glass::after { display: none; }
|
||||
html.solid .pill, html.solid .eyebrow, html.solid .filter .thumb, html.solid .lang select { background-color: rgb(70, 44, 104); -webkit-backdrop-filter: none; backdrop-filter: none; }
|
||||
html.solid .lang select { background-image: url("/assets/chevron.svg"); }
|
||||
html.solid .dl { background: rgb(176, 84, 160); }
|
||||
html.solid .scene .grade { background: rgba(14, 5, 28, .55); }
|
||||
html.contrast { --muted: rgba(255, 255, 255, .9); --faint: rgba(255, 255, 255, .75); --hair: rgba(255, 255, 255, .4); }
|
||||
html.contrast .glass, html.contrast .file, html.contrast .pill { box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, .7); }
|
||||
html.contrast .scene .grade { background: rgba(8, 2, 18, .78); }
|
||||
/* Data saving: no illustration, a plain gradient. */
|
||||
html.plain .scene .art, html.plain .scene .glow, html.plain .scene .cursor { display: none; }
|
||||
html.plain .scene { background: radial-gradient(80% 60% at 70% 40%, #5a2a7a, #140a24 70%); }
|
||||
/* Reduced motion. */
|
||||
html.calm .scene .glow { animation: none; }
|
||||
html.calm .scene .art { transition: none; }
|
||||
html.calm .pill:hover, html.calm .pill:active, html.calm .file:hover { transform: none; }
|
||||
|
||||
/* ---------- First screen dock ---------- */
|
||||
.dock { align-self: flex-end; display: grid; grid-template-columns: repeat(2, minmax(0, 240px)); gap: 14px; }
|
||||
.quick { --r: 24px; display: grid; grid-template-columns: 1fr auto; grid-template-rows: auto auto auto; gap: 2px 12px; align-items: center; padding: 16px 16px 16px 18px; }
|
||||
.quick .tag { grid-column: 1; }
|
||||
.quick .qver { grid-column: 1; font: 600 22px/1.2 var(--mono); letter-spacing: -.02em; }
|
||||
.quick .qmeta { grid-column: 1; font-size: 12px; color: var(--muted); }
|
||||
.quick .dl { grid-column: 2; grid-row: 1 / span 3; }
|
||||
.more-files { grid-column: 1 / -1; justify-self: end; font-size: 13px; color: var(--muted); text-decoration: none; padding: 2px 6px; }
|
||||
.more-files::after { content: " ↓"; }
|
||||
.more-files:hover { color: var(--text); }
|
||||
.section-title { margin: 40px 8px 18px; font-size: 28px; letter-spacing: -.025em; scroll-margin-top: 96px; }
|
||||
@media (max-width: 640px) {
|
||||
.dock { align-self: stretch; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
|
||||
.quick { grid-template-columns: 1fr; }
|
||||
.quick .dl { grid-column: 1; grid-row: auto; margin-top: 8px; }
|
||||
}
|
||||
/* Clear glass: content carries its own shadow instead of a frosted backing. */
|
||||
html.liquid main, html.liquid .bar { text-shadow: 0 1px 2px rgba(10, 4, 24, .7), 0 0 12px rgba(10, 4, 24, .6), 0 2px 28px rgba(10, 4, 24, .5); }
|
||||
html.liquid .dl { text-shadow: none; }
|
||||
html.liquid .hero { position: relative; isolation: isolate; }
|
||||
html.liquid .hero::before { content: ""; position: absolute; inset: 0 -14% -18% -22%; z-index: -1; pointer-events: none; background: radial-gradient(closest-side at 46% 62%, rgba(18, 7, 36, .62), rgba(18, 7, 36, .3) 60%, rgba(18, 7, 36, 0)); }
|
||||
+391
-186
@@ -5,9 +5,10 @@ const HTML_LANG = { zh_cn: "zh-CN", zh_tw: "zh-TW", en_us: "en", ja_jp: "ja", ko
|
||||
|
||||
const TEXT = {
|
||||
zh_cn: {
|
||||
title: "BD2 私服下载", brand: "私服", "nav.download": "下载", "nav.changelog": "更新日志", "nav.verify": "校验", lang: "语言",
|
||||
"hero.game": "适配游戏版本", "hero.title": "BD2 私服下载",
|
||||
"hero.lede": "棕色尘埃2 私服的客户端启动器和服务端。这里提供最新版本、更新日志和 SHA-256 校验值。", "hero.published": "发布于",
|
||||
"quick.all": "全部文件与校验值", "files.title": "全部文件",
|
||||
title: "BD2 离线版下载", brand: "离线版", "nav.download": "下载", "nav.changelog": "更新日志", "nav.verify": "校验", lang: "语言",
|
||||
"hero.game": "适配游戏版本", "hero.title": "BD2 离线版下载",
|
||||
"hero.lede": "棕色尘埃2 离线版的客户端启动器和服务端。这里提供最新版本、更新日志和 SHA-256 校验值。", "hero.published": "发布于",
|
||||
"client.tag": "客户端", "client.name": "启动器", "server.tag": "服务端", "server.name": "服务器",
|
||||
"client.hint": "解压后运行 bd2client.exe,选择包含 BrownDust II.exe 的游戏目录,再填写服务器地址。",
|
||||
"server.hint": "解压后运行 bd2server,单人本地服默认监听 8080 端口;网页管理台在 /admin/。",
|
||||
@@ -21,9 +22,10 @@ const TEXT = {
|
||||
"foot.disclaimer": "非官方开发与研究项目,与 Brown Dust II 及其权利人无隶属或授权关系。仅供个人学习、研究和本地非商业测试,禁止转发或二次分发,详见 LICENSE。",
|
||||
},
|
||||
zh_tw: {
|
||||
title: "BD2 私服下載", brand: "私服", "nav.download": "下載", "nav.changelog": "更新日誌", "nav.verify": "校驗", lang: "語言",
|
||||
"hero.game": "適配遊戲版本", "hero.title": "BD2 私服下載",
|
||||
"hero.lede": "棕色塵埃2 私服的用戶端啟動器與伺服端。這裡提供最新版本、更新日誌與 SHA-256 校驗值。", "hero.published": "發布於",
|
||||
"quick.all": "所有檔案與校驗值", "files.title": "所有檔案",
|
||||
title: "BD2 離線版下載", brand: "離線版", "nav.download": "下載", "nav.changelog": "更新日誌", "nav.verify": "校驗", lang: "語言",
|
||||
"hero.game": "適配遊戲版本", "hero.title": "BD2 離線版下載",
|
||||
"hero.lede": "棕色塵埃2 離線版的用戶端啟動器與伺服端。這裡提供最新版本、更新日誌與 SHA-256 校驗值。", "hero.published": "發布於",
|
||||
"client.tag": "用戶端", "client.name": "啟動器", "server.tag": "伺服端", "server.name": "伺服器",
|
||||
"client.hint": "解壓後執行 bd2client.exe,選擇包含 BrownDust II.exe 的遊戲目錄,再填寫伺服器位址。",
|
||||
"server.hint": "解壓後執行 bd2server,單人本機服預設監聽 8080 連接埠;網頁管理台在 /admin/。",
|
||||
@@ -37,9 +39,10 @@ const TEXT = {
|
||||
"foot.disclaimer": "非官方開發與研究專案,與 Brown Dust II 及其權利人無隸屬或授權關係。僅供個人學習、研究與本機非商業測試,禁止轉發或二次散布,詳見 LICENSE。",
|
||||
},
|
||||
en_us: {
|
||||
title: "BD2 Private Server Downloads", brand: "Private Server", "nav.download": "Download", "nav.changelog": "Changelog", "nav.verify": "Verify", lang: "Language",
|
||||
"hero.game": "Built for game version", "hero.title": "BD2 private server downloads",
|
||||
"hero.lede": "The client launcher and server for a Brown Dust II private server, with the latest versions, changelog and SHA-256 checksums.", "hero.published": "Published",
|
||||
"quick.all": "All files and checksums", "files.title": "All files",
|
||||
title: "BD2 Offline Edition Downloads", brand: "Offline", "nav.download": "Download", "nav.changelog": "Changelog", "nav.verify": "Verify", lang: "Language",
|
||||
"hero.game": "Built for game version", "hero.title": "BD2 offline edition downloads",
|
||||
"hero.lede": "The client launcher and server for the Brown Dust II offline edition, with the latest versions, changelog and SHA-256 checksums.", "hero.published": "Published",
|
||||
"client.tag": "Client", "client.name": "Launcher", "server.tag": "Server", "server.name": "Server",
|
||||
"client.hint": "Unzip and run bd2client.exe, pick the game folder that contains BrownDust II.exe, then enter the server address.",
|
||||
"server.hint": "Unzip and run bd2server. A local single-player server listens on port 8080; the web console is at /admin/.",
|
||||
@@ -53,9 +56,10 @@ const TEXT = {
|
||||
"foot.disclaimer": "An unofficial development and research project, not affiliated with or authorized by Brown Dust II or its rights holders. For personal study, research and local non-commercial testing only; do not forward or redistribute. See LICENSE.",
|
||||
},
|
||||
ja_jp: {
|
||||
title: "BD2 プライベートサーバー ダウンロード", brand: "プライベートサーバー", "nav.download": "ダウンロード", "nav.changelog": "更新履歴", "nav.verify": "検証", lang: "言語",
|
||||
"hero.game": "対応ゲームバージョン", "hero.title": "BD2 プライベートサーバー ダウンロード",
|
||||
"hero.lede": "ブラウンダスト2 プライベートサーバーのクライアントランチャーとサーバーです。最新バージョン、更新履歴、SHA-256 チェックサムを掲載しています。", "hero.published": "公開日",
|
||||
"quick.all": "すべてのファイルとチェックサム", "files.title": "すべてのファイル",
|
||||
title: "BD2 オフライン版 ダウンロード", brand: "オフライン版", "nav.download": "ダウンロード", "nav.changelog": "更新履歴", "nav.verify": "検証", lang: "言語",
|
||||
"hero.game": "対応ゲームバージョン", "hero.title": "BD2 オフライン版 ダウンロード",
|
||||
"hero.lede": "ブラウンダスト2 オフライン版のクライアントランチャーとサーバーです。最新バージョン、更新履歴、SHA-256 チェックサムを掲載しています。", "hero.published": "公開日",
|
||||
"client.tag": "クライアント", "client.name": "ランチャー", "server.tag": "サーバー", "server.name": "サーバー",
|
||||
"client.hint": "展開して bd2client.exe を実行し、BrownDust II.exe があるゲームフォルダーを選んでからサーバーのアドレスを入力します。",
|
||||
"server.hint": "展開して bd2server を実行します。ローカルのシングルサーバーは既定でポート 8080 で待ち受け、管理コンソールは /admin/ です。",
|
||||
@@ -69,9 +73,10 @@ const TEXT = {
|
||||
"foot.disclaimer": "非公式の開発・研究プロジェクトであり、Brown Dust II およびその権利者とは提携・許諾関係にありません。個人の学習・研究とローカルでの非商用テストに限り、転送や再配布は禁止です。詳しくは LICENSE を参照してください。",
|
||||
},
|
||||
ko_kr: {
|
||||
title: "BD2 사설 서버 다운로드", brand: "사설 서버", "nav.download": "다운로드", "nav.changelog": "업데이트 내역", "nav.verify": "검증", lang: "언어",
|
||||
"hero.game": "대응 게임 버전", "hero.title": "BD2 사설 서버 다운로드",
|
||||
"hero.lede": "브라운더스트2 사설 서버용 클라이언트 런처와 서버입니다. 최신 버전, 업데이트 내역, SHA-256 체크섬을 제공합니다.", "hero.published": "게시일",
|
||||
"quick.all": "모든 파일과 체크섬", "files.title": "모든 파일",
|
||||
title: "BD2 오프라인 버전 다운로드", brand: "오프라인", "nav.download": "다운로드", "nav.changelog": "업데이트 내역", "nav.verify": "검증", lang: "언어",
|
||||
"hero.game": "대응 게임 버전", "hero.title": "BD2 오프라인 버전 다운로드",
|
||||
"hero.lede": "브라운더스트2 오프라인 버전용 클라이언트 런처와 서버입니다. 최신 버전, 업데이트 내역, SHA-256 체크섬을 제공합니다.", "hero.published": "게시일",
|
||||
"client.tag": "클라이언트", "client.name": "런처", "server.tag": "서버", "server.name": "서버",
|
||||
"client.hint": "압축을 풀고 bd2client.exe를 실행한 뒤 BrownDust II.exe가 있는 게임 폴더를 고르고 서버 주소를 입력하세요.",
|
||||
"server.hint": "압축을 풀고 bd2server를 실행하세요. 로컬 1인 서버는 기본으로 8080 포트를 사용하며 웹 관리 콘솔은 /admin/입니다.",
|
||||
@@ -186,6 +191,14 @@ function renderCards() {
|
||||
date.dateTime = info.date;
|
||||
date.textContent = formatDate(info.date);
|
||||
$("[data-files]", card).replaceChildren(...info.files.map(fileRow));
|
||||
// Quick download: the one-step client package, the server for Linux x86-64.
|
||||
const quick = $(`[data-quick="${component}"]`);
|
||||
const main = info.files.find(f => f.platform === "linux-amd64") || info.files[0];
|
||||
$("[data-qver]", quick).textContent = "v" + info.version.replace(/^.*\+(client|server)\./, "");
|
||||
$("[data-qmeta]", quick).textContent = `${t("plat." + main.platform)} · ${formatSize(main.size)}`;
|
||||
const link = $("[data-qlink]", quick);
|
||||
link.href = main.url;
|
||||
link.setAttribute("download", main.name);
|
||||
renderNotes(card, component, info.version);
|
||||
}
|
||||
}
|
||||
@@ -305,22 +318,59 @@ const ART = { width: 2048, height: 1100, x: .62, y: .45, inset: .04, zoom: 1.03
|
||||
const LIGHTS = [{ u: .46, v: .565, w: 1 }, { u: .93, v: .70, w: .55 }, { u: .60, v: .40, w: .3 }];
|
||||
|
||||
|
||||
// WebGL scene: the graded art with its light (a glint running along the
|
||||
// blade's lit edge, breathing glow at its core and the eyes), and the liquid
|
||||
// glass drawn from every glass element's live rectangle: rim refraction,
|
||||
// chromatic split, frosting, fresnel and specular light from the blade, the
|
||||
// sky and the pointer, with edges that reach toward the pointer. The HTML
|
||||
// keeps only the content; without WebGL the CSS glass remains.
|
||||
// System preferences decide how much of the effect stack runs: reduced motion
|
||||
// freezes animation, reduced transparency or more contrast replaces glass with
|
||||
// solid panels, data saving drops the art and shader, and weak devices skip
|
||||
// the shader. Media query changes apply live.
|
||||
const PREFS = (() => {
|
||||
const query = q => matchMedia(q);
|
||||
const motion = query("(prefers-reduced-motion: reduce)");
|
||||
const transparency = query("(prefers-reduced-transparency: reduce)");
|
||||
const contrast = query("(prefers-contrast: more)");
|
||||
const data = query("(prefers-reduced-data: reduce)");
|
||||
const prefs = {
|
||||
get calm() { return motion.matches; },
|
||||
get solid() { return transparency.matches || contrast.matches; },
|
||||
get contrast() { return contrast.matches; },
|
||||
plain: data.matches || Boolean(navigator.connection && navigator.connection.saveData),
|
||||
weak: (navigator.hardwareConcurrency || 8) <= 2 || (navigator.deviceMemory || 8) < 4,
|
||||
};
|
||||
const apply = () => {
|
||||
const root = document.documentElement.classList;
|
||||
root.toggle("calm", prefs.calm);
|
||||
root.toggle("solid", prefs.solid);
|
||||
root.toggle("contrast", prefs.contrast);
|
||||
root.toggle("plain", prefs.plain);
|
||||
root.toggle("liquid", root.contains("gl") && !prefs.solid);
|
||||
};
|
||||
for (const q of [motion, transparency, contrast]) q.addEventListener("change", apply);
|
||||
prefs.apply = apply;
|
||||
apply();
|
||||
return prefs;
|
||||
})();
|
||||
|
||||
// WebGL2 liquid glass, after Apple's Liquid Glass and the open recreations
|
||||
// (liquid-glass-studio, ptu14/liquid-glass): the graded art is rendered to a
|
||||
// texture, blurred at half resolution, and one pass draws every glass shape
|
||||
// from its live element rectangle. Shapes are rounded-rect SDFs; a Snell
|
||||
// refraction edge factor bends the background at the bezel, with dispersion,
|
||||
// fresnel and a two-sided glare. A glass droplet follows the pointer on a
|
||||
// spring and fuses with nearby glass through a smooth minimum; panels jiggle
|
||||
// on a damped spring while scrolling. Without WebGL2 the CSS glass remains.
|
||||
const MAX_GLASS = 40;
|
||||
// Glass kinds: 0 panel, 1 clear pill, 2 accent pill, 3 inset row, 4 bar.
|
||||
// Kinds: 0 panel, 1 clear pill, 2 accent pill, 3 inset row, 4 bar.
|
||||
const GLASS = [
|
||||
[".bar", 4], [".card", 0], [".log", 0], [".verify", 0], [".file", 3], [".shell pre", 3],
|
||||
[".bar", 4], [".quick", 0], [".card", 0], [".log", 0], [".verify", 0], [".file", 3], [".shell pre", 3],
|
||||
[".eyebrow", 1], [".lang select", 1], [".filter .thumb", 1], [".ghost", 1], [".more", 1], [".dl", 2], [".toast.on", 1],
|
||||
];
|
||||
|
||||
const FRAGMENT = `
|
||||
const VERTEX = `#version 300 es
|
||||
in vec2 p;
|
||||
void main() { gl_Position = vec4(p, 0.0, 1.0); }`;
|
||||
|
||||
// The illustration with its light, in CSS-pixel space (y down).
|
||||
const SCENE = `#version 300 es
|
||||
precision highp float;
|
||||
#define MAX ${MAX_GLASS}
|
||||
uniform sampler2D u_art;
|
||||
uniform vec2 u_res;
|
||||
uniform vec4 u_rect;
|
||||
@@ -329,37 +379,76 @@ uniform float u_hover;
|
||||
uniform float u_time;
|
||||
uniform float u_dim;
|
||||
uniform float u_px;
|
||||
uniform int u_count;
|
||||
uniform vec4 u_glass[MAX];
|
||||
uniform vec4 u_meta[MAX];
|
||||
varying vec2 v_pos;
|
||||
out vec4 color;
|
||||
|
||||
float hash(vec2 p) { return fract(sin(dot(p, vec2(12.9898, 78.233))) * 43758.5453); }
|
||||
|
||||
vec2 bladeA() { return u_rect.xy + vec2(0.0, .44) * u_rect.zw; }
|
||||
vec2 bladeB() { return u_rect.xy + vec2(1.0, .706) * u_rect.zw; }
|
||||
vec2 bladeCore() { return u_rect.xy + vec2(.46, .565) * u_rect.zw; }
|
||||
|
||||
// The graded background with its own light, at screen pixel px.
|
||||
vec3 scene(vec2 px) {
|
||||
float scale = max(u_rect.z / (1000.0 * u_px), .4);
|
||||
vec2 uv = (px - u_rect.xy) / u_rect.zw;
|
||||
vec3 col = texture2D(u_art, uv).rgb;
|
||||
void main() {
|
||||
vec2 px = vec2(gl_FragCoord.x, u_res.y - gl_FragCoord.y);
|
||||
float scale = max(u_rect.z / (1000.0 * u_px), .4) * u_px;
|
||||
vec3 col = texture(u_art, (px - u_rect.xy) / u_rect.zw).rgb;
|
||||
float l = dot(col, vec3(.299, .587, .114));
|
||||
col = mix(col * vec3(.78, .66, 1.02), col, smoothstep(.15, .85, l));
|
||||
col = pow(col * .86, vec3(1.08));
|
||||
vec2 a = bladeA(), ab = bladeB() - a;
|
||||
col = pow(col * .97, vec3(1.04));
|
||||
// Lift the face mirrored in the blade and the wielder's eyes.
|
||||
vec2 iuv = (px - u_rect.xy) / u_rect.zw;
|
||||
float mirror = exp(-pow(length((iuv - vec2(.22, .63)) * vec2(1.0, 1.7)) / .2, 2.0));
|
||||
float gaze = exp(-pow(length((iuv - vec2(.66, .38)) * vec2(1.0, 1.9)) / .2, 2.0));
|
||||
col *= 1.0 + .38 * mirror + .18 * gaze;
|
||||
// Blade edge: v = .44 + .266u in image space.
|
||||
vec2 a = u_rect.xy + vec2(0.0, .44) * u_rect.zw, ab = vec2(u_rect.z, .266 * u_rect.w);
|
||||
float t = clamp(dot(px - a, ab) / dot(ab, ab), 0.0, 1.0);
|
||||
float d = length(px - (a + ab * t)) / (scale * u_px);
|
||||
float d = length(px - (a + ab * t)) / scale;
|
||||
float breathe = .8 + .2 * sin(u_time * .9);
|
||||
float core = exp(-length(px - bladeCore()) / (scale * u_px) / 160.0);
|
||||
float core = exp(-length(px - (u_rect.xy + vec2(.46, .565) * u_rect.zw)) / scale / 160.0);
|
||||
float glint = exp(-pow((t - fract(u_time * .045)) * 9.0, 2.0)) * exp(-d / 14.0) * .9;
|
||||
col += vec3(1.0, .56, .9) * ((exp(-d / 26.0) * .3 + exp(-d / 110.0) * .16) * breathe + core * .28 * breathe) + vec3(1.0, .86, .97) * glint;
|
||||
col += vec3(1.0, .56, .9) * ((exp(-d / 26.0) * .3 + exp(-d / 110.0) * .16 + core * .28) * breathe) + vec3(1.0, .86, .97) * glint;
|
||||
float flicker = .75 + .25 * sin(u_time * 1.7 + sin(u_time * .6) * 2.0);
|
||||
vec2 e1 = u_rect.xy + vec2(.597, .392) * u_rect.zw, e2 = u_rect.xy + vec2(.957, .405) * u_rect.zw;
|
||||
col += vec3(1.0, .2, .32) * (exp(-length(px - e1) / (38.0 * scale * u_px)) + exp(-length(px - e2) / (38.0 * scale * u_px))) * .32 * flicker;
|
||||
return col;
|
||||
}
|
||||
col += vec3(1.0, .2, .32) * (exp(-length(px - e1) / (38.0 * scale)) + exp(-length(px - e2) / (38.0 * scale))) * .32 * flicker;
|
||||
float md = length(px - u_mouse);
|
||||
col += vec3(1.0, .78, .96) * exp(-md * md / (2.0 * pow(260.0 * u_px, 2.0))) * .12 * u_hover;
|
||||
vec2 q = gl_FragCoord.xy / u_res - .5;
|
||||
col *= (1.0 - dot(q, q) * .35) * (1.0 - u_dim * .3);
|
||||
color = vec4(col, 1.0);
|
||||
}`;
|
||||
|
||||
// Separable Gaussian, 13 taps.
|
||||
const BLUR = `#version 300 es
|
||||
precision highp float;
|
||||
uniform sampler2D u_src;
|
||||
uniform vec2 u_step;
|
||||
uniform vec2 u_size;
|
||||
out vec4 color;
|
||||
void main() {
|
||||
vec2 uv = gl_FragCoord.xy / u_size;
|
||||
float w[7] = float[](.1964, .1748, .1232, .0688, .0304, .0107, .0030);
|
||||
vec3 c = texture(u_src, uv).rgb * w[0];
|
||||
for (int i = 1; i < 7; i++) {
|
||||
c += texture(u_src, uv + u_step * float(i)).rgb * w[i];
|
||||
c += texture(u_src, uv - u_step * float(i)).rgb * w[i];
|
||||
}
|
||||
color = vec4(c / (w[0] + 2.0 * (w[1] + w[2] + w[3] + w[4] + w[5] + w[6])), 1.0);
|
||||
}`;
|
||||
|
||||
const GLASS_SHADER = `#version 300 es
|
||||
precision highp float;
|
||||
#define MAX ${MAX_GLASS}
|
||||
#define PI 3.14159265
|
||||
uniform sampler2D u_bg;
|
||||
uniform sampler2D u_blur;
|
||||
uniform vec2 u_res;
|
||||
uniform vec2 u_mouse;
|
||||
uniform vec4 u_drop; // x, y, radius, stretch
|
||||
uniform vec2 u_dropDir; // unit direction of travel
|
||||
uniform vec2 u_light; // the blade's light, px
|
||||
uniform float u_px;
|
||||
uniform float u_time;
|
||||
uniform float u_jiggle; // scroll spring, px
|
||||
uniform int u_count;
|
||||
uniform vec4 u_glass[MAX];
|
||||
uniform vec4 u_meta[MAX]; // radius, kind, hover, layer
|
||||
out vec4 color;
|
||||
|
||||
float hash(vec2 p) { return fract(sin(dot(p, vec2(12.9898, 78.233))) * 43758.5453); }
|
||||
|
||||
float roundRect(vec2 p, vec4 r, float radius) {
|
||||
vec2 h = r.zw * .5;
|
||||
@@ -367,188 +456,302 @@ float roundRect(vec2 p, vec4 r, float radius) {
|
||||
return length(max(q, 0.0)) + min(max(q.x, q.y), 0.0) - radius;
|
||||
}
|
||||
|
||||
// Distance to glass i; the edge reaches toward a nearby pointer like liquid.
|
||||
float glassDist(vec4 r, vec4 m, vec2 p) {
|
||||
float d = roundRect(p, r, m.x);
|
||||
vec2 c = clamp(u_mouse, r.xy, r.xy + r.zw);
|
||||
float near = exp(-pow(length(u_mouse - c) / (70.0 * u_px), 2.0));
|
||||
float pull = exp(-pow(length(p - u_mouse) / (90.0 * u_px), 2.0));
|
||||
return d - (m.w * 6.0 + 7.0 * near) * pull * u_hover * u_px * (m.y == 0.0 || m.y == 4.0 ? .7 : 1.0);
|
||||
// Inigo Quilez's polynomial smooth minimum.
|
||||
float smin(float a, float b, float k) {
|
||||
float h = clamp(.5 + .5 * (b - a) / k, 0.0, 1.0);
|
||||
return mix(b, a, h) - k * h * (1.0 - h);
|
||||
}
|
||||
|
||||
// The pointer's droplet: an ellipse stretched along its travel.
|
||||
float droplet(vec2 p) {
|
||||
if (u_drop.z < .5) return 1e5;
|
||||
vec2 d = p - u_drop.xy;
|
||||
vec2 q = vec2(dot(d, u_dropDir), dot(d, vec2(-u_dropDir.y, u_dropDir.x)));
|
||||
vec2 ab = u_drop.z * vec2(1.0 + u_drop.w, 1.0 / (1.0 + u_drop.w * .7));
|
||||
return (length(q / ab) - 1.0) * min(ab.x, ab.y);
|
||||
}
|
||||
|
||||
void main() {
|
||||
vec2 px = vec2(v_pos.x, 1.0 - v_pos.y) * u_res;
|
||||
vec3 col = scene(px);
|
||||
// Pointer light on the open scene.
|
||||
float md = length(px - u_mouse);
|
||||
col += vec3(1.0, .78, .96) * exp(-md * md / (2.0 * pow(260.0 * u_px, 2.0))) * .14 * u_hover;
|
||||
vec2 frag = gl_FragCoord.xy;
|
||||
vec2 px = vec2(frag.x, u_res.y - frag.y);
|
||||
vec2 uv = frag / u_res;
|
||||
vec3 col = texture(u_bg, uv).rgb;
|
||||
|
||||
// Soft contact shadows under panels.
|
||||
float shade = 0.0;
|
||||
// Per-layer distances. Layer 0 (panels, bar, free pills) fuses with the droplet.
|
||||
float d0 = 1e5, d1 = 1e5, d2 = 1e5;
|
||||
float k0 = 0.0, hov0 = 0.0, hov1 = 0.0, hov2 = 0.0, acc2 = 0.0, bar0 = 0.0;
|
||||
float r0 = 0.0, r1 = 0.0, r2 = 0.0;
|
||||
float kSelf = 6.0 * u_px;
|
||||
for (int i = 0; i < MAX; i++) {
|
||||
if (i >= u_count) break;
|
||||
if (u_meta[i].y == 0.0 || u_meta[i].y == 4.0) {
|
||||
float d = roundRect(px - vec2(0.0, 14.0 * u_px), u_glass[i], u_meta[i].x);
|
||||
shade = max(shade, exp(-max(d, 0.0) / (26.0 * u_px)) * .38);
|
||||
vec4 r = u_glass[i], m = u_meta[i];
|
||||
// Trailing edges lag behind while scrolling, like a jelly.
|
||||
if (m.w == 0.0) {
|
||||
float s = u_jiggle;
|
||||
r.y += min(s, 0.0); r.w += abs(s); r.x += abs(s) * .08; r.z -= abs(s) * .16;
|
||||
}
|
||||
}
|
||||
col *= 1.0 - shade;
|
||||
|
||||
// Topmost glass under this pixel.
|
||||
int top = -1;
|
||||
float topD = 1e5;
|
||||
for (int i = 0; i < MAX; i++) {
|
||||
if (i >= u_count) break;
|
||||
float d = glassDist(u_glass[i], u_meta[i], px);
|
||||
if (d < 1.0 * u_px) { top = i; topD = d; }
|
||||
}
|
||||
if (top >= 0) {
|
||||
vec4 r = vec4(0.0), m = vec4(0.0);
|
||||
for (int i = 0; i < MAX; i++) { if (i == top) { r = u_glass[i]; m = u_meta[i]; } }
|
||||
float kind = m.y;
|
||||
float e = 1.5 * u_px;
|
||||
vec2 n = normalize(vec2(glassDist(r, m, px + vec2(e, 0.0)) - glassDist(r, m, px - vec2(e, 0.0)),
|
||||
glassDist(r, m, px + vec2(0.0, e)) - glassDist(r, m, px - vec2(0.0, e))) + 1e-5);
|
||||
float depth = max(-topD, 0.0);
|
||||
float band = min(kind == 0.0 || kind == 4.0 ? 36.0 : 16.0, m.x / u_px) * u_px;
|
||||
float t = clamp(depth / band, 0.0, 1.0);
|
||||
// Lens: strong bending at the rim, slight magnification inside.
|
||||
float bend = pow(1.0 - t, 2.0) * band * (kind == 0.0 || kind == 4.0 ? 1.15 : 1.4);
|
||||
vec2 center = r.xy + r.zw * .5;
|
||||
vec2 base = center + (px - center) * (1.0 - .035 * (1.0 + m.w));
|
||||
vec2 off = -n * bend;
|
||||
float blur = (kind == 0.0 ? 5.0 : kind == 4.0 ? 4.0 : kind == 3.0 ? 2.5 : 1.0) * u_px;
|
||||
vec3 g = vec3(0.0);
|
||||
float spin = hash(px) * 6.283;
|
||||
for (int k = 0; k < 6; k++) {
|
||||
float a = float(k) * 2.39996 + spin;
|
||||
g += scene(base + off * 1.12 + vec2(cos(a), sin(a)) * blur * sqrt((float(k) + .5) / 6.0));
|
||||
// Hovered pills lean toward the pointer.
|
||||
if (m.y == 1.0 || m.y == 2.0) {
|
||||
vec2 c = r.xy + r.zw * .5, toward = u_mouse - c;
|
||||
r.xy += toward / max(length(toward), 1.0) * min(length(toward) * .08, 5.0 * u_px) * m.z;
|
||||
}
|
||||
g /= 6.0;
|
||||
// Chromatic split along the bend.
|
||||
g.r = mix(g.r, scene(base + off * .92).r, .5);
|
||||
g.b = mix(g.b, scene(base + off * 1.34).b, .5);
|
||||
// Body tint keeps text readable on the busy art.
|
||||
vec3 tint = kind == 2.0 ? vec3(1.0, .55, .88) : vec3(.42, .3, .66);
|
||||
float dark = kind == 0.0 ? .66 : kind == 4.0 ? .74 : kind == 3.0 ? .6 : kind == 2.0 ? .95 : .92;
|
||||
float tintAmount = kind == 2.0 ? .38 : .1;
|
||||
float gl = dot(g, vec3(.299, .587, .114));
|
||||
g = mix(vec3(gl), g, 1.35);
|
||||
g = mix(g, tint * (gl + .25), tintAmount) * dark;
|
||||
g += (kind == 1.0 || kind == 2.0 ? .05 : .015) + .05 * m.z;
|
||||
// Light: the blade from the scene, the pointer, and a soft sky above.
|
||||
vec2 toBlade = normalize(bladeCore() - px);
|
||||
vec2 toMouse = normalize(u_mouse - px);
|
||||
float rim = exp(-depth / (1.1 * u_px)) + exp(-depth / (7.0 * u_px)) * .35;
|
||||
float fresnel = pow(1.0 - t, 3.0);
|
||||
float sBlade = pow(max(dot(n, toBlade), 0.0), 3.0);
|
||||
float sMouse = pow(max(dot(n, toMouse), 0.0), 3.0) * u_hover * exp(-md / (420.0 * u_px));
|
||||
float sSky = pow(max(dot(n, vec2(-.45, -.9)), 0.0), 2.0);
|
||||
float sBack = pow(max(dot(n, vec2(.45, .9)), 0.0), 2.0);
|
||||
vec3 spec = vec3(1.0, .72, .95) * sBlade * 1.1 + vec3(1.0) * sMouse * 1.6 + vec3(.95, .95, 1.0) * sSky * .9 + vec3(.8, .7, 1.0) * sBack * .3;
|
||||
g += spec * (rim * 1.0 + fresnel * .28);
|
||||
g += vec3(1.0) * rim * .1;
|
||||
// Pointer sheen inside the hovered glass.
|
||||
g += vec3(1.0, .9, 1.0) * exp(-md * md / (2.0 * pow(150.0 * u_px, 2.0))) * .07 * m.z;
|
||||
float alpha = smoothstep(1.0 * u_px, -1.0 * u_px, topD);
|
||||
col = mix(col, g, alpha);
|
||||
float d = roundRect(px, r, min(m.x, min(r.z, r.w) * .5));
|
||||
float near = 1.0 - smoothstep(0.0, 24.0 * u_px, d);
|
||||
if (m.w == 0.0) { d0 = smin(d0, d, kSelf); hov0 = max(hov0, m.z * near); bar0 = max(bar0, (m.y == 4.0 ? 1.0 : 0.0) * near); r0 = max(r0, m.x * near); k0 = max(k0, (m.y == 0.0 ? 1.0 : 0.0) * near); }
|
||||
else if (m.w == 1.0) { d1 = smin(d1, d, kSelf); hov1 = max(hov1, m.z * near); r1 = max(r1, m.x * near); }
|
||||
else { d2 = smin(d2, d, kSelf); hov2 = max(hov2, m.z * near); acc2 = max(acc2, (m.y == 2.0 ? 1.0 : 0.0) * near); r2 = max(r2, m.x * near); }
|
||||
}
|
||||
float panels = d0;
|
||||
float dd = droplet(px);
|
||||
float dropShare = clamp(.5 + .5 * (d0 - dd) / (28.0 * u_px), 0.0, 1.0);
|
||||
d0 = smin(d0, dd, 28.0 * u_px);
|
||||
|
||||
vec2 q = v_pos - .5;
|
||||
col *= 1.0 - dot(q, q) * .5;
|
||||
col *= 1.0 - u_dim * .3;
|
||||
col += (hash(px + fract(u_time) * 100.0) - .5) * .024;
|
||||
gl_FragColor = vec4(col, 1.0);
|
||||
// Gradients for all layers before any branching.
|
||||
vec2 g0 = vec2(dFdx(d0), -dFdy(d0)), g1 = vec2(dFdx(d1), -dFdy(d1)), g2 = vec2(dFdx(d2), -dFdy(d2));
|
||||
|
||||
// Soft shadow under the base layer.
|
||||
col *= 1.0 - .3 * (1.0 - smoothstep(0.0, 26.0 * u_px, panels)) * step(0.0, panels);
|
||||
|
||||
for (int l = 0; l < 3; l++) {
|
||||
float d = l == 0 ? d0 : l == 1 ? d1 : d2;
|
||||
if (d > 1.5 * u_px) continue;
|
||||
vec2 g = l == 0 ? g0 : l == 1 ? g1 : g2;
|
||||
vec2 n = g / max(length(g), 1e-4);
|
||||
float hov = l == 0 ? hov0 : l == 1 ? hov1 : hov2;
|
||||
float accent = l == 2 ? acc2 : 0.0;
|
||||
float panel = l == 0 ? max(k0, bar0) * (1.0 - dropShare) : 0.0;
|
||||
// Bezel thickness: thick for panels, thin for pills and rows.
|
||||
float thick = (l == 0 ? mix(20.0, 34.0, panel) : l == 1 ? 14.0 : 16.0) * u_px;
|
||||
float depth = max(-d, 0.0);
|
||||
// Snell edge factor (n = 1.5) over a circular bezel profile.
|
||||
float x = 1.0 - depth / thick;
|
||||
float edge = 0.0;
|
||||
if (x > 0.0) {
|
||||
float ti = asin(clamp(x * x, 0.0, 1.0));
|
||||
float tt = asin(sin(ti) / 1.5);
|
||||
edge = tan(ti - tt);
|
||||
}
|
||||
float reach = (l == 0 ? mix(46.0, 60.0, panel) : 26.0) * u_px;
|
||||
vec2 off = -n * edge * reach;
|
||||
off.y = -off.y;
|
||||
vec2 o = off / u_res;
|
||||
// Dispersion: red bends least, blue most.
|
||||
float spread = .1 * edge;
|
||||
// Clear glass: barely frosted, so the art stays visible beneath.
|
||||
float blurMix = l == 0 ? mix(mix(.0, .16, panel), 0.0, dropShare) : l == 1 ? .1 : .0;
|
||||
vec3 sharp = vec3(texture(u_bg, uv + o * (1.0 - spread)).r, texture(u_bg, uv + o).g, texture(u_bg, uv + o * (1.0 + spread)).b);
|
||||
vec3 soft = vec3(texture(u_blur, uv + o * (1.0 - spread)).r, texture(u_blur, uv + o).g, texture(u_blur, uv + o * (1.0 + spread)).b);
|
||||
vec3 g3 = mix(sharp, soft, blurMix);
|
||||
// Vibrancy and a violet body that keeps text legible on panels.
|
||||
float lum = dot(g3, vec3(.299, .587, .114));
|
||||
g3 = mix(vec3(lum), g3, 1.15);
|
||||
vec3 tint = mix(vec3(.2, .1, .34), vec3(1.0, .52, .86), accent);
|
||||
float body = l == 0 ? mix(mix(.04, .1, panel), 0.0, dropShare) : l == 1 ? .1 : mix(.04, .32, accent);
|
||||
g3 = mix(g3, tint * (accent > .5 ? lum + .3 : 1.0), body);
|
||||
g3 *= l == 0 ? mix(mix(.96, .86, panel), 1.0, dropShare) : .94;
|
||||
g3 += .04 * hov + .05 * (l == 0 ? dropShare : 0.0);
|
||||
// Fresnel: the rim brightens toward white.
|
||||
float fres = pow(clamp(1.0 - depth / (18.0 * u_px), 0.0, 1.0), 5.0);
|
||||
float dropRim = l == 0 ? dropShare : 0.0;
|
||||
g3 = mix(g3, vec3(1.0), fres * (.32 + .25 * dropRim));
|
||||
// Glare: two opposite highlights, the brighter one facing the blade light.
|
||||
vec2 toLight = normalize(u_light - px);
|
||||
float facing = dot(n, toLight);
|
||||
float diag = .5 + .5 * cos(2.0 * (atan(n.y, n.x) - atan(toLight.y, toLight.x)));
|
||||
float glareGeo = pow(clamp(1.0 - depth / (10.0 * u_px), 0.0, 1.0), 3.0);
|
||||
float glare = pow(diag, 4.0) * (facing > 0.0 ? 1.0 : .45) * glareGeo;
|
||||
// The pointer is a second light on nearby rims.
|
||||
vec2 toMouse = u_mouse - px;
|
||||
float mouseGlare = pow(max(dot(n, normalize(toMouse)), 0.0), 3.0) * exp(-length(toMouse) / (160.0 * u_px)) * glareGeo;
|
||||
g3 += (vec3(1.0, .82, .96) * glare * .85 + vec3(1.0) * mouseGlare * .8) * (1.0 + dropRim);
|
||||
float alpha = 1.0 - smoothstep(-1.0 * u_px, 1.0 * u_px, d);
|
||||
col = mix(col, g3, alpha);
|
||||
}
|
||||
col += (hash(px + fract(u_time) * 100.0) - .5) * .022;
|
||||
color = vec4(col, 1.0);
|
||||
}`;
|
||||
|
||||
function shaderScene(scene, art, state) {
|
||||
const canvas = document.createElement("canvas");
|
||||
const gl = canvas.getContext("webgl", { alpha: false, antialias: false, premultipliedAlpha: false });
|
||||
const gl = canvas.getContext("webgl2", { alpha: false, antialias: false, depth: false, stencil: false });
|
||||
if (!gl) return false;
|
||||
const compile = (type, source) => {
|
||||
const s = gl.createShader(type);
|
||||
gl.shaderSource(s, source);
|
||||
gl.compileShader(s);
|
||||
if (!gl.getShaderParameter(s, gl.COMPILE_STATUS)) throw new Error(gl.getShaderInfoLog(s));
|
||||
return s;
|
||||
};
|
||||
let program;
|
||||
try {
|
||||
program = gl.createProgram();
|
||||
gl.attachShader(program, compile(gl.VERTEX_SHADER, "attribute vec2 p; varying vec2 v_pos; void main() { v_pos = p * .5 + .5; gl_Position = vec4(p, 0.0, 1.0); }"));
|
||||
gl.attachShader(program, compile(gl.FRAGMENT_SHADER, FRAGMENT));
|
||||
const build = fragment => {
|
||||
const program = gl.createProgram();
|
||||
for (const [type, source] of [[gl.VERTEX_SHADER, VERTEX], [gl.FRAGMENT_SHADER, fragment]]) {
|
||||
const s = gl.createShader(type);
|
||||
gl.shaderSource(s, source);
|
||||
gl.compileShader(s);
|
||||
if (!gl.getShaderParameter(s, gl.COMPILE_STATUS)) throw new Error(gl.getShaderInfoLog(s));
|
||||
gl.attachShader(program, s);
|
||||
}
|
||||
gl.bindAttribLocation(program, 0, "p");
|
||||
gl.linkProgram(program);
|
||||
if (!gl.getProgramParameter(program, gl.LINK_STATUS)) throw new Error(gl.getProgramInfoLog(program));
|
||||
const cache = {};
|
||||
return { program, u: name => (name in cache ? cache[name] : (cache[name] = gl.getUniformLocation(program, name))) };
|
||||
};
|
||||
let sceneP, blurP, glassP;
|
||||
try {
|
||||
sceneP = build(SCENE); blurP = build(BLUR); glassP = build(GLASS_SHADER);
|
||||
} catch (error) {
|
||||
console.warn("background shader disabled:", error.message);
|
||||
console.warn("liquid glass disabled:", error.message);
|
||||
return false;
|
||||
}
|
||||
gl.useProgram(program);
|
||||
gl.bindBuffer(gl.ARRAY_BUFFER, gl.createBuffer());
|
||||
gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([-1, -1, 1, -1, -1, 1, 1, 1]), gl.STATIC_DRAW);
|
||||
const where = gl.getAttribLocation(program, "p");
|
||||
gl.enableVertexAttribArray(where);
|
||||
gl.vertexAttribPointer(where, 2, gl.FLOAT, false, 0, 0);
|
||||
gl.bindTexture(gl.TEXTURE_2D, gl.createTexture());
|
||||
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
|
||||
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
|
||||
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
|
||||
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
|
||||
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGB, gl.RGB, gl.UNSIGNED_BYTE, art);
|
||||
const u = name => gl.getUniformLocation(program, name);
|
||||
const uniforms = { res: u("u_res"), rect: u("u_rect"), mouse: u("u_mouse"), hover: u("u_hover"), time: u("u_time"),
|
||||
dim: u("u_dim"), px: u("u_px"), count: u("u_count"), glass: u("u_glass"), meta: u("u_meta") };
|
||||
gl.enableVertexAttribArray(0);
|
||||
gl.vertexAttribPointer(0, 2, gl.FLOAT, false, 0, 0);
|
||||
|
||||
const texture = (w, h, data) => {
|
||||
const t = gl.createTexture();
|
||||
gl.bindTexture(gl.TEXTURE_2D, t);
|
||||
if (data) gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGB, gl.RGB, gl.UNSIGNED_BYTE, data);
|
||||
else gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA8, w, h, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
|
||||
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
|
||||
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
|
||||
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
|
||||
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
|
||||
return t;
|
||||
};
|
||||
const artTexture = texture(0, 0, art);
|
||||
let targets = null;
|
||||
const target = (w, h) => {
|
||||
const tex = texture(w, h);
|
||||
const fbo = gl.createFramebuffer();
|
||||
gl.bindFramebuffer(gl.FRAMEBUFFER, fbo);
|
||||
gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, tex, 0);
|
||||
return { tex, fbo, w, h };
|
||||
};
|
||||
const resizeTargets = (w, h) => {
|
||||
if (targets) for (const t of Object.values(targets)) { gl.deleteTexture(t.tex); gl.deleteFramebuffer(t.fbo); }
|
||||
const hw = Math.max(1, w >> 1), hh = Math.max(1, h >> 1);
|
||||
targets = { bg: target(w, h), half: target(hw, hh), blur: target(hw, hh) };
|
||||
};
|
||||
|
||||
canvas.className = "shader";
|
||||
scene.prepend(canvas);
|
||||
scene.classList.add("gl");
|
||||
document.documentElement.classList.add("liquid");
|
||||
document.documentElement.classList.add("gl");
|
||||
PREFS.apply();
|
||||
|
||||
const reduced = matchMedia("(prefers-reduced-motion: reduce)");
|
||||
const rects = new Float32Array(MAX_GLASS * 4), metas = new Float32Array(MAX_GLASS * 4);
|
||||
const hovered = new WeakMap();
|
||||
let radii = new WeakMap();
|
||||
addEventListener("resize", () => { radii = new WeakMap(); });
|
||||
// Lower the render resolution when frames run long.
|
||||
const drop = { x: innerWidth / 2, y: innerHeight / 2, vx: 0, vy: 0, r: 0, dir: [1, 0], stretch: 0 };
|
||||
const jiggle = { s: 0, v: 0, lastY: scrollY };
|
||||
let hover = 0, last = 0, quality = 1, slow = 0;
|
||||
|
||||
function collect(ratio, h) {
|
||||
let count = 0;
|
||||
let count = 0, overPanel = false;
|
||||
const { tx, ty, active } = state.pointer;
|
||||
for (const [selector, kind] of GLASS) {
|
||||
for (const node of $$(selector)) {
|
||||
if (count >= MAX_GLASS) return count;
|
||||
if (count >= MAX_GLASS) return { count, overPanel };
|
||||
const r = node.getBoundingClientRect();
|
||||
if (r.width < 2 || r.height < 2 || r.bottom < -40 || r.top > h + 40) continue;
|
||||
if (r.width < 2 || r.height < 2 || r.bottom < -60 || r.top > h + 60) continue;
|
||||
if (!radii.has(node)) radii.set(node, parseFloat(getComputedStyle(node).borderTopLeftRadius) || 0);
|
||||
const radius = Math.min(radii.get(node), r.width / 2, r.height / 2);
|
||||
const inside = state.pointer.active && state.pointer.tx >= r.left && state.pointer.tx <= r.right && state.pointer.ty >= r.top && state.pointer.ty <= r.bottom;
|
||||
const level = (hovered.get(node) || 0) + ((inside ? 1 : 0) - (hovered.get(node) || 0)) * .15;
|
||||
const inside = active && tx >= r.left && tx <= r.right && ty >= r.top && ty <= r.bottom;
|
||||
if (inside && (kind === 0 || kind === 4)) overPanel = true;
|
||||
const level = (hovered.get(node) || 0) + ((inside ? 1 : 0) - (hovered.get(node) || 0)) * .18;
|
||||
hovered.set(node, level);
|
||||
const layer = kind === 0 || kind === 4 ? 0 : !node.parentElement.closest(".glass") ? 0 : kind === 3 ? 1 : 2;
|
||||
rects.set([r.left * ratio, r.top * ratio, r.width * ratio, r.height * ratio], count * 4);
|
||||
metas.set([radius * ratio, kind, level, kind === 0 || kind === 4 ? 0 : level], count * 4);
|
||||
metas.set([Math.min(radii.get(node), r.width / 2, r.height / 2) * ratio, kind, level, layer], count * 4);
|
||||
count++;
|
||||
}
|
||||
}
|
||||
return count;
|
||||
return { count, overPanel };
|
||||
}
|
||||
|
||||
function physics(overPanel) {
|
||||
const calm = PREFS.calm, p = state.pointer;
|
||||
// Droplet: a damped spring toward the pointer, absorbed over panels.
|
||||
const targetR = !calm && p.active && !overPanel ? 22 : 0;
|
||||
drop.r += (targetR - drop.r) * (targetR > drop.r ? .12 : .2);
|
||||
if (calm) { drop.x = p.tx; drop.y = p.ty; drop.vx = drop.vy = 0; }
|
||||
else {
|
||||
drop.vx = (drop.vx + (p.tx - drop.x) * .16) * .68;
|
||||
drop.vy = (drop.vy + (p.ty - drop.y) * .16) * .68;
|
||||
drop.x += drop.vx; drop.y += drop.vy;
|
||||
}
|
||||
const speed = Math.hypot(drop.vx, drop.vy);
|
||||
if (speed > .3) drop.dir = [drop.vx / speed, drop.vy / speed];
|
||||
drop.stretch += (Math.min(.75, speed / 28) - drop.stretch) * .25;
|
||||
// Scroll jiggle: a spring driven by scroll speed.
|
||||
const dy = scrollY - jiggle.lastY;
|
||||
jiggle.lastY = scrollY;
|
||||
const target = calm ? 0 : Math.max(-16, Math.min(16, dy * .6));
|
||||
jiggle.v = (jiggle.v + (target - jiggle.s) * .22) * .74;
|
||||
jiggle.s += jiggle.v;
|
||||
}
|
||||
|
||||
function draw(now) {
|
||||
requestAnimationFrame(draw);
|
||||
if (document.hidden || now - last < 15) return;
|
||||
if (last && now - last > 26) { if (++slow > 45 && quality > .55) { quality *= .8; slow = 0; } } else slow = Math.max(0, slow - 1);
|
||||
if (document.hidden) { last = 0; return; }
|
||||
if (last && now - last > 30) { if (++slow > 40 && quality > .55) { quality *= .85; slow = 0; } } else slow = Math.max(0, slow - 1);
|
||||
last = now;
|
||||
const ratio = Math.min(devicePixelRatio || 1, 1.25) * quality;
|
||||
const ratio = Math.min(devicePixelRatio || 1, 1.5) * quality;
|
||||
const w = Math.round(innerWidth * ratio), h = Math.round(innerHeight * ratio);
|
||||
if (canvas.width !== w || canvas.height !== h) { canvas.width = w; canvas.height = h; gl.viewport(0, 0, w, h); }
|
||||
if (canvas.width !== w || canvas.height !== h || !targets) { canvas.width = w; canvas.height = h; resizeTargets(w, h); }
|
||||
hover += ((state.pointer.active ? 1 : 0) - hover) * .08;
|
||||
const time = PREFS.calm ? 0 : now / 1000;
|
||||
const r = state.rect;
|
||||
gl.uniform2f(uniforms.res, w, h);
|
||||
gl.uniform4f(uniforms.rect, r.x * ratio, r.y * ratio, r.w * ratio, r.h * ratio);
|
||||
gl.uniform2f(uniforms.mouse, state.pointer.x * ratio, state.pointer.y * ratio);
|
||||
gl.uniform1f(uniforms.hover, hover);
|
||||
gl.uniform1f(uniforms.time, reduced.matches ? 0 : now / 1000);
|
||||
gl.uniform1f(uniforms.dim, state.dim);
|
||||
gl.uniform1f(uniforms.px, ratio);
|
||||
gl.uniform1i(uniforms.count, collect(ratio, innerHeight));
|
||||
gl.uniform4fv(uniforms.glass, rects);
|
||||
gl.uniform4fv(uniforms.meta, metas);
|
||||
|
||||
// 1. Scene.
|
||||
gl.useProgram(sceneP.program);
|
||||
gl.bindFramebuffer(gl.FRAMEBUFFER, targets.bg.fbo);
|
||||
gl.viewport(0, 0, w, h);
|
||||
gl.activeTexture(gl.TEXTURE0);
|
||||
gl.bindTexture(gl.TEXTURE_2D, artTexture);
|
||||
gl.uniform1i(sceneP.u("u_art"), 0);
|
||||
gl.uniform2f(sceneP.u("u_res"), w, h);
|
||||
gl.uniform4f(sceneP.u("u_rect"), r.x * ratio, r.y * ratio, r.w * ratio, r.h * ratio);
|
||||
gl.uniform2f(sceneP.u("u_mouse"), state.pointer.x * ratio, state.pointer.y * ratio);
|
||||
gl.uniform1f(sceneP.u("u_hover"), hover);
|
||||
gl.uniform1f(sceneP.u("u_time"), time);
|
||||
gl.uniform1f(sceneP.u("u_dim"), state.dim);
|
||||
gl.uniform1f(sceneP.u("u_px"), ratio);
|
||||
gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);
|
||||
|
||||
// 2. Blur at half resolution.
|
||||
gl.useProgram(blurP.program);
|
||||
const { half, blur } = targets;
|
||||
for (const [src, dst, dx, dy] of [[targets.bg, half, 1, 0], [half, blur, 0, 1]]) {
|
||||
gl.bindFramebuffer(gl.FRAMEBUFFER, dst.fbo);
|
||||
gl.viewport(0, 0, dst.w, dst.h);
|
||||
gl.bindTexture(gl.TEXTURE_2D, src.tex);
|
||||
gl.uniform1i(blurP.u("u_src"), 0);
|
||||
gl.uniform2f(blurP.u("u_size"), dst.w, dst.h);
|
||||
gl.uniform2f(blurP.u("u_step"), dx * 1.6 / dst.w, dy * 1.6 / dst.h);
|
||||
gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);
|
||||
}
|
||||
|
||||
// 3. Glass.
|
||||
const { count, overPanel } = PREFS.solid ? { count: 0, overPanel: false } : collect(ratio, innerHeight);
|
||||
physics(overPanel);
|
||||
gl.useProgram(glassP.program);
|
||||
gl.bindFramebuffer(gl.FRAMEBUFFER, null);
|
||||
gl.viewport(0, 0, w, h);
|
||||
gl.activeTexture(gl.TEXTURE0);
|
||||
gl.bindTexture(gl.TEXTURE_2D, targets.bg.tex);
|
||||
gl.activeTexture(gl.TEXTURE1);
|
||||
gl.bindTexture(gl.TEXTURE_2D, blur.tex);
|
||||
gl.activeTexture(gl.TEXTURE0);
|
||||
const u = glassP.u;
|
||||
gl.uniform1i(u("u_bg"), 0);
|
||||
gl.uniform1i(u("u_blur"), 1);
|
||||
gl.uniform2f(u("u_res"), w, h);
|
||||
gl.uniform2f(u("u_mouse"), state.pointer.x * ratio, state.pointer.y * ratio);
|
||||
gl.uniform4f(u("u_drop"), drop.x * ratio, drop.y * ratio, PREFS.solid ? 0 : drop.r * ratio, drop.stretch);
|
||||
gl.uniform2f(u("u_dropDir"), drop.dir[0], drop.dir[1]);
|
||||
gl.uniform2f(u("u_light"), (r.x + .46 * r.w) * ratio, (r.y + .565 * r.h) * ratio);
|
||||
gl.uniform1f(u("u_px"), ratio);
|
||||
gl.uniform1f(u("u_time"), time);
|
||||
gl.uniform1f(u("u_jiggle"), jiggle.s * ratio);
|
||||
gl.uniform1i(u("u_count"), count);
|
||||
gl.uniform4fv(u("u_glass"), rects);
|
||||
gl.uniform4fv(u("u_meta"), metas);
|
||||
gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);
|
||||
}
|
||||
requestAnimationFrame(draw);
|
||||
@@ -557,15 +760,17 @@ function shaderScene(scene, art, state) {
|
||||
|
||||
function sceneLight() {
|
||||
const scene = $(".scene");
|
||||
const reduced = matchMedia("(prefers-reduced-motion: reduce)");
|
||||
const fine = matchMedia("(pointer: fine)");
|
||||
const pointer = { x: innerWidth / 2, y: innerHeight / 3, tx: innerWidth / 2, ty: innerHeight / 3, active: false };
|
||||
let frame = 0, settle = 0;
|
||||
|
||||
const state = { pointer, rect: { x: 0, y: 0, w: 1, h: 1 }, dim: 0 };
|
||||
const art = new Image();
|
||||
art.src = "/assets/bg.webp";
|
||||
art.decode().then(() => shaderScene(scene, art, state)).catch(() => {}).finally(() => scene.classList.add("ready"));
|
||||
if (PREFS.plain) scene.classList.add("ready");
|
||||
else {
|
||||
art.src = "/assets/bg.webp";
|
||||
art.decode().then(() => PREFS.weak || shaderScene(scene, art, state)).catch(() => {}).finally(() => scene.classList.add("ready"));
|
||||
}
|
||||
|
||||
function project(u, v, bx, by) {
|
||||
const w = innerWidth, h = innerHeight;
|
||||
@@ -578,7 +783,7 @@ function sceneLight() {
|
||||
|
||||
function update() {
|
||||
frame = 0;
|
||||
const w = innerWidth, h = innerHeight, still = reduced.matches;
|
||||
const w = innerWidth, h = innerHeight, still = PREFS.calm;
|
||||
pointer.x += (pointer.tx - pointer.x) * (still ? 1 : .14);
|
||||
pointer.y += (pointer.ty - pointer.y) * (still ? 1 : .14);
|
||||
const bx = still || !fine.matches ? 0 : -(pointer.x / w - .5) * 26;
|
||||
|
||||
+27
-9
@@ -3,8 +3,8 @@
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>BD2 私服下载</title>
|
||||
<meta name="description" content="棕色尘埃2 私服的客户端启动器与服务端下载,附更新日志与 SHA-256 校验。">
|
||||
<title>BD2 离线版下载</title>
|
||||
<meta name="description" content="棕色尘埃2 离线版的客户端启动器与服务端下载,附更新日志与 SHA-256 校验。">
|
||||
<meta name="color-scheme" content="dark">
|
||||
<meta name="theme-color" content="#140a24">
|
||||
<link rel="icon" href="/assets/icon.svg" type="image/svg+xml">
|
||||
@@ -23,7 +23,7 @@
|
||||
<header class="bar glass">
|
||||
<a class="brand" href="#top" aria-label="BD2">
|
||||
<span class="mark">BD2</span>
|
||||
<span class="sub" data-i18n="brand">私服</span>
|
||||
<span class="sub" data-i18n="brand">离线版</span>
|
||||
</a>
|
||||
<nav>
|
||||
<a href="#download" data-i18n="nav.download">下载</a>
|
||||
@@ -43,14 +43,32 @@
|
||||
</header>
|
||||
|
||||
<main id="top">
|
||||
<section class="hero">
|
||||
<p class="eyebrow"><span data-i18n="hero.game">适配游戏版本</span> <b id="game-version">—</b></p>
|
||||
<h1 data-i18n="hero.title">BD2 私服下载</h1>
|
||||
<p class="lede" data-i18n="hero.lede">棕色尘埃2 私服的客户端启动器和服务端。这里提供最新版本、更新日志和 SHA-256 校验值。</p>
|
||||
<p class="stamp"><span data-i18n="hero.published">发布于</span> <time id="published">—</time></p>
|
||||
<section class="stage">
|
||||
<div class="hero">
|
||||
<p class="eyebrow"><span data-i18n="hero.game">适配游戏版本</span> <b id="game-version">—</b></p>
|
||||
<h1 data-i18n="hero.title">BD2 离线版下载</h1>
|
||||
<p class="lede" data-i18n="hero.lede">棕色尘埃2 离线版的客户端启动器和服务端。这里提供最新版本、更新日志和 SHA-256 校验值。</p>
|
||||
<p class="stamp"><span data-i18n="hero.published">发布于</span> <time id="published">—</time></p>
|
||||
</div>
|
||||
<div class="dock">
|
||||
<div class="quick glass" data-quick="client">
|
||||
<span class="tag" data-i18n="client.tag">客户端</span>
|
||||
<b class="qver" data-qver>—</b>
|
||||
<span class="qmeta" data-qmeta>—</span>
|
||||
<a class="dl pill" data-qlink href="#download"><span data-i18n="download">下载</span></a>
|
||||
</div>
|
||||
<div class="quick glass" data-quick="server">
|
||||
<span class="tag" data-i18n="server.tag">服务端</span>
|
||||
<b class="qver" data-qver>—</b>
|
||||
<span class="qmeta" data-qmeta>—</span>
|
||||
<a class="dl pill" data-qlink href="#download"><span data-i18n="download">下载</span></a>
|
||||
</div>
|
||||
<a class="more-files" href="#download" data-i18n="quick.all">全部文件与校验值</a>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section id="download" class="cards" aria-label="下载">
|
||||
<h2 class="section-title" id="download" data-i18n="files.title">全部文件</h2>
|
||||
<section class="cards" aria-label="下载">
|
||||
<article class="card glass" id="client" data-component="client">
|
||||
<header>
|
||||
<span class="tag" data-i18n="client.tag">客户端</span>
|
||||
|
||||
Reference in new issue
Block a user