Skip to content

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

Merged
zccrs merged 2 commits into
linuxdeepin:masterfrom
zccrs:feature/liquid-glass-webgl
Jul 28, 2026
Merged

refactor(glass): improve liquid glass refraction and performance#1187
zccrs merged 2 commits into
linuxdeepin:masterfrom
zccrs:feature/liquid-glass-webgl

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

@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 Outdated
Comment thread misc/dconfig/org.deepin.dde.treeland.user.json Outdated
Comment thread misc/dconfig/org.deepin.dde.treeland.user.json Outdated
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 2 times, most recently 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

@LFRon

LFRon commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

大佬是不是忘记在debian/control下的build-depends等地方加QtQuick 3D库了, 我发现应用大佬的PR后需要补上qt6-quick3d-dev这个包才能编译

@zccrs

zccrs commented Jul 28, 2026

Copy link
Copy Markdown
Member Author

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

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

我做了个实现: #1171

这改动的太大了,没法审核呀。你先自己用着吧,实际的修复等我按计划来搞。

@zccrs
zccrs force-pushed the feature/liquid-glass-webgl branch from da4b09e to dbb3ab4 Compare July 28, 2026 09:53
@LFRon

LFRon commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

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

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

我做了个实现: #1171

这改动的太大了,没法审核呀。你先自己用着吧,实际的修复等我按计划来搞。

(那块模糊支持的提交我专门标记了,没必要看整体的更改)
而且AI挖挖也能挖清楚我那个更改改了什么吧(

@zccrs
zccrs force-pushed the feature/liquid-glass-webgl branch from dbb3ab4 to af9aef5 Compare July 28, 2026 11:16
@zccrs

zccrs commented Jul 28, 2026

Copy link
Copy Markdown
Member Author

大佬是不是忘记在debian/control下的build-depends等地方加QtQuick 3D库了, 我发现应用大佬的PR后需要补上qt6-quick3d-dev这个包才能编译

3D方面的已经去掉了

wineee
wineee previously approved these changes Jul 28, 2026
@zccrs
zccrs force-pushed the feature/liquid-glass-webgl branch from af9aef5 to 8b588c3 Compare July 28, 2026 11:57
@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

1 similar comment
@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 added 2 commits July 28, 2026 20:28
…tion

Implement Liquid Glass for backdrop blur regions, replacing the plain blur
presentation with a physically based refraction model.

Shader:
- Use an analytic rounded-rectangle refraction field and Snell calculation.
- Apply a Hermite-Coons corner map when radius is smaller than bezel width.
- Preserve C1 corner continuity with projected source-depth correction.
- Derive optical normals from the field gradient and sample refraction inward.
- Keep the flat-region early-out, single texture sample, and feature guards.
- Derive the private optical radius from max(radius, bezelWidth).

QML and DConfig:
- Dispatch between Liquid Glass and the legacy MultiEffect through a Loader.
- Keep blur and color processing in MultiEffect before glass refraction.
- Keep glassEnabled, blurStrength, blurAmount, blurMultiplier,
  glassSaturation, glassSpecular, glassBezel, glassThickness, and
  glassProfilePower in the user DConfig descriptor.
- Use radius=12, bezelWidth=36, thickness=40, profilePower=2, ior=1.33,
  refractionMaxTan=2, contentEdgePull=0, contentRampEnd=0, innerShadow=0,
  specular=0, saturation=0, blurMax=64, and blurAmount=0.6 as defaults.

Tests and example:
- Cover material controls, blur behavior, refraction, defaults, and corner
  continuity with runtime rendering and property checks.
- Add an opt-in offscreen grab round-trip benchmark with configurable image
  size, rounds, draws, radius, and bezel width.
- Keep test_glass defaults synchronized with GlassEffect and DConfig.
- Allow test_glass width/height sliders down to 30.

实现液态玻璃背景效果,以物理折射表现替代单一的普通模糊表现。

着色器:使用解析圆角矩形折射场和 Snell 计算;当 radius 小于 bezelWidth
时使用 Hermite-Coons 角区映射,并通过源深度投影保持 C1 连续;从场梯度
计算光学法线;保留平坦区快速路径、单次纹理采样和按功能跳过;光学圆角
半径在内部取 max(radius, bezelWidth)。

QML 与 DConfig:通过 Loader 在液态玻璃和传统 MultiEffect 之间切换;模糊
和颜色处理在折射前由 MultiEffect 完成;用户 DConfig 保留玻璃开关、模糊
强度、模糊量、模糊倍率、饱和度、高光强度、边缘宽度、玻璃厚度和轮廓幂次
共 9 项配置。默认值统一为 radius=12、bezelWidth=36、thickness=40、
profilePower=2、ior=1.33、refractionMaxTan=2、contentEdgePull=0、
contentRampEnd=0、innerShadow=0、specular=0、saturation=0、blurMax=64、
blurAmount=0.6。

测试与示例:覆盖材质控制、模糊行为、折射效果、默认值和角区连续性;新增
可选的离屏抓图往返性能测试;test_glass 默认值与 GlassEffect 和 DConfig
保持一致;宽高 Slider 下限调整为 30。

Log: 实现液态玻璃折射效果并暴露高光配置
Influence: 1. 重点验证窗口、任务切换和锁屏等背景模糊区域的液态玻璃表现。
2. 重点验证小圆角、radius=bezelWidth 和大圆角下边缘折射连续且无对角折痕。
3. 验证模糊开关、强度、倍率、饱和度、高光强度及液态玻璃开关能够实时生效。
4. 验证关闭液态玻璃后正确回退传统模糊,窗口拖动和动画无明显性能回退。
5. 验证 test_glass 初始参数为产品默认值,DConfig 修改后表现与示例一致。
6. 验证小尺寸(宽高 30)玻璃面板仍可正常显示与交互。
Reduce Liquid Glass fragment overhead without changing corner geometry.

- Enable QSB OPTIMIZED for liquidglass shader packs.
- Early-out center fill with safetyMargin derived from radiusLift.
- Use analytic rounded-rect normals instead of finite-difference fieldT.
- Converge Newton invert and preserve loops early when error is small.
- Guard innerShadow and simplify contentRamp when edgePull is zero.
- Avoid double-clamping refraction sample UVs.

降低液态玻璃片元开销,不改变角区几何语义。

- 为 liquidglass shader pack 启用 QSB OPTIMIZED。
- 按 radiusLift 推导 safetyMargin,中心区域跳过 map/preserve。
- 用解析圆角矩形法线替代 fieldT 差分。
- Newton 反演与 preserve 在误差足够小时提前结束。
- innerShadow=0 时跳过内阴影;edgePull=0 时简化 contentRamp。
- 去掉折射采样 UV 的重复 clamp。

Log: 优化液态玻璃中心填充与边缘重路径
Influence: 1. 回归小圆角与 radius<bezel 角区折射,确认无错位和折痕。
2. 验证 specular/innerShadow 开关与 contentEdgePull 行为正常。
3. 关注弱 GPU 上大面积玻璃中心区域的填充成本。
@zccrs
zccrs force-pushed the feature/liquid-glass-webgl branch from 8b588c3 to 07f1a12 Compare July 28, 2026 12:31
@zccrs
zccrs merged commit cd0879d into linuxdeepin:master Jul 28, 2026
8 of 9 checks passed
@zccrs
zccrs deleted the feature/liquid-glass-webgl branch July 28, 2026 12:54
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.

5 participants