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-plugin-device-renderer] Line 边缘需要反走样 #1352

Closed
xiaoiver opened this issue May 25, 2023 · 1 comment
Closed

[g-plugin-device-renderer] Line 边缘需要反走样 #1352

xiaoiver opened this issue May 25, 2023 · 1 comment
Assignees
Labels

Comments

@xiaoiver
Copy link
Contributor

xiaoiver commented May 25, 2023

Line 的边缘未做反走样,锯齿较明显:

截屏2023-05-25 上午10 53 42

https://zhuanlan.zhihu.com/p/59541559

基本思路是在 fragment shader 中基于拉伸后点到线段的距离:

https://thebookofshaders.com/glossary/?search=smoothstep

@xiaoiver xiaoiver self-assigned this May 25, 2023
@xiaoiver xiaoiver added the bug label May 25, 2023
@xiaoiver
Copy link
Contributor Author

xiaoiver commented May 25, 2023

在 vertex shader 中传递反走样模糊距离,以及用于插值的 y,取值范围为 [-0.5, 0.5]

float antialiasblur = 1.0 / strokeWidth;
v_Distance = vec2(a_Position.y * 2.0, antialiasblur);

在 fragment shader 中作为透明度系数:

float blur = smoothstep(0.0, v_Distance.y, 1.0 - abs(v_Distance.x));
截屏2023-05-25 下午8 41 37

xiaoiver added a commit that referenced this issue May 25, 2023
@xiaoiver xiaoiver mentioned this issue May 25, 2023
14 tasks
xiaoiver added a commit that referenced this issue Jun 6, 2023
* fix: antialias line #1352

* Publish

 - @antv/g-mobile-webgl@0.7.68
 - @antv/g-plugin-annotation@0.2.61
 - @antv/g-plugin-device-renderer@1.7.64
 - @antv/g-webgl@1.7.68
 - @antv/g-webgpu@1.7.67

* fix: avoid recreating geometry when instance changed

* Publish

 - @antv/g-lite@1.0.64
 - @antv/g-mobile-webgl@0.7.69
 - @antv/g-plugin-3d@1.7.53
 - @antv/g-plugin-control@1.7.50
 - @antv/g-plugin-device-renderer@1.7.65
 - @antv/g-shader-components@1.7.51
 - @antv/g-webgl@1.7.69
 - @antv/g-webgpu@1.7.68
 - @antv/g@5.16.27
 - @antv/react-g@1.8.73

* fix: account for empty sorted array

* Publish

 - @antv/g-lite@1.0.65
 - @antv/g@5.16.28
 - @antv/react-g@1.8.74

* fix: destroy selectable ui when mark as dirty

* Publish

 - @antv/g-plugin-annotation@0.2.62

* fix: remove target from selected array when amark as dirty

* Publish

 - @antv/g-plugin-annotation@0.2.63

* feat: support refreshing selectable UI

* Publish

 - @antv/g-plugin-annotation@0.2.64

* fix: avoid recreate geometry of Text when attribute changed #1356

* Publish

 - @antv/g-mobile-webgl@0.7.70
 - @antv/g-plugin-device-renderer@1.7.66
 - @antv/g-webgl@1.7.70
 - @antv/g-webgpu@1.7.69

* fix: avoid triggering select event when refreshing ui

* Publish

 - @antv/g-plugin-annotation@0.2.65

* fix: insert a dirty object into sorted array in an efficient way

* Publish

 - @antv/g-lite@1.0.66
 - @antv/g@5.16.29
 - @antv/react-g@1.8.75
@xiaoiver xiaoiver moved this from In Progress to Done in Polishing WebGL & WebGPU implementation Jun 7, 2023
@xiaoiver xiaoiver closed this as completed Jun 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

1 participant