Flood fill feature on polygon

Avatar
  • updated

Hello everyone,

I'm working with shapes on Unity and I need to fill a polygon that have many holes without fill the holes. I need a function like the flood fill.

Is there a feature, inside Shapes, to do this?

Thank you!

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
Avatar
Freya Holmér creator

is this a request for support for polygons with holes?

Avatar
emanuele sartorini

Yes, for a project in unity I need to fill a polygon only in specific areas without fill other polygons inside it. I saw the documentation but I haven't find a function that allow me to draw this specific type of polygons. Please can you help me? Thank you.

Avatar
Freya Holmér creator

right now there's no built-in support for polygons with holes, but it might come in the future if people want it. In the meantime, you can work around it right now in one of two ways:

1. you can use the stencil buffer to make the fill polygon not render within certain regions of other polygons
2. you can manually split the polygon up so that it no longer has holes, even though it looks like it, by connecting the inner polygon with the outer polygon, with a 0 width gap

Avatar
emanuele sartorini

I solved the problem playing with stencil buffer. Thank you and have a nice day!

Avatar
Freya Holmér creator

glad it worked out!