Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[g-webgl] Path 填充部分透明度问题 #859

Closed
xiaoiver opened this issue Jan 20, 2022 · 0 comments
Closed

[g-webgl] Path 填充部分透明度问题 #859

xiaoiver opened this issue Jan 20, 2022 · 0 comments
Assignees
Labels

Comments

@xiaoiver
Copy link
Contributor

xiaoiver commented Jan 20, 2022

可以看出填充部分并没有正确应用 opacity

截屏2022-01-20 下午12 09 26

Blend 相关参数设置的其实是正确的:

BLEND: true
BLEND_COLOR: 0, 0, 0, 0
BLEND_DST_ALPHA: ONE
BLEND_DST_RGB: ONE_MINUS_SRC_ALPHA
BLEND_EQUATION_ALPHA: FUNC_ADD
BLEND_EQUATION_RGB: FUNC_ADD
BLEND_SRC_ALPHA: ZERO
BLEND_SRC_RGB: SRC_ALPHA

在绘制 Path、Polygon 时,填充和描边是分开绘制的,前者通过 earcut 三角化,后者使用 Polyline 绘制。

问题出在绘制顺序上,从下图可以看出几个图形的绘制顺序为:

No.1 Fill
No.2 Fill
No.3 Fill
No.4 Fill
No.1 Stroke
No.2 Stroke
...

截屏2022-01-20 下午12 14 07

加入渲染队列的 RenderInst 会使用 sortKey 排序,例如按照不透明和透明。问题出在不能用 Program ID 排序,虽然能减少 Program 切换(上图中 useProgram 一次绘制四个图形),但会影响正确的顺序:

renderInst.sortKey = makeSortKeyOpaque(RendererLayer.OPAQUE, program.id);

正常效果:

截屏2022-01-20 下午1 33 17

参考资料:

@xiaoiver xiaoiver added the bug label Jan 20, 2022
@xiaoiver xiaoiver self-assigned this Jan 20, 2022
xiaoiver added a commit that referenced this issue Jan 24, 2022
* fix: control render order with renderInst's sortKey #859

* fix: end point in polygon & path #860

* fix: support webgl1 in hal #851

* feat: add targets config in g-webgl

Co-authored-by: yuqi.pyq <[email protected]>
xiaoiver added a commit that referenced this issue Feb 5, 2022
* fix: control render order with renderInst's sortKey #859

* fix: end point in polygon & path #860

* fix: support webgl1 in hal #851

* feat: add targets config in g-webgl

* build: merge build commands

* Publish

 - @antv/[email protected]
 - @antv/[email protected]
 - @antv/[email protected]
 - @antv/[email protected]
 - @antv/[email protected]
 - @antv/[email protected]
 - @antv/[email protected]
 - @antv/[email protected]
 - @antv/[email protected]
 - @antv/[email protected]
 - @antv/[email protected]
 - @antv/[email protected]
 - @antv/[email protected]
 - @antv/[email protected]
 - @antv/[email protected]
 - @antv/[email protected]
 - @antv/[email protected]
 - @antv/[email protected]
 - @antv/[email protected]
 - @antv/[email protected]
 - @antv/[email protected]

* chore: update changelog

Co-authored-by: yuqi.pyq <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant