Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

refactor(glass): improve liquid glass refraction and performance#1187

Open
zccrs wants to merge 6 commits into
linuxdeepin:masterlinuxdeepin/treeland:masterfrom
zccrs:feature/liquid-glass-webglzccrs/treeland:feature/liquid-glass-webglCopy head branch name to clipboard
Open

refactor(glass): improve liquid glass refraction and performance#1187
zccrs wants to merge 6 commits into
linuxdeepin:masterlinuxdeepin/treeland:masterfrom
zccrs:feature/liquid-glass-webglzccrs/treeland:feature/liquid-glass-webglCopy head branch name to clipboard

Conversation

@zccrs

@zccrs zccrs commented Jul 21, 2026

Copy link
Copy Markdown
Member

Summary / 摘要

  • Rework the liquid-glass shader around a single-channel rounded-rectangle refraction field.
  • 使用单通道圆角矩形折射场重构液态玻璃 shader。
  • Make specular the sole highlight control and tint the sole white-mixing control; remove the redundant QML and DConfig switches.
  • specular 作为唯一高光控制、tint 作为唯一白色混合控制,删除重复的 QML 与 DConfig 开关。
  • Restore a flat-interior fast path, use analytic profile/Snell math, and reduce the refraction path to one texture sample.
  • 恢复平坦区域快速路径,使用解析曲面与 Snell 计算,并将折射路径降为单次纹理采样。
  • Use one radius-limited optical width around the full rounded rectangle and ease slope at the silhouette, preventing small corners from pulling black backdrop regions into the glass.
  • 整个圆角矩形使用统一的半径限制光学带宽,并在轮廓处平滑拉起斜率,避免小圆角把外部黑色背景拉入玻璃区域。
  • Preserve the fixed-width inner rim for narrow bezels with dedicated regression coverage.
  • 保留窄 bezel 的固定宽度内沿,并增加针对性回归测试。

GPU performance / GPU 性能

Median offscreen fragment time, 120 draws per round, 7 alternating rounds:

GPU / workload Parent This PR Change
RTX 5060, 1024x1024 0.02609 ms 0.02194 ms 15.9% faster
RTX 5060, 2048x2048 0.10230 ms 0.08600 ms 15.9% faster
Intel UHD 630, 1024x1024 1.15170 ms 0.71882 ms 37.6% faster
Intel UHD 630, 2048x2048 4.82867 ms 2.87516 ms 40.5% faster

The active refraction path still uses one texture sample. The final shader has 717 SPIR-V instructions versus 764 before the corner fix.
有效折射路径仍只使用一次纹理采样;最终 shader 的 SPIR-V 指令数由圆角修复前的 764 降至 717。

Verification / 验证

/usr/bin/ctest --test-dir build -R test_effect_glass --output-on-failure

Result: 1/1 target passed, 0 failures.
结果:1/1 测试目标通过,0 失败。

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry @zccrs, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: zccrs

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@zccrs
zccrs force-pushed the feature/liquid-glass-webgl branch from ff77a9b to 99c193e Compare July 21, 2026 11:39
@zccrs
zccrs requested a review from Copilot July 21, 2026 12:37

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

EN: Refactors Treeland’s Liquid Glass effect to a simplified single-channel refraction field with analytic Snell-based displacement, consolidating highlight/tint controls and reducing sampling cost, while updating QML/DConfig wiring and adding regression coverage for narrow bezels.
中文:重构 Treeland 的液态玻璃效果为更简化的单通道折射场,采用解析 Snell 位移计算并降低采样次数,同时合并高光/染色控制、更新 QML/DConfig 绑定,并加入窄 bezel 回归测试覆盖。

Changes / 变更:

  • EN: Replace multiple legacy shader uniforms/switches with specular (highlight) + tint (white mix) and new refraction shaping knobs; update tests accordingly.
    中文:用 specular(高光)+ tint(白色混合)及新的折射塑形参数替换旧的多组 shader uniform/开关,并同步更新测试。
  • EN: Update Blur.qmlGlassEffect.qml pipeline and DConfig defaults/knobs for the new model.
    中文:更新 Blur.qmlGlassEffect.qml 管线,并调整 DConfig 默认值/可调项以匹配新模型。
  • EN: Add documentation capturing the removed chromatic-dispersion approach for future reference.
    中文:新增文档记录已移除的色散方案,便于后续可能的重做与查阅。

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
tests/test_effect_glass/main.cpp Updates/extends rendering + property tests for new specular/tint model and bezel regressions.
src/plugins/lockscreen/qml/RoundBlur.qml Drops removed highlightEnabled binding.
src/core/qml/Effects/GlassEffect.qml Reworks effect inputs/defaults and the MultiEffect → shader source path for the new liquid-glass shader.
src/core/qml/Effects/Blur.qml Rewires DConfig-driven knobs to GlassEffect (glassSpecular, glassTint, glassContrast, glassSaturation).
misc/shaders/liquidglass.frag Implements new single-sample refraction + Fresnel/specular/tint logic and fast interior path.
misc/dconfig/org.deepin.dde.treeland.user.json Adjusts liquid-glass defaults and introduces new user-facing knobs (specular/tint/contrast/saturation).
examples/test_glass/Main.qml Updates demo UI and parameters to match the new shader controls and shaping knobs.
examples/test_glass/main.cpp Removes example-only multi-output backend setup code.
examples/test_glass/helper.h Updates example config properties to match new control set/defaults.
docs/liquid-glass-dispersion.md New doc describing the removed dispersion implementation for reference.

Comment thread misc/shaders/liquidglass.frag
Comment thread misc/dconfig/org.deepin.dde.treeland.user.json
Comment thread misc/dconfig/org.deepin.dde.treeland.user.json
Comment thread misc/dconfig/org.deepin.dde.treeland.user.json Outdated
@LFRon

LFRon commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

大佬, Vulkan后端能不能也来个(

@zccrs
zccrs force-pushed the feature/liquid-glass-webgl branch from 6716b87 to 511e44d Compare July 22, 2026 01:52
zccrs added 3 commits July 22, 2026 09:57
Improve the existing rim-color path into a single-channel refraction field.
The shader derives a continuous rounded-rect normal, caps edge slope, and
uses inward/tangent soft sampling to avoid border tearing and dark flecks.

Content-pull ramp controls keep distorted content closer to the glass edge
while the optical pull still follows the surface profile. Fresnel rim
highlighting and symmetric SDF antialiasing improve edge quality.

Tuned defaults are blurAmount 0.6, ior 1.5, saturation 0.04,
specular 0, and tint 0. Dispersion, edge-saturation, reflection-offset,
and displacement-factor controls are removed because they no longer feed
the shader.

将已有边缘染色路径优化为单通道折射场。
shader 通过连续圆角矩形法线计算折射,限制边缘斜率,并使用
向内/切线柔化采样,减少边界撕裂和深色噪点。

内容贴边渐变控制让变形后的内容更贴近玻璃边缘,
同时光学位移仍跟随表面剖面变化。Fresnel 边缘高光和
对称 SDF 抗锯齿改善边缘质量。

默认值调整为 blurAmount 0.6、ior 1.5、saturation 0.04、
specular 0 和 tint 0。色散、边缘饱和度、反射偏移和
位移强度控制已移除,因为这些参数不再进入 shader。

Log: 优化液态玻璃折射效果
Influence: 需测试圆角边缘、模糊强度、默认颜色参数和 DConfig 加载。
test_glass now uses only the compositor output from its startup path.

test_glass 只使用启动流程创建的合成器输出。

Log: 移除 test_glass 额外屏幕创建
Influence: 需测试 test_glass 启动后只出现一个屏幕且玻璃效果可渲染。
Replace finite-difference optics with analytic math and restore the flat path.

用解析数学替代有限差分光学计算,并恢复平坦区域快速路径。

Remove multi-tap edge filtering and guard optional material work.

移除多重边缘采样,并按需跳过可选材质计算。

Log: 优化液态玻璃 shader 性能
Influence: 降低默认与高光路径的 GPU 开销,保留折射、圆角和内沿高光。
@zccrs
zccrs force-pushed the feature/liquid-glass-webgl branch from 511e44d to d8c32f6 Compare July 22, 2026 01:57
@zccrs

zccrs commented Jul 22, 2026

Copy link
Copy Markdown
Member Author

大佬, Vulkan后端能不能也来个(

这个不依赖后端呀,主要是 renderblitter 还没有支持vulkan,后面会支持的

@LFRon

LFRon commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

主要是 renderblitter 还没有支持vulkan,后面会支持的

大佬这个是Qt QML这侧压根没有支持, 还是这个本来就需要treeland自己实现

@LFRon

LFRon commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

主要是 renderblitter 还没有支持vulkan,后面会支持的

大佬这个是Qt QML这侧压根没有支持, 还是这个本来就需要treeland自己实现

我做了个实现: #1171

@deepin-bot

deepin-bot Bot commented Jul 24, 2026

Copy link
Copy Markdown

TAG Bot

New tag: 0.8.16
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #1203

zccrs added 3 commits July 24, 2026 13:13
Replace the binary top/side split in getFieldT with a geometric-mean
of two directional bezel progressions (sqrt(smoother01(top) *
smoother01(side))), matching the visualizer's smoothCornerT. The old
approach produced a fold line along the 45° diagonal in corner regions
when radius < bezelWidth, causing incorrect refraction direction and
visible artifacts. The new field is C1-smooth everywhere, ensuring the
gradient (used for the refraction normal and localBezel) is continuous.

修复 radius < bezelWidth 时角区 t 场的折痕 bug:将 getFieldT 中的
top/side 二分改为两个方向进度的几何平均
(sqrt(smoother01(top) * smoother01(side))),与可视化工具的
smoothCornerT 一致。旧实现在角区沿 45° 对角线产生折痕,导致
折射法线方向错误和可见伪影;新场处处 C1 光滑,梯度连续。

Log: 修复角区 t 场折痕
Influence: radius < bezelWidth 时玻璃折射不再有对角线折痕,
角区折射方向连续平滑。
Add DConfig keys and QML wiring for content pull, ramp end,
refraction slope cap, profile power, and inner shadow.

新增 DConfig 配置项和 QML 透传,支持内容拉力、渐变终点、
折射斜率上限、轮廓幂次和内阴影调节。

Log: 暴露液态玻璃轮廓与阴影参数
Influence: 可通过 DConfig 动态调整液态玻璃 profilePower、
specular、边缘拉力、折射上限和内阴影等参数。
Let contentEdgePull lift the silhouette softening floor before slope
calculation, add a regression render test, and expose all glass optics
knobs in the test_glass UI.

让 contentEdgePull 在斜率计算前抬高轮廓 softening 下限,新增渲染
回归测试,并在 test_glass UI 暴露所有玻璃光学参数。

Log: 修复 contentEdgePull 无效并补齐 test_glass 控件
Influence: Treeland 与 test_glass 中 contentEdgePull 会影响边缘折射;
test_glass 可调全部玻璃光学参数。
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.