refactor(glass): improve liquid glass refraction and performance - #1187
Conversation
ff77a9b to
99c193e
Compare
There was a problem hiding this comment.
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.qml→GlassEffect.qmlpipeline and DConfig defaults/knobs for the new model.
中文:更新Blur.qml→GlassEffect.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. |
99c193e to
6716b87
Compare
|
大佬, Vulkan后端能不能也来个( |
511e44d to
d8c32f6
Compare
这个不依赖后端呀,主要是 renderblitter 还没有支持vulkan,后面会支持的 |
大佬这个是Qt QML这侧压根没有支持, 还是这个本来就需要treeland自己实现 |
我做了个实现: #1171 |
|
TAG Bot New tag: 0.8.16 |
|
大佬是不是忘记在debian/control下的build-depends等地方加QtQuick 3D库了, 我发现应用大佬的PR后需要补上 |
这改动的太大了,没法审核呀。你先自己用着吧,实际的修复等我按计划来搞。 |
da4b09e to
dbb3ab4
Compare
(那块模糊支持的提交我专门标记了,没必要看整体的更改) |
dbb3ab4 to
af9aef5
Compare
3D方面的已经去掉了 |
af9aef5 to
8b588c3
Compare
|
[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. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
1 similar comment
|
[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. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
…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 上大面积玻璃中心区域的填充成本。
8b588c3 to
07f1a12
Compare
Summary / 摘要
specularthe sole highlight control andtintthe sole white-mixing control; remove the redundant QML and DConfig switches.specular作为唯一高光控制、tint作为唯一白色混合控制,删除重复的 QML 与 DConfig 开关。GPU performance / GPU 性能
Median offscreen fragment time, 120 draws per round, 7 alternating rounds:
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 / 验证
Result:
1/1target passed,0failures.结果:
1/1测试目标通过,0失败。