# 2D GUI anti-aliasing

**URL:** <https://forum.babylonjs.com/t/2d-gui-anti-aliasing/35706>\
**Category:** Questions\
**Created:** [November 15, 2022, 7:51am UTC](https://forum.babylonjs.com/t/2d-gui-anti-aliasing/35706 "2022-11-15T07:51:29Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![McNimble](https://avatars.discourse-cdn.com/v4/letter/m/838e76/32.png) [@McNimble](https://forum.babylonjs.com/u/McNimble)\
**Post date:** [November 15, 2022, 7:51am UTC](https://forum.babylonjs.com/t/2d-gui-anti-aliasing/35706/1 "2022-11-15T07:51:29Z")

</div>

Can 2D GUI be anti-aliased?

When linking a rectangle to a mesh, it is drawn pixel accurate, which looks sharp in a single frame, but the rectangle moves choppy (by pixel) while the mesh moves smoothly (sub-pixel).

I understand that for lines and text, sub-pixel placement looks blurry, but my rectangle is big enough to not suffer from that effect.

---

<div class="post-metadata">

**Author:** ![Evgeni\_Popov](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/evgeni_popov/32/4432_2.png) [@Evgeni\_Popov](https://forum.babylonjs.com/u/Evgeni_Popov)\
**Post date:** [November 15, 2022, 10:25am UTC](https://forum.babylonjs.com/t/2d-gui-anti-aliasing/35706/2 "2022-11-15T10:25:12Z")

</div>

Welcome aboard!

Would you have a repro in the Playground to show the effect?

When trying in this PG it does not seem choppy to me:

> **[Babylon.js Playground](https://playground.babylonjs.com/#XCPP9Y%2316473)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL 3D scenes

---

<div class="post-metadata">

**Author:** ![McNimble](https://avatars.discourse-cdn.com/v4/letter/m/838e76/32.png) [@McNimble](https://forum.babylonjs.com/u/McNimble)\
**Post date:** [November 15, 2022, 10:46am UTC](https://forum.babylonjs.com/t/2d-gui-anti-aliasing/35706/3 "2022-11-15T10:46:32Z")

</div>

Slow it down with a factor of 10, and you’ll see the sphere move smoothly, still, and the green textblock take small steps.

mm, I have a 90 dpi laptop screen… but alas, high dpi mobile platform fares no better.

---

<div class="post-metadata">

**Author:** ![Evgeni\_Popov](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/evgeni_popov/32/4432_2.png) [@Evgeni\_Popov](https://forum.babylonjs.com/u/Evgeni_Popov)\
**Post date:** [November 15, 2022, 10:55am UTC](https://forum.babylonjs.com/t/2d-gui-anti-aliasing/35706/4 "2022-11-15T10:55:46Z")

</div>

I’m not sure we can do anything for that…

We are not truncating the calculation, so the top/left positions of the rectangle are floating point numbers, we don’t snap the position to a pixel.

If your design allows, maybe you can try to use a billboard plane instead, which is following the mesh?

---

<div class="post-metadata">

**Author:** ![McNimble](https://avatars.discourse-cdn.com/v4/letter/m/838e76/32.png) [@McNimble](https://forum.babylonjs.com/u/McNimble)\
**Post date:** [November 15, 2022, 11:19am UTC](https://forum.babylonjs.com/t/2d-gui-anti-aliasing/35706/5 "2022-11-15T11:19:01Z")

</div>

It’s common that 2D frameworks round to pixels for sharp edges… Often, certainly for static screens, that looks better, sometimes not. Not sure you can do something about that, either. It’s the browser’s 2D rendering engine, in this case, I guess?

I’m working with distance to camera that is changing an order of magnitude, at least. Although a billboard plane would be smooth, I’d have to resize it continuously to look nice. The `linkWithMesh` is a great time saver, compared to that 😉 Maybe I’ll do it eventually.

---

<div class="post-metadata">

**Author:** ![Evgeni\_Popov](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/evgeni_popov/32/4432_2.png) [@Evgeni\_Popov](https://forum.babylonjs.com/u/Evgeni_Popov)\
**Post date:** [November 15, 2022, 11:41am UTC](https://forum.babylonjs.com/t/2d-gui-anti-aliasing/35706/6 "2022-11-15T11:41:12Z")

</div>

> [@McNimble](#):
>
> Not sure you can do something about that, either. It’s the browser’s 2D rendering engine, in this case, I guess?

Yes, we are using canvas as the backend for the 2D GUI.
