- Home /
Merging Textures
Hi
I have a building with 3 textures that bend one on top of the other to create the desired visual. I bought this building fbx file. I naively openned it up and tried to 'bake' the 3 textures into one using 3ds max but it did not work.
If I import the fbx into unity, it works just fine but it uses 3 drawcalls. This is for the iphone so it would be great if I could use 1.
Is there a way to merge the 3 textures using unity? otherwise, any other tool that would do the trick? 3ds max doesn't seem to bake this one correctly.
Answer by skovacs1 · Sep 17, 2010 at 04:14 PM
You seem to be concerned over your draw calls. Are you sure that the mapping is the cause of your draw calls? Do you have separate objects with separate materials? How many lights and what lighting mode are you using? Are you doing anything fancy with your camera renders? What kind of shaders and effects are you using? There are too many things that can up your draw calls. Please see this Unite presentation for some useful information.
Assuming that your materials are the issue, the real problem is that 3DS max materials are separate materials and even the blend/composite/Multi-SubObject materials only take in multiple separate materials, not separate maps.
If the only thing different about your materials is a map of some kind, then you can merge them into one map and apply them as one material, but if the material properties are actually different, then it becomes harder and you would either need separate draw calls or to generate merged maps of the material settings as well but that still may not reduce your draw calls.
Merging your maps
If your maps are blended in a fairly straightforward manner, you could author a simple 3 Blend shader in Unity that takes in 3 materials to do your blending and it would look kind of like this:
Shader "Example/3 Alpha Blended Textures" {
Properties {
_MainTex ("Base (RGB)", 2D) = "white" {}
_BlendTex ("Alpha Blended (RGBA)", 2D) = "white" {}
_BlendTex2 ("Alpha Blended (RGBA) 2", 2D) = "white" {}
}
SubShader {
Pass {
// Apply base texture
SetTexture [_MainTex] {
combine texture
}
// Blend in the alpha texture using the lerp operator
SetTexture [_BlendTex] {
combine texture lerp (texture) previous
}
// Blend in the alpha texture using the lerp operator
SetTexture [_BlendTex2] {
combine texture lerp (texture) previous
}
}
}
}
To reduce the memory and load though, it would be better if you just took the maps and merged them into one. You could use your image editor of choice, applying the appropriate deformation according to your UV's (which you can get with Unwrap UVW's if you need - look up UV unwrapping), or you could just bake the textures in 3DS max - RenderToTexture and add as output the map you want (diffuse for example)(see this tutorial if you're having trouble).
To make your life easier, with your shiny new merged map, in max, change the material on your object to one that applies your map. When you import into Unity, it should import only the one material with only the one map.
Separate material settings
You would generate one or more maps like the above for your material settings and then you would have to author a slightly more complex shader that applies the settings with the values you've input. Since I don't know the specifics of your materials, I can only guess at what settings would be different, but you could just look at the source for the built-in shaders for reference and adjust those.
Answer by squall_789 · Sep 17, 2010 at 04:05 PM
Why not just use Photoshop? Or GIMP...those are made for editing images, whereas MAX and Unity are not. Plus in Photoshop you can have Blend layers too so you can more easily tweek it, though you might want to export your UV map into photoshop in order to line it all up propperly, otherwise it will be ugly looking.
Answer by alexnode · Sep 17, 2010 at 04:05 PM
After baking to texture you should have one texture, did you combined the meshes ? there are some tools that can create atlas maps, search online it is exactly what you are trying to do...
The manual way is like that ...
In order to bake to texture you need to combine(attach) the three objects(automatically a multisubobject material will be created,) then you need to create a temporary 2nd Uv channel, where all the textures fit in one uv tile with unwrapp modifier. Just fit everything in the box (you could use automatic unwrapp but i really don't recommend it for such an optimized work required for an I-phone.)
After that in render to texture you should choose 2nd uv channel for baking . in practice you read the three materials and bake them in this new channel. After finishing rendering you should replace the 1st uvchannel with the baked 2nd uv channel, just make the first uvchannel 1st. collapse the mesh and then with the channel info tool delete the unesseccary 2nd uv . then create a new material that has only the baked texture in diffuse channel.
hope that helps...
Answer by PetrSevostianov · Feb 09, 2015 at 03:13 PM
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 merge and customize textures using masks of materials.