I have a painting app for texture artists that I am working on. I am able to paint to a flat canvas that updates the texture of a 3d object in an object viewer. Now I want to be able to paint directly to the 3d model.

enter image description here

One way I can think of is to get the uv coordinate from the mouse position, and use that as the position to paint onto my 2d canvas, which updates the 3d models texture.

Oh and only one object at a time is active, so that should make things a little simpler.

Is this the right approach? If it is then how should I start. Or is there a simpler/better way of painting directly to a 3d model? How does zbrush do it?


1 Answer 1


Here are two approaches that I've used before:

The approach I prefer is to create an indirection map:

  1. Render the UV coordinates themselves to a texture
  2. Iterate the raw pixels of the 3D view which need to be updated.
  3. Splat into the model texture for each UV pixel

The other approach I've had success with is un-projecting and raytracing

  1. Invert your view matrix, and compute a ray that corresponds to the clicked point
  2. Raytrace the scene, and find the target to paint onto
  3. Compute the barycentric coordinates and UV coordinate of the intersection
  4. Brush onto the model texture at the UV coordinate

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .