- Home /
Multiple textures layered in a single mesh
I've read at this forum some questions similar to mine, but no one seems to have the answer for what I'm looking for. I'm working with customizable characters, and what I'm looking for is basically to apply different textures to a single mesh, overlaping them hierarchically (not only replacing one texture with another one), like shown on the image. Does anyone have any clue about how to do that?
Many thanks
Answer by Noise crime · Jul 21, 2010 at 06:16 PM
If the model is a single mesh, with a single material you can just 'add' materials to its mesh in the inspector.
If you look at a model in the inspector with a mesh render component assigned you'll notice you can add further materials by setting the size value. Normally this is for use with mulit sub-meshes, but you can assign as many materials as you like.
Any materials > number of meshes will be applied over the top of the material assigned to the last sub-mesh (if you have a single mesh then its just applied over the top of it). Frankly its rather odd behaviour as although it works for single meshes, its no use for multi sub-mesh models as only the last sub-mesh will have the additional materials applied to it.
Its a bit hard to explain, but if you give it a go, it should become obvious. I asked a question about this behaviour myself, but never really got a good answer as to why it works as it does or if its even intentional.
If you have multiple sub-meshes then its unlikely to be of use, in which case writing a shader is your best. Although I guess you could always write some code to composite a sequence of textures into a final version, avoiding the need for a shader and reducing draw calls.
$$anonymous$$any thanks! It seems to be exactly what I was looking for. I'll try that here. Thanks for replying!
Yay! It worked! $$anonymous$$any many thanks! I just have a concern about that. I'll try to make myself clear, because I'm quite a newbie on unity (actually, I'm a character artist with not much experience with engines ). $$anonymous$$y question is: How does unity handle all this maps applied on a single material? I mean, does Unity "converts" all the different textures in a single one into the engine to optimizing the file size?
Well you're not adding maps, but adding materials, so there is no additional memory overhead. However there is likely to be gpu processing overhead as each material will (I believe) need another render pass per additional material you add to the list. Effectively what you are doing here is (as I understand it) telling Unity to render the mesh with the first material, then render again with the next material in the list and so on.
There is no texture compositing or optimisation going on, though that should not be a problem. You need all the textures in memory regardless which method you choose.
Omg, just saw this now and it is so helpful!!! Thanks Noisecrime
Answer by equalsequals · Jul 21, 2010 at 01:36 PM
You can achieve that with multi sub-object materials.
Note: This is done in the design phase of your mesh and isn't done inside of Unity.
This involves breaking the character's body apart by poly face and assigning a specific material ID to each separate section. From there each part can have a separate texture applied to it. See Tutorial linked above.
Keep in mind that the more materials you have the more GL draw calls your character requires.
Hope that helps.
==
Yes, but I the character I'm using as a reference for that it's not breaked in so many pieaces. The forearm for example, it's made in one single piece. It really seems that there's a texture overlapping...
This could be done with the method I mentioned above but with some clever texture mapping techniques.
You could also go so far as to write a shader that linear interpolates multiple textures together based on masks.
I have not been able to test the original method yet of setting multiple textures.
however I have used the lerps with textures to do this, the lerps have the added bonus that in my case remove the clamp mode stretch.
I have a couple of question, regarding both methods, however I will explain my situation as for you to get a better understanding
I am currently making a mobile game, I am trying to avoid draw calls so have made my own terrain as a single mesh.
Currently the texture res is too low for a single texture, again I dont want to split the terrain into 4 and assign each a texture as thats 4 draw calls ins$$anonymous$$d of 1.
I have done the lerp stuff in UD$$anonymous$$ for the exact same thing but the target platform was PC (portfolio work)
I can make a similar shader in unity without much issue.
So to my questions. the original method of changing the ammount of materials for the mesh have any cost associated, it seemed to be somewhat speculation that it would render the mesh for each texture - thus defeating the point here.
For my example I clamp the texture and tile it twice (so it takes up 1/4 of the mesh, then just offset the other 3 to their location. Problem is that clamp mode has the edge stretch effect, is the case for the original mode?
lastly, out of the two (if the original doesn't cost any more draw calls) is cheaper to do?
Answer by PetrSevostianov · Feb 09, 2015 at 03:13 PM
Hi! You can try Unity utility CompositeMap: https://www.assetstore.unity3d.com/en/#!/content/28788
It works similar to CompositeMap map in 3ds Max or Layered Texture in Maya and allows to create and customize textures using masks of materials.
Just look at the video: https://www.youtube.com/watch?v=PAKyw2eWld4
Your answer
Follow this Question
Related Questions
How can you get multiple materials/textures on the same object in unity 5? 2 Answers
How do I apply Multiple textures to a surface? 1 Answer
Better to use multiple objects or textures with basic paperdolling? 0 Answers
how to apply multiple layers of textures to a billboard? 1 Answer
Meshes with multpile texture maps--is it possible? 3 Answers