Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
aae21ff
fix: streamline slider glass interaction path
hoshiizumiya Sep 17, 2026
f803310
tune slider active glass response
hoshiizumiya Sep 17, 2026
a165f09
docs: document WinUI.LiquidGlass controls
hoshiizumiya Sep 17, 2026
9e23177
docs: link liquid glass controls guide
hoshiizumiya Sep 17, 2026
c4ab62e
docs: surface WinUI.LiquidGlass package
hoshiizumiya Sep 17, 2026
0dae4d5
docs: 补充 WinUI.LiquidGlass 控件文档
hoshiizumiya Sep 17, 2026
cf33b07
perf: narrow slider optical hot path
hoshiizumiya Sep 17, 2026
b5b575e
fix: detach slider glass lens from native thumb
hoshiizumiya Sep 18, 2026
54d91d5
fix: restore switch glass body contrast
hoshiizumiya Sep 18, 2026
cb831a4
fix: align switch active glass response with Kube
hoshiizumiya Sep 18, 2026
06ac9cb
fix: bind switch glass directly to knob surface
hoshiizumiya Sep 18, 2026
bc7a70f
fix: hide native slider thumb visual completely
hoshiizumiya Sep 18, 2026
4c9e26c
refactor: keep switch spring state continuous
hoshiizumiya Sep 18, 2026
7e99d1b
fix: strengthen switch rest glass body
hoshiizumiya Sep 18, 2026
052958a
fix: preserve transparent pressed switch state
hoshiizumiya Sep 18, 2026
3c33b0c
fix: center initial scale before first layout
hoshiizumiya Sep 18, 2026
b4057cc
fix: sync slider after layout and match Kube press spring
hoshiizumiya Sep 18, 2026
cc49f68
fix: use WinRT event token for slider layout sync
hoshiizumiya Sep 18, 2026
79037af
fix: commit switch drag state on capture loss
hoshiizumiya Sep 18, 2026
d50ba51
tune active slider and switch glass response
hoshiizumiya Sep 18, 2026
7e706b1
refine compact glass optical presets
hoshiizumiya Sep 18, 2026
f188cd1
fix: match Kube slider rest material
hoshiizumiya Sep 18, 2026
3dfd3b9
fix: strengthen active slider glass optics
hoshiizumiya Sep 18, 2026
b0c8ff7
fix: keep switch drag state authoritative
hoshiizumiya Sep 18, 2026
319b7da
Code style
hoshiizumiya Sep 18, 2026
981c3ea
fix: make pointer field material tracking teardown-safe
hoshiizumiya Sep 18, 2026
6a761ae
fix: stabilize slider lens across subtree reloads
hoshiizumiya Sep 18, 2026
0600548
fix: give switch knob non-clipping overscan
hoshiizumiya Sep 18, 2026
334c5cc
fix: align active glass optics with Kube
hoshiizumiya Sep 18, 2026
e3bf6e1
fix: make child glass replacement teardown-safe
hoshiizumiya Sep 18, 2026
6808a96
fix: drop stale optics owners on brush replacement
hoshiizumiya Sep 18, 2026
215be39
fix: keep switch optics independent of checked state
hoshiizumiya Sep 18, 2026
d10106f
fix: match Kube inset shadow states
hoshiizumiya Sep 18, 2026
fb718c0
fix: keep switch outer shadow stable while pressed
hoshiizumiya Sep 18, 2026
5bd2bdd
fix: refresh local glass field with pressed optics
hoshiizumiya Sep 18, 2026
fda4903
fix: remove layered ThemeShadow from glass knobs
hoshiizumiya Sep 18, 2026
6c88bb8
fix: keep slider and switch specular single-layer
hoshiizumiya Sep 18, 2026
e34b61d
fix: keep switch layout footprint at track bounds
hoshiizumiya Sep 18, 2026
6ea13fd
fix: keep Kube specular opacity stable on press
hoshiizumiya Sep 18, 2026
e7dbee5
feat: make switch glyph height-scalable
hoshiizumiya Sep 18, 2026
4225ef0
fix: avoid recursive press optics refresh hook
hoshiizumiya Sep 18, 2026
ca3265a
fix: restore switch glyph hit testing
hoshiizumiya Sep 18, 2026
e956bbb
fix: use compact switch default footprint
hoshiizumiya Sep 18, 2026
d92e369
fix: preserve rounded glass coverage at brush edges
hoshiizumiya Sep 18, 2026
83d6272
fix: avoid double-applied active refraction
hoshiizumiya Sep 18, 2026
75adce5
fix: clamp glass spectral samples independently
hoshiizumiya Sep 18, 2026
6bf36f4
fix: restore Kube slider displacement response
hoshiizumiya Sep 18, 2026
3a81e42
fix: keep concave refraction inside valid transmission
hoshiizumiya Sep 18, 2026
70a6271
fix: make standalone concave refraction composition-safe
hoshiizumiya Sep 18, 2026
d20b46c
fix: restore slider active spatial refraction
hoshiizumiya Sep 18, 2026
eca5fe7
fix: keep slider refraction stable while scaling
hoshiizumiya Sep 18, 2026
a144d90
fix: isolate slider optics from visual scale
hoshiizumiya Sep 18, 2026
0716086
fix: decouple slider material optics from scale spring
hoshiizumiya Sep 18, 2026
2597983
fix: match slider optical preset to Kube
hoshiizumiya Sep 18, 2026
17e4dde
fix: animate slider effect properties on property set
hoshiizumiya Sep 18, 2026
033ca1a
fix: honor zero liquid glass border thickness
hoshiizumiya Sep 18, 2026
9fa9aa2
fix: match Kube slider optical spring directions
hoshiizumiya Sep 18, 2026
4121a6d
fix: remove non-Kube pointer optics from slider
hoshiizumiya Sep 18, 2026
b8a3634
fix: composite slider white body after glass optics
hoshiizumiya Sep 18, 2026
87d4498
fix: preserve authored slider optical bounds
hoshiizumiya Sep 18, 2026
dffdf94
fix: scale slider optical geometry for raster DPI
hoshiizumiya Sep 18, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 35 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,19 @@

<h1 align="center">WinUI.Composition.Hlsl</h1>

<p align="center">Native HLSL nodes for WinUI 3 Composition, plus XAML material brushes.</p>
<p align="center">Native HLSL nodes for WinUI 3 Composition, plus XAML material brushes and native liquid-glass controls.</p>
<p align="center"><a href="README.md">English</a> · <a href="README_zh_cn.md">简体中文</a></p>

<p align="center">
<a href="https://github.com/Millennium-Science-Technology-R-D-Inst/WinUI.Composition.Hlsl/actions/workflows/ci.yml"><img alt="CI" src="https://github.com/Millennium-Science-Technology-R-D-Inst/WinUI.Composition.Hlsl/actions/workflows/ci.yml/badge.svg?branch=master"></a>
<a href="https://www.nuget.org/packages/WinUI.Composition.Hlsl"><img alt="NuGet" src="https://img.shields.io/nuget/v/WinUI.Composition.Hlsl?logo=nuget"></a>
<a href="https://www.nuget.org/packages/WinUI.Composition.Hlsl"><img alt="WinUI.Composition.Hlsl NuGet" src="https://img.shields.io/nuget/v/WinUI.Composition.Hlsl?logo=nuget"></a>
<a href="https://www.nuget.org/packages/WinUI.LiquidGlass"><img alt="WinUI.LiquidGlass NuGet" src="https://img.shields.io/nuget/v/WinUI.LiquidGlass?logo=nuget"></a>
<a href="LICENSE.txt"><img alt="License" src="https://img.shields.io/badge/license-MIT-blue.svg"></a>
<img alt="C++23" src="https://img.shields.io/badge/C%2B%2B-23-00599C?logo=cplusplus">
<img alt="WinUI 3" src="https://img.shields.io/badge/WinUI-3-0078D4">
</p>

## What this package does
## What this repository does

`WinUI.Composition.Hlsl` lets application HLSL participate in the existing Windows Graphics Effects / `Microsoft.UI.Composition` / WinUI 3 XAML pipeline:

Expand All @@ -30,9 +31,27 @@ HLSL / FXC linkable library

It is not an app-owned D3D renderer: no `SwapChainPanel`, custom presentation loop, overlay HWND, or second visual tree is required. The public API is WinRT and is consumable from C++/WinRT and C#.

The repository also contains `WinUI.LiquidGlass`, a native C++/WinRT WinUI 3 control library built on top of the core material. It keeps native WinUI input/layout/UI Automation semantics while adding liquid-glass visuals, optical interaction, spring motion, and reusable control presets.

## Packages

| Package | Purpose |
| --- | --- |
| `WinUI.Composition.Hlsl` | Core HLSL/Composition runtime, effect graph API, `LiquidGlassMaterial`, and `LiquidGlassBrush`. |
| `WinUI.LiquidGlass` | Native WinUI 3 liquid-glass controls and templates; depends on the matching core package. |

For controls, reference both packages using matching versions:

```xml
<ItemGroup>
<PackageReference Include="WinUI.Composition.Hlsl" Version="1.0.*" />
<PackageReference Include="WinUI.LiquidGlass" Version="1.0.*" />
</ItemGroup>
```

## Requirements and compatibility

The NuGet package requires **Windows App SDK 1.6 or later** and ships native runtime assets for **x86, x64, and ARM64**.
The NuGet packages require **Windows App SDK 1.6 or later** and ship native runtime assets for **x86, x64, and ARM64**.

Each validated `master` push is published automatically to NuGet.org as a stable `1.0.<CI run number>` package.

Expand All @@ -50,12 +69,14 @@ Custom shader execution relies on a private, undocumented Composition implementa
- Immutable/cachable `HlslShaderLibrary` objects.
- Composition property paths/setters and Composition-thread animation.
- `LiquidGlassMaterial` and `LiquidGlassBrush`.
- Native `WinUI.LiquidGlass` controls including card, magnifier, buttons, choice controls, Slider, input controls, ToggleSwitch, and TabBar.
- Separable Gaussian backdrop blur, SDF coverage, refraction/magnification, chromatic dispersion, pointer specular lighting, and control-specific motion/elevation.

The public contract does not yet claim multi-source `MaterializedSampler`, arbitrary multi-custom-node graph lowering, or arbitrary native nodes after a custom materialized pass. Those graph-planning features are being developed separately rather than being enabled by removing safety checks.

## Quick start

Add the package and a shader item:
Add the core package and a shader item:

```xml
<ItemGroup>
Expand Down Expand Up @@ -132,7 +153,7 @@ Compilation and structural validation are setup operations, not rendering operat
- rendering does not repeatedly reflect DXBC;
- `GetRuntimeCapabilities()` is side-effect free and does not probe/patch the private runtime.

The package keeps runtime checks for facts that are only known at runtime (for example source object/count validity), while deterministic shader-authoring errors are handled by the compiler/build pipeline whenever possible.
Control hot paths follow the same principle. Value/pointer updates should modify existing Composition state, not walk XAML templates or allocate brushes every frame. See the Slider section in [WinUI.LiquidGlass controls](docs/liquid-glass-controls.md).

## Documentation

Expand All @@ -141,8 +162,9 @@ Start with the documentation set rather than treating the README as the API manu
1. [Get started](docs/get-started.md)
2. [Concepts](docs/concepts.md)
3. [Architecture](docs/architecture.md)
4. [API reference](docs/api/index.md)
5. [Design notes](docs/index.md#design-reference)
4. [WinUI.LiquidGlass controls](docs/liquid-glass-controls.md)
5. [API reference](docs/api/index.md)
6. [Design notes](docs/index.md#design-reference)

Useful references:

Expand All @@ -152,6 +174,9 @@ Useful references:
- [HlslShaderLibrary](docs/api/hlsl-shader-library.md)
- [HlslProperty](docs/api/hlsl-property.md)
- [HlslRuntimeCapabilities](docs/api/hlsl-runtime-capabilities.md)
- [LiquidGlassBrush](docs/api/liquid-glass-brush.md)
- [LiquidGlassMaterial](docs/api/liquid-glass-material.md)
- [WinUI.LiquidGlass controls](docs/liquid-glass-controls.md)
- [Sampler resource binding contract](docs/design/resource-binding-contract.md)
- [Materialized graph compilation](docs/design/materialized-graph-runtime.md)

Expand All @@ -166,12 +191,12 @@ Useful references:
.\tests\build.ps1 -Language CSharp
```

CI builds x64/Win32/ARM64 native assets, the CsWinRT projection, generated shader fixtures, a NuGet package, and downstream C++/C# package consumers. Successful `master` push runs publish that validated package directly from `ci.yml` to NuGet.org through OIDC trusted publishing.
CI builds x64/Win32/ARM64 native assets, the CsWinRT projection, generated shader fixtures, both NuGet packages, and downstream C++/C# package consumers. Successful `master` push runs publish the validated packages directly from `ci.yml` to NuGet.org through OIDC trusted publishing.

## License

[MIT License](LICENSE.txt).

## Thanks

Inspired by @apkipa's WUILiquidGlassDemo work.
Inspired by @apkipa's WUILiquidGlassDemo work.
47 changes: 36 additions & 11 deletions README_zh_cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,19 @@

<h1 align="center">WinUI.Composition.Hlsl</h1>

<p align="center">让自定义 HLSL 作为 WinUI 3 Composition 原生 effect node 工作,并最终回到 XAML Brush。</p>
<p align="center">让自定义 HLSL 作为 WinUI 3 Composition 原生 effect node 工作,并提供 XAML Brush 与原生液态玻璃控件。</p>
<p align="center"><a href="README.md">English</a> · <a href="README_zh_cn.md">简体中文</a></p>

<p align="center">
<a href="https://github.com/Millennium-Science-Technology-R-D-Inst/WinUI.Composition.Hlsl/actions/workflows/ci.yml"><img alt="CI" src="https://github.com/Millennium-Science-Technology-R-D-Inst/WinUI.Composition.Hlsl/actions/workflows/ci.yml/badge.svg?branch=master"></a>
<a href="https://www.nuget.org/packages/WinUI.Composition.Hlsl"><img alt="NuGet" src="https://img.shields.io/nuget/v/WinUI.Composition.Hlsl?logo=nuget"></a>
<a href="https://www.nuget.org/packages/WinUI.Composition.Hlsl"><img alt="WinUI.Composition.Hlsl NuGet" src="https://img.shields.io/nuget/v/WinUI.Composition.Hlsl?logo=nuget"></a>
<a href="https://www.nuget.org/packages/WinUI.LiquidGlass"><img alt="WinUI.LiquidGlass NuGet" src="https://img.shields.io/nuget/v/WinUI.LiquidGlass?logo=nuget"></a>
<a href="LICENSE.txt"><img alt="License" src="https://img.shields.io/badge/license-MIT-blue.svg"></a>
<img alt="C++23" src="https://img.shields.io/badge/C%2B%2B-23-00599C?logo=cplusplus">
<img alt="WinUI 3" src="https://img.shields.io/badge/WinUI-3-0078D4">
</p>

## 这个包解决什么问题
## 这个仓库解决什么问题

`WinUI.Composition.Hlsl` 把应用自己的 HLSL 接入现有 Windows Graphics Effects / `Microsoft.UI.Composition` / WinUI 3 XAML 渲染链:

Expand All @@ -30,11 +31,29 @@ HLSL / FXC linkable library

它不是应用自管的 D3D renderer,不需要 `SwapChainPanel`、自己的 present loop、额外 HWND overlay 或第二套 visual tree。公共 API 是 WinRT,可同时供 C++/WinRT 和 C# 使用。

仓库还包含 `WinUI.LiquidGlass`:建立在 core material 之上的原生 C++/WinRT WinUI 3 控件库。它保留 WinUI 原生输入、布局和 UI Automation 语义,同时提供液态玻璃材质、光学交互、spring 动效与控件预设。

## NuGet 包

| 包 | 用途 |
| --- | --- |
| `WinUI.Composition.Hlsl` | HLSL/Composition 核心运行时、effect graph API、`LiquidGlassMaterial`、`LiquidGlassBrush`。 |
| `WinUI.LiquidGlass` | 原生 WinUI 3 液态玻璃控件与模板;依赖相同版本的 core 包。 |

使用控件库时建议两个包保持相同版本:

```xml
<ItemGroup>
<PackageReference Include="WinUI.Composition.Hlsl" Version="1.0.*" />
<PackageReference Include="WinUI.LiquidGlass" Version="1.0.*" />
</ItemGroup>
```

## 版本与兼容性

NuGet 包最低依赖 **Windows App SDK 1.6**,并提供 **x86、x64、ARM64** 三种 native runtime asset。

每次通过验证的 `master` push 都会自动发布正式 NuGet 包,版本格式为 `1.0.<CI run number>`;例如 CI #80 对应 `1.0.80`。
每次通过验证的 `master` push 都会自动发布正式 NuGet 包,版本格式为 `1.0.<CI run number>`。

Custom shader backend 依赖未公开的 Composition 私有实现 ABI。遇到无法安全识别的布局时会 fail closed,而不是继续向未知私有结构写入猜测数据。实现细节、支持边界和运行时安全约束见 [整体架构](docs/architecture.md) 与 [Runtime safety](docs/design/runtime-safety.md)。

Expand All @@ -49,13 +68,15 @@ Custom shader backend 依赖未公开的 Composition 私有实现 ABI。遇到
- `HlslCompiler` 提供真正需要动态源码时的异步编译;
- `HlslShaderLibrary` 可缓存、持久化、重新加载;
- Composition property path/setter 与 Composition animation;
- `LiquidGlassMaterial` / `LiquidGlassBrush`。
- `LiquidGlassMaterial` / `LiquidGlassBrush`;
- `WinUI.LiquidGlass` 原生控件:Card、Magnifier、Button、Choice、Slider、输入控件、ToggleSwitch、TabBar 等;
- separable Gaussian backdrop blur、SDF coverage、折射/放大、色散、pointer specular、按控件区分的 motion/elevation。

当前还没有把 multi-source `MaterializedSampler`、任意多个 custom node 的 graph lowering、custom materialized pass 后任意 native node 宣布为公开稳定能力。这些会通过正式 graph/pass planner 继续推进,而不是简单删掉安全判断。

## 最短上手

项目中加入包和 shader:
项目中加入 core 包和 shader:

```xml
<ItemGroup>
Expand Down Expand Up @@ -132,7 +153,7 @@ Sampler 所需的 private `PSBody*` edge-mode wrapper 以及 `textureN` / `sampl
- render 时不会反复做 DXBC reflection;
- `GetRuntimeCapabilities()` 无副作用,不会为了查询 capability 去扫描/patch 私有 runtime。

只有运行时才能知道的问题,例如 source brush 对象、source 数量和 compositor 归属,才保留在 API 边界检查。能在编译/构建阶段确定的错误尽量在那里解决。
控件 hot path 同样遵守这个原则:高频 Value/pointer 更新应该只改已有 Composition 状态,不能每一帧重新遍历 XAML template、分配 brush 或重写 resource。Slider 的实现约束见 [WinUI.LiquidGlass 控件](docs/liquid-glass-controls.md)。

## 文档

Expand All @@ -141,8 +162,9 @@ README 只负责项目入口,完整文档从这里开始:
1. [上手指南](docs/get-started.md)
2. [基础概念](docs/concepts.md)
3. [整体架构](docs/architecture.md)
4. [API Reference](docs/api/index.md)
5. [设计文档索引](docs/index.md#design-reference)
4. [WinUI.LiquidGlass 控件](docs/liquid-glass-controls.md)
5. [API Reference](docs/api/index.md)
6. [设计文档索引](docs/index.md#design-reference)

常用参考:

Expand All @@ -152,6 +174,9 @@ README 只负责项目入口,完整文档从这里开始:
- [HlslShaderLibrary](docs/api/hlsl-shader-library.md)
- [HlslProperty](docs/api/hlsl-property.md)
- [HlslRuntimeCapabilities](docs/api/hlsl-runtime-capabilities.md)
- [LiquidGlassBrush](docs/api/liquid-glass-brush.md)
- [LiquidGlassMaterial](docs/api/liquid-glass-material.md)
- [WinUI.LiquidGlass 控件](docs/liquid-glass-controls.md)
- [Sampler 资源绑定 ABI](docs/design/resource-binding-contract.md)
- [Materialized graph runtime](docs/design/materialized-graph-runtime.md)

Expand All @@ -166,12 +191,12 @@ README 只负责项目入口,完整文档从这里开始:
.\tests\build.ps1 -Language CSharp
```

CI 会构建 x64/Win32/ARM64 native asset、CsWinRT projection、generated shader fixture、NuGet 包,并使用生成的 NuGet 再构建下游 C++/C# consumer。`master` push 全部验证通过后,会直接由 `ci.yml` 通过 OIDC trusted publishing 发布该包到 NuGet.org。
CI 会构建 x64/Win32/ARM64 native asset、CsWinRT projection、generated shader fixture、两个 NuGet 包,并使用生成的 NuGet 再构建下游 C++/C# consumer。`master` push 全部验证通过后,会直接由 `ci.yml` 通过 OIDC trusted publishing 发布经过验证的包。

## License

[MIT License](LICENSE.txt)。

## Thanks

项目受到 @apkipa 的 WUILiquidGlassDemo 工作启发。
项目受到 @apkipa 的 WUILiquidGlassDemo 工作启发。
6 changes: 5 additions & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,17 @@

`WinUI.Composition.Hlsl` adds custom HLSL nodes to the normal Windows Graphics Effects / `Microsoft.UI.Composition` / WinUI 3 XAML pipeline. It supports C++/WinRT and C#, build-time or runtime compilation, linked multi-source effects, typed animatable properties, and packaged material brushes.

The repository also ships `WinUI.LiquidGlass`, a native C++/WinRT WinUI 3 control package built on the liquid-glass material. See [WinUI.LiquidGlass controls](liquid-glass-controls.md) for control architecture, interaction ownership, Slider/ToggleSwitch/Magnifier behavior, and teardown rules.

## Start here

If this is your first time using the package, read these in order:

1. [Get started](get-started.md) — install the package, compile a shader, and create a Composition brush.
2. [Concepts](concepts.md) — HLSL vs DXBC vs `.g.h`, shader profiles, effect kinds, linked sources, materialization, and typed properties.
3. [Architecture](architecture.md) — how the WinRT API, shader compiler, Graphics Effects graph, and private Composition adapter fit together.
4. [API reference](api/index.md) — class-by-class public WinRT reference.
4. [WinUI.LiquidGlass controls](liquid-glass-controls.md) — native glass controls, interaction ownership, and control-specific geometry.
5. [API reference](api/index.md) — class-by-class public WinRT reference.

## Installation and compatibility

Expand Down Expand Up @@ -97,6 +100,7 @@ The package deliberately avoids moving errors that can be detected by FXC/MSBuil

## Design reference

- [WinUI.LiquidGlass controls](liquid-glass-controls.md)
- [Sampler resource binding contract](design/resource-binding-contract.md)
- [Materialized graph compilation](design/materialized-graph-runtime.md)
- [Precompiled and asynchronous shader libraries](design/precompiled-shaders.md)
Expand Down
Loading