Files
openchamber-android-native/third_party/mygo/plugins/glass/blur.hlsl
T
OpenChamber 6c0ee61750 feat: port the client to MyGo native UI (0.3.0)
Switch from Asuka to MyGo, keeping the API client and the feature set:

- servers: saved servers, passwordless and password login, proxy,
  self-signed certificates, per-server device tokens (Keystore), connect
  form, instance list sheet with switch/disconnect
- sessions: virtualized list, search, new session, rename/archive/delete,
  running indicator, event stream keeps it live
- chat: pushed window with system back bar, streaming Markdown via
  ui/markdown, reasoning and tool rows with image previews, footer menu
  (read aloud via a Kotlin TTS plugin, copy, fork), user message menu
  (copy, revert, fork), context usage ring and detail sheet, attachments
  (photos/files via the document picker), permissions
- release builds allow plain http:// LAN servers (Go's net/http dials
  directly, no cleartext manifest needed)
- a local fork of MyGo (third_party/mygo) lowers the Android host's
  minSdk to 24 (Android 7.0); Go 1.27.4 via mise

Version 0.3.0.
2026-11-18 13:22:59 +08:00

36 lines
1.2 KiB
HLSL

// A level of the blur's effect in HLSL (see scene.Effect), as blur.metal
// is in Metal Shading Language and blur.go draws it on the CPU.
float4 blurAt(int2 p, int2 size) { return backdropTex.Load(int3(clamp(p, int2(0, 0), size - 1), 0)); }
float4 blurSample(Effect e, float2 q) {
q = framePoint(e, q);
float2 u = (q - e.area.xy) / e.down - 0.5;
float2 f = floor(u);
float2 w = u - f;
int2 p = int2(f);
int2 size = int2(e.area.zw);
float4 top = blurAt(p, size) * (1 - w.x) + blurAt(p + int2(1, 0), size) * w.x;
float4 bot = blurAt(p + int2(0, 1), size) * (1 - w.x) + blurAt(p + int2(1, 1), size) * w.x;
return top * (1 - w.y) + bot * w.y;
}
float4 effect(float2 p, Effect e) {
float2 d = e.p0.zw - e.p0.xy;
float l = d.x * d.x + d.y * d.y;
float t = 0;
if (l > 0) {
t = saturate(((p.x - e.p0.x) * d.x + (p.y - e.p0.y) * d.y) / max(l, 0.0001));
}
float blur = e.p1.x * (1 - t) + e.p1.y * t;
float w = saturate((blur - e.p1.z) / (e.p1.w - e.p1.z));
if (w <= 0) {
return float4(0, 0, 0, 0);
}
float4 c = blurSample(e, p);
float lum = 0.2126 * c.r + 0.7152 * c.g + 0.0722 * c.b;
c.rgb = clamp(lum + (c.rgb - lum) * (1 + e.p2.x) + e.p2.y * c.a, 0, c.a);
c += (float4(e.p3.rgb, 1) - c) * e.p2.z;
return c * w;
}