Task: Realize an effect that can be represented as follows. If this effect is applied to an object, for example, a sphere, then at a certain height (y-axis coordinate), a slice of this object will be created. By slice we mean an unfilled flat figure, the perimeter of which is not filled with anything. The contour of the slice should at least appear three-dimensional, so that it can be seen from any point. A schematic representation of the operation of such an effect is attached below. The height at which the slice is created can be changed in runtime. Example of the result of the effect
My attempts and assumptions: The first thing I tried to do was to implement it with a shader. My knowledge of them is very mediocre, but being amnestied by ChatGPT I managed to create some semblance of what I needed. The shader simply cut off all pixels below and above a given height. However, the problem was obvious, if you look at the result of this effect from above, if you apply it to a cube, the figure will not be visible, because the shader is displayed only on the polygons, which in this case are parallel to the viewer.
Due to my inexperience in this matter, I do not know if it is possible to do something like this relying only on shaders. Perhaps it can be done in some way using two shaders?
An alternative would be to change the Mesh, but since this effect applies to more than one object in the game, I'm scared to think about how things would slow down. And even if I do set aside the optimization issues, how do I define the shape that the new Mesh should take?
Roughly speaking, I'm very confused about this, but I'm sure there must be reasonable ways. If anyone knows what I should look at and what I could try, please tell me about it, I'd be very grateful!