Looking for advice on the best method of applying shaders or other techniques to wrap an entire object

I have a goal of performing a boolean subtraction against a loaded stl mesh, which is complex geometry. That subtraction would take a second mesh wrapped completed around a first, and remove any portions of the first mesh that extend into the second. Imagine loading a football stl, and using a second mesh, all areas in black would be removed from the football, with the hole shrinking in each direction as it gets closer to the base.

Due to the complexity of both meshes, this option was unachievable using babylonjs.

I am now looking into shaders, masks, textures etc or other options where I could simulate this same action by wrapping a texture or shader with some level of transparency around my base mesh.

So importing this stl:

and uploading a texture or shader png, which ever works, that is similar to the one below:

To produce this exact result:

I no longer need holes, but a representation of where the holes would be using a flat black on the surface is good enough. Having a result that looks identical to the screen above is acceptable.

I would need to be able to drag that shader or texture around the football to get it to align exactly where it needs to be and the png file source would need to wrap all around the football. Finally, the png will always be the same, but the stl mesh football could be ANY shape and size. It could be a bulldozer, chicken, etc.

How can I achieve this??? Thank you in advance.

Welcome!

You should be able to drag a texture around fairly easily by changing the uv coords based on mouse movements, or similar user input.

Or if you want to try the boolean subtraction again you can use the Babylon.js CSG2 feature.
Here’s an example:

…and here’s an example of moving textures using uv offsets:

In your case you would want to move them based on user input instead of animating them like in the example, but this shows how it’s possible.

2 Likes

Also have a look at decals.

1 Like