Jump to content

Using multiple textures on one Mesh


Recommended Posts

I'm reworking some easy fueltanks now, and to reduce RAM usage I wanted to put the top and bottom portions one one texture file and all the sides one one texture file.

I have already made two UV layouts of the first tank for the two textures:

fwMKfij.png

lpL94Ak.png

Now I have pretty much no idea on how to assign parts of the mesh to the two textures. I have read some blender tutorials using multiple materials, but they were no real help. I could kinda make it work in blender (though I was not sure what I was actually doing), but ocne I tried getting the thing into Unity the material names and textures were all messed up.

So my question is how to get multiple textures on one mesh in Blender and how to set the textures up in Unity. Some examples would be greatly appreciated.

Thanks for any help.

Link to comment
Share on other sites

put the two UVs into a single texture. you've got plenty of space for both. It'll be more efficient in game than two materials. you can then adjust the UVs for the various tanks to sample different areas, sides sample the side area of the texture, ends sample the end area of the texture, so you have 1 texture for all your tanks.

http://i.imgur.com/8P8F4yF.jpg

Edited by nli2work
Link to comment
Share on other sites

put the two UVs into a single texture. you've got plenty of space for both. It'll be more efficient in game than two materials. you can then adjust the UVs for the various tanks to sample different areas, sides sample the side area of the texture, ends sample the end area of the texture, so you have 1 texture for all your tanks.

http://i.imgur.com/8P8F4yF.jpg

The room I left was on purpose, since I haven't modeled the smaller tanks yet. They will be filled.

I found the problem I had too, I was using two UV layouts, which apparently doesn't work.

Now I still have a problem, once I export my mdoel to KSP it looks like this:

espRyoX.png

It only shwos the parts that are mapped on the top texture, but with the side texture applied.

This is how the mesh is set up in unity:

nqvMWzo.png

Link to comment
Share on other sites

Gotcha. KSP only reads 1st material on a mesh object. you have to split the tank into as many mesh objects as materials you use. 1 UV set per mesh as well. That said, unless the smaller tanks will have completely different looks, in which case it's probably more efficient to group the smaller tanks into another texture.

Edited by nli2work
Link to comment
Share on other sites

Gotcha. KSP only reads 1st material on a mesh object. you have to split the tank into as many mesh objects as materials you use. 1 UV set per mesh as well. That said, unless the smaller tanks will have completely different looks, in which case it's probably more efficient to group the smaller tanks into another texture. I would just sample smaller areas of the main texture on the smaller tanks. e.g. a half length tank would sample the ends as the full size tank, but only half the side texture area.

Ooh, that explains my problems of course.

The sides of the smaller tanks are supposed to look different, only the top and bottom parts will be reused across all of them.

Hm, If I put it all on a 1024x1024 texture the quality is drastically reduced, So I'll probably have to go with a single huge 2048x2048x texture. :D

Thanks for your help!

Edited by Socke
Link to comment
Share on other sites

Ooh, that explains my problems of course.

The sides of the smaller tanks are supposed to look different, only the top and bottom parts will be reused across all of them.

Hm, If I put it all on a 1024x1024 texture the quality is drastically reduced, So I'll probably have to go with a single huge 2048x2048x texture. :D

Thanks for your help!

Holy cow, 2k x 2k? That's pretty huge. :)

It's really simple to just have the ends be separate mesh objects in blender, and then they can use the shared end-cap texture. Just make sure they use different materials, and then in Unity you just have to assign the right textures and shaders to each mesh-object.

This is a really useful thing to keep in mind for cases like this. Separate mesh objects also can be useful if you want to have more than one emissive, or different shaders for different parts of the model.

Link to comment
Share on other sites

Holy cow, 2k x 2k? That's pretty huge. :)

It's really simple to just have the ends be separate mesh objects in blender, and then they can use the shared end-cap texture. Just make sure they use different materials, and then in Unity you just have to assign the right textures and shaders to each mesh-object.

This is a really useful thing to keep in mind for cases like this. Separate mesh objects also can be useful if you want to have more than one emissive, or different shaders for different parts of the model.

In the end I was able to put it all into one 1024x1024 texture :D

lULEqC8.png

This texture is used by six fuel tank models :)

I'm still a bit puzzled about the shared texture thing. The MODEL section of the cfg files looks like this:

MODEL{
model = SockeAA/Parts/F25/model
texture = tank.mbm, SockeAA/Parts/F100/tank.mbm
texture = NRM.mbm, SockeAA/Parts/F100/NRM.mbm
}

The texture lines are the same in all of them but I still need to have the texture saved six times, and according to the debug menu it also is loaded six times. How would I fix this?

Link to comment
Share on other sites

you need a dummy texture in the part folders for MODEL{}.

I export the proper MBM textures with the 1st part; move the MBMs to the centralized folder for the pack; export the part again but with different texture format like PNG, resize those PNGs to 1x1; one color PNG is 1KB. now export the rest of the parts into their part folders, texture format doesn't matter at this point. copy the 1x1 dummies to all the subsequent parts that share the same texture; and delete the full size textures in those part folders.

for future part updates, export one of the parts with format you use for actual textures, move those into the centralized location and replace the old textures, and that updates textures for all the parts that share the texture. other part updates (new mesh or UV) just export to a different format than what you use for the dummy textures, and delete the new exported textures, keeping the dummies in the part folders.

Edited by nli2work
Link to comment
Share on other sites

you need a dummy texture in the part folders for MODEL{}.

I export the proper MBM textures with the 1st part; move the MBMs to the centralized folder for the pack; export the part again but with different texture format like PNG, resize those PNGs to 1x1; one color PNG is 1KB. now export the rest of the parts into their part folders, texture format doesn't matter at this point. copy the 1x1 dummies to all the subsequent parts that share the same texture; and delete the full size textures in those part folders.

for future part updates, export one of the parts with format you use for actual textures, move those into the centralized location and replace the old textures, and that updates textures for all the parts that share the texture. other part updates (new mesh or UV) just export to a different format than what you use for the dummy textures, and delete the new exported textures, keeping the dummies in the part folders.

Okay, thank you. I assume I need a dummy for the normalmap too then, right?

Link to comment
Share on other sites

you need one for every texture (Normal; Diffuse; Emissive) referenced by MODEL{}, file name has to be exact match. those that aren't shared can stay in the part folder and not reference them in MODEL{}. KSP loads everything (used or not) in GameData; and MODEL{} texture replacement happens during part compile phase. if a texture isn't being replaced using MODEL{}, KSP will look for it in the same folder as the MU. I haven't had any problems doing things that way, but a few has run into issues where MODEL{} doesn't replace textures correctly preventing parts from compiling correctly.

another option is export everything with dummy texture to begin with. and your MODEL{} would look something like this

MODEL{

model = model path

texture = dummyDIF, Diffuse texture path

texture = dummyNRM, Normal texture path

texture = dummyEMI, Emissive texture path

//Only necessary if other than 0,0,0 and 1,1,1

postion = x,y,z

rotation = x,y,z

scale = x,y,z

}

Edited by nli2work
Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...