Projecting texture onto mesh and applying result to mesh texture (for mesh painting)

Sure! Sorry if my description wasn’t accurate enough, to put it in simple terms using the Demo you linked:

Because you are drawing a circle directly on the texture, and that texture is then mapped onto the 3D surface, the circle will be warped as in the screenshot when going towards the top of the sphere.

What I would be interested in, would be achieving a drawing mechanic that lets you draw a circle that will not appear warped like that from the perspective of the camera, or from the surface normal at that point (not sure which is better), so there would need to be some kind of projection onto the geometry, and I’d like the result of that so that I could ‘bake’ it into the texture.

A practical example of this would be these examples for projecting textures onto geometry:
https://github.com/marcofugaro/three-projected-material
https://discourse.threejs.org/t/texture-projection/3224

That exact effect is what I want, I want to project a circle onto the geometry from a specific angle – however these examples are doing that projection in a shader at render time for each frame, and the result is being shown in the viewport directly – I’d like to do the projection once when drawing, and then have it applied to the texture.

Yeah exactly, that’s kind of what I’m after! It’s just that I don’t want to create a bunch of SpotLights (or decals, or such) for each brush stroke that do the work of projecting the texture on each frame. After you make a brush stroke, the projection will never change, so I’d like to ideally calculate it once and then store the result in the texture and just render the texture as is.

That’s exactly it yeah! Seems like you are using the brush normal to do the projection (or whatever you may call it), I also just found this example: three.js - texture - paint which seems to project from the camera instead, but I like the effect with the normal more I think.

I haven’t looked into your ScenePainter.js too deeply but looks like you’re still using a shader and rendering that to a rendertarget which I assume is then used to texture the model being painted or something along those lines?
I’ll look into it more, thanks for linking the example, that helps a ton already!

1 Like