0
$\begingroup$

I want to modify a 3D model in a particular way. Render images, modify these images (using a python program), and project these modifications back onto the texture. Is this possible or not?

$\endgroup$
  • 1
    $\begingroup$ your question is not well understood, you want to know if you can modify the images of your render and put them in place of the original textures as a new texture or you want to make a new model in 3d with the modified images that are not 2D are 1D because they are flat $\endgroup$ – user58715 Jul 13 '19 at 4:35
  • $\begingroup$ you might find what you want with baking $\endgroup$ – moonboots Jul 13 '19 at 6:37
  • 1
    $\begingroup$ The 3D view is a 2D rendered image... So you can paint on textures directly on it. $\endgroup$ – lemon Jul 13 '19 at 8:26
  • $\begingroup$ @lemon I need to feed the rendered image through a python program, so I can't directly paint onto it $\endgroup$ – Goldname Jul 13 '19 at 17:43
  • $\begingroup$ Still don't get the point. What is this Python program supposed to do? Modifying the rendered images or report modifications on the 3D model? $\endgroup$ – lemon Jul 13 '19 at 17:50
1
$\begingroup$

Projection painting and UV project modifier

If the context of the question is the following:

  • You have a model, a camera and a rendered image taken from this camera
  • Then something (a Python program) changes the rendered image
  • You now want to report the modification done on this image onto the object original texture

Then you can use the following method:

Important: during this process don't move the camera and don't move the 3D object.

The base setup is the following:

A model with some material, a UV map (named 'original') and a texture (named 'original' also).

enter image description here

Render the image, so you have for instance this:

enter image description here

And modify it by the way you want. For instance I've this:

enter image description here

Import the modified image into Blender.

Create a second UV map for the 3D object and name it 'projection'.

Select the 3D object, go to the modifier panel and add a 'UV project' modifier, and in this panel:

  • Choose the 'projection' UV map
  • Choose the camera as projector
  • Indicate the aspect ratio which is the dimensions of the rendered image (I've not found a way to do that automatically or by an option)

You should have something like this:

enter image description here

Now, go to 'texture paint' mode. Open the tool panel and choose the clone brush.

  • Set the mode to 'single image'
  • Choose your original image and the original UV map

  • Indicate 'clone from paint slot'

  • Choose the 'modified' image as source
  • And choose the 'projection' UV map for it

enter image description here

Now, in the 3D view, still in texture paint mode, you can draw to clone from your modified image onto the object original texture:

enter image description here

Note:

During this process you may want to avoid shader effects due to the shaders used when the image is originally rendered, because lights and shadows will get the rendered image altered from the object original texture. If so, you can set the object material like this, plugin directly the color input (here the original texture) to the material output node:

enter image description here

|improve this answer|||||
$\endgroup$
  • $\begingroup$ Do you know of a way of doing this within a python script? I think that would be a lot easier, because I actually need to do this on dozens of images $\endgroup$ – Goldname Jul 15 '19 at 3:06
  • $\begingroup$ @Goldname, generally speaking, no, I don't. Could you provide more information about the context? Maybe, some detail could simplify the problem? $\endgroup$ – lemon Jul 15 '19 at 6:56
  • $\begingroup$ Here's an example of what I want to do. Let's say I want to paint a dot (the modification) on every 20 degrees of a 3D model. I would do that by rendering at every 20 degrees, feeding the image through a python program to paint the dot, and then pasting the images back to the 3D model. However, I want to do this for an arbitrary modification $\endgroup$ – Goldname Jul 15 '19 at 16:54
2
$\begingroup$

Yes it is possible and called projection painting. CGMatter has tutorials on this topic that should get you started. Blender 2.8 Texture extraction projection painting (part 1) and Blender 2.8 3D Object removal projection painting (part 3)

|improve this answer|||||
$\endgroup$
  • $\begingroup$ The tutorial seems to be about extracting textures from images, not 3D models $\endgroup$ – Goldname Jul 13 '19 at 19:24
  • $\begingroup$ It's about projecting image onto a 3D model. If you meant something different then your question is ambiguous. You can render images, edit them and then project them back onto (a possibly different) 3D model. $\endgroup$ – Robert Gützkow Jul 13 '19 at 22:04
  • $\begingroup$ Sorry for the ambiguity. You're saying the projection isn't necessary at all? Can you explain how in python I could modify rendered portions of the texture of the 3D model directly? $\endgroup$ – Goldname Jul 14 '19 at 3:37
  • $\begingroup$ I don't understand if the projection is necessary or not. For example if I have a 3D model of a cube, I would want to modify all six sides of the cube by rendering all six sides, feeding each of the six images through a python program, and then reprojecting the images back to the cube. Are you saying there is a simpler method? $\endgroup$ – Goldname Jul 14 '19 at 3:39
  • $\begingroup$ @Goldname Why don't you bake the texture and modify it with the script? That way you can skip projecting it, you simply edit in 2D. $\endgroup$ – Robert Gützkow Jul 14 '19 at 9:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.