Shared Outlines

image
I’m working on a project where I need to implement a unique visual feature: when two or more objects intersect, they should share a common outline instead of maintaining separate outlines. This effect aims to create a more unified and visually appealing interaction between the objects.

Here’s what I’m looking to achieve:

  • When objects are separate, they have their own distinct outlines.
  • Upon intersection, these objects blend their outlines to form a single, shared outline.
  • The shared outline should smoothly adapt to the shape created by the intersecting objects.

I’m seeking advice or suggestions on how to best approach this in Defold. Has anyone here worked on a similar feature or could provide insights into how to manipulate object outlines in this manner? Now i1m just having a layer under everything with duplicated graphics of sprites, but in black mode. Maybe there is an easy way.

2 Likes

I imagine that your current approach is the simplest way to achieve the desired effect, and it seems like it should work pretty well. Do you have a video or gif of how it looks, then maybe explain how it should be different?

1 Like

In fact, your approach is good for 2D and it can be automated through render script and with an extra material:

  • create a new material that draws sprites in black and with an expansion to create an outline effect.
  • add this new material to the custom render file.
  • all outline sprites must have a special predicate, for example tile_outline. Yes, you need to make a duplicate of sprite.material and change the tile to tile_outline in the material.
  • in the render script before rendering tile_outline, draw them with the special material you added above:
render.enable_material(your_outline_material)
render.draw(your_tile_outline_predicate)
render.disable_material()
6 Likes

i`ll try this, thanks a lot