Search code examples
three.jstexturesprojectiontexture-mappingdecal

Three.js Merge objects and textures


My question is related to this article:

http://blog.wolfire.com/2009/06/how-to-project-decals/

If my understanding is correct, a mesh made from the intersection of the original mesh and a cube is added to the scene to make a decal appear. I need to save the final texture. So I was wondering if there is a way to 'merge' the texture of the original mesh and the added decal mesh?


Solution

  • You'd need to do some tricky stuff to convert from the model geometry space into UV coordinate space so you could draw the new pixels into the texture map. If you want to be able to use more than one material that way, you'd also probably need to implement some kind of "material map" similar to how some deferred rendering systems work. Otherwise you're limited to at most, one material per face, which wouldn't work for detailed decals with alpha. I guess you could copy the UV coordinates from the original mesh into the decal mesh, and the use that information to reproject the decal texture into the original texture