Jump to content

[1.12.x] Recolour Collection


Recommended Posts

On 7/25/2024 at 9:36 PM, ZZetho said:

Textures Unlimited Recolouring Tutorial pt1 (minimum viable product).

I threw this together in like an hour so there's definitely stuff i forgot about, please tell me if you have problems.

More info can be found on the Textures Unlimited Wiki.

I use paint.net and notepad++ but any text editor and image editor should work fine.

You need to have both Module Manager and Textures Unlimited installed to do this.

You also should install the mod Part info in PAW to get part names more easily

This wont work for parts that have texture variants (though it can be done), if variants don't change the texture it should be fine.

First of all go into GameData/000_TexturesUnlimited/GeneralConfiguration and set exportUVs to true, once you have launched the game at least once this will create a folder "expotedUVMaps" in your ksp install folder (one level up from gamedata) which contains the info for every texture that every part uses as well as any other properties that the part has (eg: shininess).

Next create a folder in gamedata, this will be where all of the recolour stuff will go, inside your recolour folder make three .cfg files (make a .txt file then rename it to .cfg) one is for texture sets one is for the default (un-recoloured) textures of parts and one is for recolouring the parts so name them accordingly.

Also create some folders in here, these will hold the recolour textures and default textures for if parts don't have them. Just copy the folder named "Default" from any of my recolours to get the default textures.

File tree should look something like this:

os0sM55.png

Copy the following into the texture sets file:

  Reveal hidden contents

// texture sets that are copied to create the default and recolour texture sets //

KSP_TEXTURE_SET:NEEDS[TexturesUnlimited&NearFutureLaunchVehicles]
{
    name = NFLV_Default
    title = Squad
    recolorable = false

    MATERIAL
    {
        mode = create
        
        shader = KSP/Emissive/Bumped Specular
    }
}

// create red green and blue if they dont exist already //

KSP_COLOR_PRESET:NEEDS[TexturesUnlimited]
{
    name = absolute_red
    title = Absolute Red
    color = 255,0,0
    specular = 0
    metallic = 0
}
KSP_COLOR_PRESET:NEEDS[TexturesUnlimited]
{
    name = absolute_green
    title = Absolute Green
    color = 0,255,0
    specular = 0
    metallic = 0
}
KSP_COLOR_PRESET:NEEDS[TexturesUnlimited]
{
    name = absolute_blue
    title = Absolute Blue
    color = 0,0,255
    specular = 0
    metallic = 0
}

KSP_TEXTURE_SET:NEEDS[TexturesUnlimited&NearFutureLaunchVehicles]
{
    name = NFLV_Paint
    title = Bob Ross Paints
    recolorable = true
    
    MATERIAL
    {
        mode = create
        
        shader = TU/Metallic
        
        keyword = TU_RECOLOR
    }
    COLORS
    {
        mainColor = absolute_red
        secondColor = absolute_green
        detailColor = absolute_blue
    }
}

Change "NearFutureLaunchVehicles " to the name of whatever mod you are recolouring (the name of its folder inside gamedata).

For each of the texture sets change name to something unique.

xcmHBrf.png

Copy the following into your default file:

  Reveal hidden contents

// default texture template //
@PART[partName]:FOR[000_TU_NFLV_000]:NEEDS[TexturesUnlimited&NearFutureLaunchVehicles]
{
    MODULE
    {
        name = KSPTextureSwitch
        sectionName = Appearance
        currentTextureSet = NFLV_Default
        textureSet = NFLV_Default
    }
}
+KSP_TEXTURE_SET[NFLV_Default]:NEEDS[TexturesUnlimited&NearFutureLaunchVehicles]
{
    @name = NFLV_Default
    @MATERIAL
    {        
        texture = _MainTex,
        texture = _BumpMap,
        texture = _Emissive,
        
        PROPERTY
        {
            name = _Shininess
            float = 0.4
        }
    }
}

First of all change "NearFutureLaunchVehicles" to the name of the mod you are recolouring. Change 000_TU_NFLV_000 to 000_TU_somethingThatIdentifiesWhatModIsBeingRecooloured_000. Change currentTextureSet, textureSet and @name from NFLV_Defalt to something else. Change the NFLV_Default in +KSP_TEXTURE_SET[NFLV_Default] to whatever you called the first texture set in the texture sets file (NFLV_Default in the previous pic). Change the partName in @PART[partName] to the internal name of whatever part you are recolouring, assuming you have Part info in PAW you can click on "Copy Part Name" in the right click window of a part.

To fill in the rest of the missing bits you'll need to open that exportedUVMaps folder from earlier and navigate to whatever part you want to recolour and open its ModelData.txt file. In here you will find the mesh(s) that the part is made of and the path to the textures they use, copy these texture paths into the default texture sets file, each part needs a _MainTex and a _BumpMap, _Emissive is optional, remove it if the part doesnt have one. If the part has no bump map use the one found in that Default folder you copied earlier.

ModelData also shows what properties are applied to meshes, if there are any, copy the properties name and value into the property node. if there are multiple properties copy the node (from PROPERTY { to } ) and put them one after another (though i've never encountered part with anything other than shininess).

rBCK2da.png

Some parts have multiple meshes, this is fine unless they use different textures, if they do come back later for when i make a part two of this tutorial or try a different part. you can ignore any meshes called flagTransform though.

Once you've done this once for a part from a mod you can copy it and only change the parts that are different between parts, the partName, the currentTextureSet textureSet and @name should be unique per part and the textures will of course be different.

If multiple parts use the same textures you can do multiple parts at the same time, put their internal names one after another in the partName box with commas separating them.

Great job! if you did everything right when you launch the game the part should look absolutely indistinguishable from what it did previously (it should also have a selection box with no other options than "Appearance" in its right click menu). If it didn't work check the common issues section at the bottom of this post.

Now we need to recolour it.

Copy the following into your recolour file:

  Reveal hidden contents

// recolour template //
@PART[partName]:FOR[999_TU_NFLV_Recolour_000]:NEEDS[TexturesUnlimited&NearFutureLaunchVehicles]
{
    @MODULE[KSPTextureSwitch],0
    {
        textureSet = NFLV_Paint
    }
    %MODULE[SSTURecolorGUI]
    {
        %name = SSTURecolorGUI
    }
}
+KSP_TEXTURE_SET[NFLV_Paint]:NEEDS[TexturesUnlimited&NearFutureLaunchVehicles]
{
    @name = NFLV_Paint
    @MATERIAL
    {
        vector = _DiffuseNorm,0.75,0.75,0.75
        vector = _MetalNorm,0.55,0.55,0.55
        vector = _SmoothnessNorm,0.55,0.55,0.55
        
        texture = _MainTex,
        texture = _BumpMap,
        texture = _Emissive,
        texture = _MetallicGlossMap,
        texture = _MaskTex,
    }
}

Change partName, the NFLV bit of 999_TU_NFLV_Recolour_000, NearFutureLaunchVehicles (name of the mod being recoloured) and the textures _MainTex, _BumpMap and _Emissive to the same as whatever they were in the previous default file. Change textureSet and @name in the same way as last time but use a different unique name. Change NFLV_Paint to whatever you called the paint texture set in your texture sets file. Some parts use the transparency of _MainTex as a gloss map, if the main texture is partially transparent this is likely the case and it can be used as _MetallicGlossMap, if it isn't then you will have to make your own.

RIyqNcU.png

Now is the point where we actually get to do some recolouring. I will be using paint.net for this part.

Open the original texture and recolour it, it should be split into four areas, a purely red, purely green, and purely blue section that do not overlap, anti aliasing should be off so there are no semi-red semi-green ect pixels. Any part of the image that isn't being recoloured should be pitch black, these parts will retain their original textures on the final part.

If you need to make a _MetallicGlossMap it doesn't matter what colours you use, the glossiness is based on how transparent the texture is (more transparent = less glossy).

!! important!!  save the recolour as a .png, when you do this is needs to be flipped vertically compared to the original texture.

Once these textures are done save them somewhere in your recolour folder and set _MaskTex to the path to the recolour texture from GameData. eg: "texture = _MaskTex,TU_NearFutureSpacecraft/Textures/EnginePods/engine-pod-01_paintTU_NearFutureSpacecraft/Textures/EnginePods/engine-pod-01_paint" don't include the file extension (.dds). If you copy the path from the top bar of file explorer you'll have to change the \'s to /'s.

Back in the recolour file we now change the vectors, these are essentially the average value of a property in the red green and blue areas of the recolour texture. the only one to worry about for now is the _DIffuseNorm vector, this is the average brightness of each of the areas.

u0fipv7.png

0.75 is a pretty good value for stock white areas but you'll want to change it if the red, green or blue areas are particularly dark or bright. The exact value doesn't really matter, it its really far off the recoloured areas will appear to dark or bright compared to other parts.

There is a proper way to calculate these that can be found on the Textures Unlimited Wiki if you want.

Assuming you did everything right (and i wrote this tutorial correctly) when you launch the game the parts you want recoloured should now have that option.

 

Common issues (that i had):

- Parts appear solid grey / Recolours are solid red / Parts have weird shadows.

This is because the _MainTex / _MaskTex / _BumpMap did not work, check the file path specified in the default / recolour file is correct, that the textures are being applied to the correct part.

 - Parts are mirror-shiny.

_MetallicGlossMap is completely opaque, check it is the right format (BC3 sRGB DX 10+) / file path is correct (same as above).

 - Some bits of parts have the wrong texture applied to them.

This is either because that part is made of multiple meshes with different textures, i will explain how to solve this sometime in the future  or because the recolour texture has not been flipped.

Hey, what do I do if there are actually multiple meshes with multiple textures? For example Restock mk1-3pod has a hatch, and a flag. They all require their own texture since... they look ugly

Edit: I think I figured out, I looked at UncleMateo's config for drop tanks, and the solution seems to be copy +KSP_TEXTURE_SET times how much meshes are there, then to each one add mesh = I_NEED_THIS and excludeMesh = I_DONT_NEED_THIS, excludeMesh = flag, and obviously add texture for all of them, am I correct?

Edit Edit: yup it worked, just needed to plug in mesh and excludeMesh nearby textures and worked like a charm :D

Edited by MrShelter
Edit Edit
Link to comment
Share on other sites

I made a simple customizable TURD config maker based of @ZZetho's tutorial! https://github.com/likeproblem/TURD_ConfigMaker

I would be very happy if it helps you to create configs even if marginally faster :)

Uses latest python, and can be customized by editing all txt files

Just launch, input all variables(you can default them if you want so!) and select mode: init, add, and meshify(very specific mode explained in main.py)

Please tell me if it worked, what to improve etc!

Link to comment
Share on other sites

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...