2
$\begingroup$

My object consists of two materials. One of them has a texture attached. What I want is to uv map the whole object to a single texture so I can read it in opengl easily without an mtl file.

So, this is what I did in steps(I'm a beginner and I don't know what I might have done wrong so I'll mention as many steps as possible even though they may be irrelevant, obviously correct or very simple steps):

1)I set up 3 views: 3D Viewport, UV editor and shader editor.

2)I joined the parts of my object into a single one. Now in the collection I can see it is referred to as a single object.

3)I select the object in edit mode. Now I can see the uv unwrapping in uv editor.

enter image description here

4 ) Having selected the object in edit mode, I add a new uv map under the object data properties :

enter image description here

5 ) In the 3d viewport I press U and choose smart UV project. Now I can see the new uv unwrapping :

enter image description here

6 ) I create a new image in UV editor and save it. Now the background behind the uv unwrapping is black so the texture has been created.

7 ) For the material that has a texture I added a few nodes in shader editor. You can see how it was in the 1st picture and what I added in the second :

enter image description here

enter image description here

8 ) The other material has no texture attached so I only added the two nodes(the texture image node with the bake texture and its uv map input).

9 ) Having selected the texture nodes with the texture to be baked(in both materials), I go to render properties -> bake and I change bake type to diffuse, uncheck direct and indirect, leaving only color, and then press bake.

Doing that, it seems that the material with the texture goes over the other material producing this :

enter image description here

In the previous bake the material that is open in shader editor is the one with the texture. If I view the other material(the can, the metal) and bake again , this is what I get:

enter image description here

This time, the material with the texture is baked only where it should but the other material ends up as black for some reason. I tried adding a texture to the metal , making its nodes in shader editor just like the ones of the other material. In the 3d viewport I can see the new texture is loaded correctly but in the bake I still see black.

What am I doing wrong and why does it matter what material I choose in shader editor?

This is the blender file. Hopefully I've done the packing correctly. In this version I've attached a green texture to the can.

$\endgroup$
5
  • $\begingroup$ hello, you could create a second object and use the Selected to Active option, it would make things simpler, but maybe pack your images and share your file? pasteall.org/blend $\endgroup$
    – moonboots
    Jun 13, 2021 at 12:58
  • $\begingroup$ @moonboots I've uploaded my file. Link is in the question. I'm not sure I understand what you said but I'll try it now. $\endgroup$ Jun 13, 2021 at 13:09
  • 1
    $\begingroup$ it seems to work fine, select the Image Texture node with the bake image in both the 2 materials like you've done. Note that if your material is 100% metallic it won't be able to bake any diffuse, just black color, this is what's happening $\endgroup$
    – moonboots
    Jun 13, 2021 at 13:18
  • $\begingroup$ You are a lifesaver. I've wasted at least 3 hours on this. I changed metallic and it works like a charm. Just out of curiosity now, why do I get the result in the first 2 pictures after step 9? I have selected the image texture in both materials. When the label material is open in shader editor, I get this undesired result. When the can material is open, everything is baked fine. $\endgroup$ Jun 13, 2021 at 13:24
  • $\begingroup$ you must have somehow used a wrong UV map node? $\endgroup$
    – moonboots
    Jun 13, 2021 at 13:28

1 Answer 1

2
$\begingroup$

Select the Image Texture node with the bake image in both the 2 materials like you've done. Note that if your material is 100% metallic it won't be able to bake any diffuse, just black color, this is what's happening.

$\endgroup$

You must log in to answer this question.

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