Question: Combine multiple textured models into one object - re-use materials

Hello and thanks for your time. This is my first blender question.

Let me begin by quickly describing my issue, then afterward I will describe it again in detail. I’m struggling to word my question, so I will include as much detail as I can.

My question is about combining multiple textured objects into a single object to be exported to a game engine, in an efficient way that will allow me to re-use materials.

In Blender, I have created 7 unique “wooden planks”. Each of these is already textured, has the normal maps baked from a high poly sculpt, has a different material, has a uniquely named UV map,

Next, I would like to assemble these planks into a structure. This means duplicating and positioning each of these planks and using them like building materials.

Now for the final step, and here is where I am stuck (here is where my question begins).

If I were to export this to Unity, then it would result in 26 different game objects, possibly 26 draw calls, etc.

Instead, I would like to join these together into a single object. I could use ctrl + j to join them into one mesh. Each of the wooden plank varieties has a uniquely named UV map, and each of their materials has a UV Map node.

And in Blender, this looks great. It looks like it is working (but only in Blender). This is because procedural materials in blender cannot be exported, they must be first baked.

I don’t know how to do it, but my guess is that it’s possible to join them together, then UV unwrap the Joined mesh, and then somehow bake the details into that. This might create a single, final image with the entire structure UV unwrapped and textured. However, that means that all 26 planks would occupy a small part of the UV, meaning each plank would lose a significant amount of detail (resolution).

For instance, one of the wooded planks is duplicated 9 times in the final structure. So that single plank, would occupy 9 unique sections of the final UV map, even though it’s the exact same object.

But not only will the texture lose significant detail, the final result would be a unique image (PBR texture set), which can’t be used for anything else.

But I would like to create tons of structures from these 7 wooden planks, which results in only 7 materials in Unity. This way I could re-use the materials and textures across all of the structures.

So, my goal is to find an efficient way to build structures with these 7 planks (7 materials), and join them to be exported, while being able to re-use the 7 materials in Unity.

What are my options? How are game studios doing this? They can’t possibly have a separate 4k PBR texture set (3+ 4k images) for every single structure. There must be a way to re-use objects and re-use materials.

So, in case I wasn’t clear, I would like to create a toolbox of polished, textured building blocks. And then assemble them to create tens of structures. Export these to a game engine. And be able to re-use the materials efficiently.

Final Note: I do have access to Substance Painter, if that somehow unlocks options.

Thanks again!

2 Likes

Blender and game engines are two different tools. Optimizing objects can be different for those tools. For the game engine you are looking for CPU cycles (how many faces (triangles) you can handle to get a smooth game play).
Blender has more like optimizations of creating content and re-use in scenes and animations.

You should first think about what kind of games object you need and what to do with them.
Now you’ve created beautiful planks, but the end goal is to have a structure. Unless you do want to blow up the structure, you do not need planks for this. Just the object of this structure in the game.

But for Blender it is handy to have loose planks, so that you can design alternate structures. easily in a creative process.

There a lot of things to consider, all depending on what you are trying to achieve. Make that clear for your self. Where lies the efficiency in the work order and end usage.

Questions like, can I walk around it (3D model) or is it an object far away in the distance (which could be a rendered 2D image. Or do I need details (close-ups) and when do I need them.

The structure you’ve created is very hard to UV-Unwrap in Blender (as one object), a lot of islands. You can of course overlay some parts (islands) to use the same bitmap (Like the front and back of the plank), both are never seen at the same time. Painting is hard (Substance will help).

You could invest more time in reading about export Blender and import into game engines. How does this process work. Because creating textures for planks in a games is probably work for the last part of game development.

See other forum topics about this: WIKI - Interesting forum topics, problem solving issues

2 Likes

Hey Pete,

Thank you for taking the time to respond to my question. Your wisdom on how to determine what needs optimized is valuable.

With that said, I don’t feel that this response quite targets my question. And for that, I apologize for not asking it clearly enough. I did struggle to word it.

Here are a couple of notes about how I’m already trying to optimize (the reasoning behind my question):

  1. Creating a unique PBR texture set for each structure is inefficient. This PBR texture set can only be used for that one structure. So if you create 10 structures (chicken coop, bench, window shutters), then that would result in 10 different texture sets (10 albedos, 10 normals). But if all 10 of those structures were built with the same underlying planks, then we should be able to share the materials between them.
  2. Unity batching works by grouping together game objects by their materials. Re-using materials across game objects will allow me to make the best use of batching.
  3. When purchasing asset packs (like Polyart Village) from the Unity asset store, I can see that Polyart studio re-uses materials (based on a wood trim sheet) across tens of prefabs. So I know that what I’m trying to accomplish is possible. When I inspect these prefabs, I see that they are a single mesh, but that mesh was exported with multiple UVs (UV0, UV1). And in Unity, multiple materials are assigned to that mesh.

GameDevTV has a course where they build modular walls to create a modular building. Each wall variety seems to have a material. This way the walls sharing that material can be batched. If you compare that to my wooden plank question, that would mean I would actually export each wooden plank separately, and construct the structures in Unity. But obviously that would result in A LOT more game objects than the GameDevTV Modular building course. Sticking with that example, this would mean that Rick would have to join all the walls together into a single mesh, before exporting to Unity.

Again, thank you for taking the time to respond to my question. However I feel my question is still unanswered and would appreciate additional responses (not to discredit your response in anyway, it was really helpful).

Thanks!
–Nathan

2 Likes

First, I need to make a correction to your thought process. You wouldn’t have 9 areas of the image. You would have 9 Islands that would be layered on top of each other, because they use the same Pixel to Texel information. So, it would be just 1 area for those 9 planks.

Second, it’s all about Planning. In your case, you would select all 7 separate object then tab into edit mode and align all the UVs so they are separated in the UV Map. Then create the textures. Then you can add as many of them as you want to a single object, because when you join them their position on the UV Map will be the same for each individual plank and they will automatically be layered on top of each other. In fact since they are all wood planks you could even use the same wood texture for the 7 planks and even have their UV islands overlap, but that would take a lot more planning and reduce individual details for each plank.

Third, UDIM are a great way to use smaller texture images and get more resolution on the faces of your object. This does increase the number of Physical images, but each image can have different resolution and only requires 1 image input. As of 1 year ago, the last time I looked into it, Unity didn’t support UDIM. So this may not be an option currently.

1 Like

Hello Dwayne,

Thank you so much for responding!

I’d like to make sure I understand what you’re recommending.

This is my understanding of your second paragraph:

Rather than individually model, sculpt and texture 7 different “Wooden Plank” objects separately (resulting in 7 different 2k texture sets), you’re instead suggesting that I create a single texture atlas which contains the textures / UVs for all 7 in one file. Doing this would reduce the number of files/images/texture sets from 7 sets to only one set, but it would also reduce the resolution/detail of each Wooden Plank to probably 1/7th. Is this what you were recommending in your second paragraph (to combine all 7 planks into a single texture atlas)?

I do think that I could benefit from reducing the number of Texture Sets into a texture atlas, as an extra optimization.

I’m not quite sure what you’re recommendation is, in your first paragraph.

It sounds like you’re suggesting that somehow overlapping UV’s can help, but I don’t understand specifically where I can use that? I don’t think you’re suggesting that the final structure (like a chicken coop built from 30+ wooden planks) be UV unwrapped and baked into a “ChickenCoop” texture set (coop albedo, coop normal, etc). Not to mention I’m pretty sure we can’t have overlapping UV’s when we bake multiple textures / uvs into a single texture set. But either way baking and creating a texture set for each structure wouldn’t give us a result that lets us share materials. So I don’t think that’s what you’re suggesting, but I wasn’t sure how else overlapping UV’s could be applied in this case?

Sorry I didn’t fully understand your advice. I know you put effort into helping me.

I think I found a solution, but I want to take my time to write a new reply and organize my thoughts carefully. I will write a second reply here.

Thanks again.

1 Like

I believe I have found a solution, I will re-summarize the problem and explain my solution.

My Objective:

Assume we have 7 separate objects, which are each already textured, have normal maps baked from high poly sculpts, UV unwrapped.

Each object has it’s own material, with a set of texture images:

Let’s say that I want to treat these Wooden Planks like building blocks, and construct tens of structures from them (a chicken coop, a bench, a shed, a barricade). I could do this by creating linked duplicates (alt + d) and positioning the wooden planks.

I assembled linked duplicates of the planks into a structure:

If I were to export this structure to Unity game engine (as FBX), it would result in almost 30 game objects. And, this isn’t even a bad example. Imagine if I tried to build a wooden dock (floor) out of 100 planks (by duplicating a few unique ones). So my objective is to somehow export only one mesh by joining all of the planks (ctrl + j).

Each of the planks has it’s own uniquely named UV map. If I were to grab a few, and join them, then the textures for some would immediately break.

However, if I give every one of the planks an additional UV map with the exact same shared name before I join them, then when I join them, the list of UV Maps will include each of the individual names, as well as the shared one.

Added this:
same name

After joining:

Then I remove all of the UV Maps, except the one with the shared name, and activate that one:

Then now they are all joined as one mesh, and the textures appear correctly. At this point, it’s done and working. But the last step is to just export and verify that it works in Unity.

When exporting an FBX from Blender to Unity, the correct settings to prevent the object from having default rotation is y up and negative Z forward. Also check Apply transform to make the root object and children objects (if any) all have a scale of 1 ( to avoid that scale of 100 issue on children ). Finally, make sure your model is “facing” the -y direction, and has zero rotation and scale (meaning go into edit mode and rotate it to face -y).

export settings

In Unity we can see that the final prefab has no children because it’s a single mesh with multiple materials assigned. Because of this, we can create as many structures as we want from these materials, and they will all share the materials, allowing us to use Unity batching.

And finally if we inspect the final mesh in Unity, we can see that it has color coded each index, each material and it identified only a single UV (UV0)

So, hopefully I’m not missing something obviously bad about this approach. But I think this solution accomplishes exactly what I was hoping for. It allows me to construct as many structures as a I want from some building blocks, and export them to Unity as a single mesh. All of the structures will share the same handful of materials (for batching and texture space). All of the building blocks can use the full UV space (high resolution textures). And each building block can be constructed and modeled individually.

I hope this helps someone else because I could not find this online anywhere.

3 Likes

Thank you, for your study on this matter. I’ve added it to the WIKI.

Pete

3 Likes

Hey Dwayne,

Before the thread locks, I wanted to follow up with you about your advice. Today I took your advice, and I re-textured all 7 planks and combined them into a single texture Atlas.

Here is the combined UV, and the final texture atlas:

Now each of the 7 planks uses the same material, built from the same texture atlas (image file). This has greatly reduced the memory required. While it did result in a significantly lower resolution allocated to each plank (since there are now 7 UVs within one image), I doubled the image size to 4k to help compensate. I think it still looks good enough.

So I wanted to say thank you again for your advice.

4 Likes

No problem. Also side note when you build something using these planks and join them into one object they will keep the UV location for each plank. So no additional work on your part.

2 Likes

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms