Gap between shapes

Avatar
  • updated
  • Answered

There is a small gap between shapes even if their edges a extremely close, for example 2 regular triangle below:

Image 352

I want to maintain the scale and shape of the triangles, is there a way to get rid of the gap?

Even if I slightly edit the points position to make the triangle bigger, the gap still exist when camera is far away.

Reporting a bug? please specify Unity version:
Reporting a bug? please specify Shapes version:
Reporting a bug? please specify Render Pipeline:
Built-in render pipeline
Pinned replies
Avatar
Freya Holmér creator
  • Answer
  • Answered

this is a very very complicated thing to solve unfortunately, because it's impossible for Shapes to know if you are intending to tile or not to tile

there are basically three options, none of which are ideal:


  1. I can make shapes always fully cover the pixels within its bounds. However, this means that they will always appear 0.5px-1px larger in all directions, than what you intend to. This means all shapes will overextend basically. This would fix this problem, but would cause another. namely, all shapes are slightly larger than you expect, and now instead you will have issues where if they are transparent, they would be extra opaque along the lines, instead of having a gap, because they now overlap.
  2. I can make shapes always have a precise and perceptually correct boundary with anti-aliasing. However, this means that when tiling shapes, there will be a tiny gap because of anti-aliasing. This is how shapes work right now
  3. You can turn off local anti aliasing in the Shapes settings, if acceptable for the project. This should (hopefully) make it tile properly, but you won't get the benefits of LAA

Otherwise, other solutions involve using polygons instead of triangles/regular polygons. Or cover up the gap with another shape, or using the stencil buffer to mask a region to draw inside that region.

But yeah, I wish this was something I could solve, but this is a general difficult problem in graphics in general :(

That said, one solution could be to allow users to set this boundary offset as a global setting. In other words, make point #1 above available with a switch. If that's something you'd want then feel free to open a feature request!

Avatar
chopjzl

Thanks for the reply

I think using polygons is enough for me. 

Actually I am going to use polygons in my project. At first I used triangle to test, never thought they are different in this way

Avatar
Freya Holmér creator
  • Answer
  • Answered

this is a very very complicated thing to solve unfortunately, because it's impossible for Shapes to know if you are intending to tile or not to tile

there are basically three options, none of which are ideal:


  1. I can make shapes always fully cover the pixels within its bounds. However, this means that they will always appear 0.5px-1px larger in all directions, than what you intend to. This means all shapes will overextend basically. This would fix this problem, but would cause another. namely, all shapes are slightly larger than you expect, and now instead you will have issues where if they are transparent, they would be extra opaque along the lines, instead of having a gap, because they now overlap.
  2. I can make shapes always have a precise and perceptually correct boundary with anti-aliasing. However, this means that when tiling shapes, there will be a tiny gap because of anti-aliasing. This is how shapes work right now
  3. You can turn off local anti aliasing in the Shapes settings, if acceptable for the project. This should (hopefully) make it tile properly, but you won't get the benefits of LAA

Otherwise, other solutions involve using polygons instead of triangles/regular polygons. Or cover up the gap with another shape, or using the stencil buffer to mask a region to draw inside that region.

But yeah, I wish this was something I could solve, but this is a general difficult problem in graphics in general :(

That said, one solution could be to allow users to set this boundary offset as a global setting. In other words, make point #1 above available with a switch. If that's something you'd want then feel free to open a feature request!