1
$\begingroup$

I am doing a camera projection (from a picture onto a 3D object). In the picture I am projecting from, there are some hidden parts of the object due to the geometry of the object itself, and I would like to avoid Blender to "invent" those hidden parts of the texture by repeating other visible parts so I can know accurately and quickly which parts are still needed to be photographed in order to complete the full texture of the object.

My idea is to bake the projection over a green chroma texture but I do not want the UV project modifier to complete the texture regarding those hidden sections of the 3D piece (which is currently doing).

Does anybody know how to avoid that?

EDIT: Just discovered the image is being projected onto every voxel colliding with each ray from the camera, which means it is being projected onto backfaces where (in my opinion) it should not. Researching deeper in this, I just found a topic which describes my problem and potential solution:

Cycles, UV Project Camera Modifier projects forwards and backwards

It suggests to use object's negative Z coordinates to "blank" those parts of the texture and therefore avoid printing backfaces. Is there any other solution? Tell me if you consider to remove or to solve this thread or mark it as duplicated in case there is no other possible solution.

Thank you again for your feedback. Best regards, maije

$\endgroup$
2
  • 1
    $\begingroup$ It's unclear what techniques you're using to do your camera projection. If you're not after perspective, then doing it with object coordinates from an empty, discarding one side of the object, as demonstrated in your link, is usually the simplest way to get what you want (doesn't necessarily work well in presence of concavity though.) For concavity or perspective, you should be looking at texture painting instead-- either using your projected image as a texture for texture painting, or simply painting a black and white mask from a particular view. $\endgroup$
    – Nathan
    Jan 18 at 20:52
  • $\begingroup$ I am using perspective, as I'm trying to project from a picture, so the orthographic view is not realistic and would lead to perspective distortion, even if I have done some camera lens correction on the picture beforehand. In addition, "hand-made" texture painting is also discarded, as I am willing to do it within a script, so it has to be an automated process. Thank you for your support $\endgroup$ Jan 19 at 11:53
0
$\begingroup$

You've indicated a few details in your comments: you're using the perspective of the camera for your UV projector; you want to do this using only scriptable tools (no mouse strokes). For that, the linked answer you gave won't help you.

You need to make a mask for your projected image. As I indicated in comments, the easiest way to make this mask is just by hand, with texture painting. But it's not impossible to do it another way:

  1. Make your object flat shaded. Give it a diffuse material. If it's not UV mapped, give it a non-overlapping UV map (a smart project or lightmap project would be fine.)

  2. Place a point light at the location of your UV projector camera. Set the radius to 0 and the light to something really high (like 100,000).

  3. If necessary, remove everything but the object and point light from renders. Set bounces to 0.

  4. Create an image texture node in your material and bake combined to a new image. Save your image.

  5. Create compositing nodes using your baked image (not a render). For each pixel of your image, check to see if the brightness is greater than 0. Make your output 1 if it is, 0 if it isn't. Set your color management display device to None. Set your rendering resolution to the same resolution as your baked image. Render. Save the render. As necessary, revert to settings used at the start of the process.

You now have a mask created using only scriptable operations that represents the occlusion (only) from your UV projector.

enter image description here

Let me know if that image is bugging out for you-- Imgur looks like it's freaking out or something. Check comments for a different image host.

$\endgroup$
4
  • $\begingroup$ pasteboard.co/JKpcjFM.png has the image (incl nodes) if Imgur's just showing you nonsense like it is for me. $\endgroup$
    – Nathan
    Jan 19 at 19:46
  • $\begingroup$ Dear Nathan, this is genius. I am sorry for the late reply, but until today I could not try the solution you gave me. It's so clever to use a point light, overexpose it and bake that as a mask to be used to choose a projected texture or chroma pixels on my texture. It worked smoothly and I believe I can script every step. Unfortunately, I cannot upvote your answer (too low reputation) so I beg the administrators do to so. Thank you so much for your very appreciated support on this. PS: I also see a weird image on your post, but only with the text I got your idea. Best regards, maije. $\endgroup$ Jan 24 at 19:22
  • $\begingroup$ @JaimeFinat I'm glad you're happy. Don't worry about upvotes-- SE points are worth exactly nothing. Imgur was acting weird; proper image is the comment, and should be active for a few days. $\endgroup$
    – Nathan
    Jan 24 at 22:34
  • $\begingroup$ no worries about the image. I checked it after reading your answer, but in the end, I came up with my own nodes configuration as I added some more "sugar" to the result ;-) Again, so clever to realize the point light will impact just the same areas as the camera rays so it could be baked with exact results as a mask. Thank you! $\endgroup$ Jan 25 at 19:51

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.