Jump to content

Multiple parts using one texture?


Recommended Posts

Heard about putting multiple textures into one file should save performance, is it as simple as putting all parts in one directory and using the same texture in Unity? So when you export it, the models are all looking for the same file? Or can you reference textures outside the model's directory?

Sorry if this has been answered before, have searched the forum but couldn't find anything.

Link to comment
Share on other sites

Supposedly, using one large texture file, rather than several small ones, is slightly better in terms of performance. I don't have any metrics on this, but anecdotally it seems to be true.

Yes, multiple models, or multiple parts, can use the same textures. And they can reference them from outside the same directory, with some caveats, and details that are worth keeping in mind.

* All models (.mu files) and all textures (png, mbm, dds, etc) are loaded FIRST, before the part CFGs are dealt with, so memory is used right away whether the texture or model is referenced by a part or not. This mostly doesn't matter here, but it's worth keeping in mind, especially since it influences the next point:

* When the model (mu file) is processed, it needs to find a corresponding texture with the correct name in the SAME directory, or those meshes will come up as untextured, even if you assign a different texture in the part CFG. This is because it's looking at what assets are currently being loaded, and not what's in the part's CFG yet. This means if you want to use a texture in another directory, you need to have a dummy texture in the same directory as a placeholder. It can be stupidly tiny if you want. I usually make them something like 8x8 or 16x16 in size, but a 1x1 texture might work too. Textures this small sometimes don't work in DDS format, so I'd use MBM or something for these. You can try DDS and switch back to MBM if it fails to load it.

* The re-assignment of textures (particularly when using one in another directory) is done in the part's CFG file, and is name-based. This reassignment also works on an absolute directory path (from GameData), not a relative one. You use the "MODEL { }" syntax for this. For example, in ColorCodedCanisters, I have an orange tank that uses the stock orange textures (including the normal-map), in addition to its own texture. The local texture is in the current folder, but obviously the stock textures are elsewhere:


MODEL {
model = ColorCodedCans/CC2m-Jumbo64
texture = orange-jumbo-0, Squad/Parts/FuelTank/fuelTankJumbo-64/model000
texture = orange-jumbo-1, Squad/Parts/FuelTank/fuelTankJumbo-64/model001
scale = 1.0, 1.0, 1.0
}

In the above example, the model was compiled in Unity with a texture named "orange-jumbo-0" and a normal map named "orange-jumbo-1". I made small dummy images for those, and reassign with the above code.

Edited by NecroBones
Link to comment
Share on other sites

Using atlas textures over mutliple models is more efficient since it reduces the amount of individual render calls for the textures. You can reuse parts of the texture across multiple meshes, potentially saving time and performance.

To do this in KSP, use "MODEL{}" instead of "mesh = " in your CFG

example:

MODEL

{

model = Squad/Parts/FuelTank/mk3Fuselage/LFO_100

}

It will automatically look for textures in the same folder that match the internal reference name of the texture assigned to the material you exported with the mesh.

Link to comment
Share on other sites

  • 3 weeks later...
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...