refactor(glass): improve liquid glass refraction and performance#1187
refactor(glass): improve liquid glass refraction and performance#1187zccrs wants to merge 6 commits intolinuxdeepin:masterlinuxdeepin/treeland:masterfrom zccrs:feature/liquid-glass-webglzccrs/treeland:feature/liquid-glass-webglCopy head branch name to clipboard
Conversation
|
[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 |
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后端能不能也来个( |
6716b87 to
511e44d
Compare
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 开销,保留折射、圆角和内沿高光。
511e44d to
d8c32f6
Compare
这个不依赖后端呀,主要是 renderblitter 还没有支持vulkan,后面会支持的 |
大佬这个是Qt QML这侧压根没有支持, 还是这个本来就需要treeland自己实现 |
我做了个实现: #1171 |
|
TAG Bot New tag: 0.8.16 |
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 可调全部玻璃光学参数。
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失败。