Paint on 3D Model from an Image (not color) but how tf

I had this idea where the user can paint a 3D Model but instead of painting a color the brush uses an image as reference as paints that, but only a specific part of the Image. (Basically like the copying brush from photoshop).
I havent been able to make any progress and my last hope is somebody in here knows how this could be doable.

Would appreciate any help!

For a quick, simple and generally sufficient solution - you can just use CanvasTexture and draw images using Canvas API. For a super optimal solution - you could use a RenderTarget with a disabled autoClear.

Thank you! Any examples of that maybe?
Havent really seen many people do that tbh, and havent found a single example doing it

It’s a tricky problem. This is the usual starting point for people exploring this idea… but you can see the difficulty:

https://threejs.org/examples/webgl_decals.html

Namely that… linear projections will have some kind of stretching edge case, or clipping, that doesn’t look good.

It’s also an expensive operation to do the extraction/intersection of the geometry within the decal volume, which make it hard to do at interactive rates.

There are things you can do in a shader that are faster but it’s wickedly more complex, and you have to somehow persist the results back out of the shader.

I wrote a painting tool that does the shader based approach just for a spherical brush… but it shows some of the complexity if you look at how the texture has to actually be transformed.

1 Like