When combining holes cut with polygon mesh builder and CSG, things do not fully cut through

Both the wall and the paint layer have a hole cut out of them at the top. (if you want to see the “cut” area of the paint, simply dont dispose of the box). The cut area of the wall, instead of remaining fully cut out, somehow gets the material of the cutout of the paint layer applied to it. How can i go about fixing this?

Even stranger, when i add motion, that blue box travels with it. see updated playground https://playground.babylonjs.com/#EYJF9P#1

I’m sorry but I’m sure to understand your problem.
CSG is a one time operation. once it’s done, you get a mesh that can be moved but no other CSG will happen.
What do you want to achieve ?

So there are two different types of cutouts occurring. One using CSG, and one using PolygonMeshBuilder. I would expect a result like the following image. The CSG cutout for the Paint is actually outside of the paint entirely, so should have no real effect. The cutout for the wall using PolygonMeshBuilder is inside the wall, so should cutout the wall. Instead, it appears as if the CSG cutout that is outside of the paint is somehow applying the paint material to the cutout area

CSG has weird result when using not closed geometry. And the result with just a plane is not what you expect, I guess.
Changing it to a box with thickness should solve your issue:

Test Holes Cut | Babylon.js Playground (babylonjs.com)

2 Likes

Unfortunately we cannot change it to a box with thickness. It is a paint layer on a wall, something that would inherently have no thickness, and is pretty firmly baked into our platform. I take it this is just a known issue, and not something that we can do anything about?

unfortunately, it’s by design.
but, I think, with a bit of work and effort, you can clip a mesh by a plane.
I guess your primary need is to be able to cut a mesh and discarded faces that aren’t on the ‘good’ side.
It’s a matter of running thru all the triangles, and checking is its vertices position are on the positive or negative side.

This actually used to work in babylon 4.2.1. Do we know what changed?

I see the same behavior between 5.5.0 and 4.2.1.

Oh weird. I see it in the playground too. In our code base though, its different. We must be doing something different than i did in the playground. For now, im going to try adding the slightest bit of depth to our paint layer and see if that resolves it

1 Like

On such a case, maybe you could consider using an opacity texture to make those holes. Just an idea.

Stencils might be another option

1 Like

Much better indeed, and here is a PG just for the fun of it:

2 Likes