Resource:Using pallettes for recoloring in Fallout 4

Using pallettes for recoloring in Fallout 4 is a resource guide written by Ajhakra.

Info
Before starting, I, by no means, am an expert in this subject and I actively encourage those who are more experienced or have more knowledge to step in and contribute to the page.

In Fallout 4, Palette textures/files essentially act as colour Lookup Tables(LUTs). These allow us to have multiple texture variants, without the need to have a separate texture set for each variant, which allows us to save on file size and reduce drawcalls(?)

Understanding the Palette File
As mentioned before, palette files act as LUTs in Fallout 4. These allow us to select certain colours from the palette files, using a coordinate system, in order to colour our textures the way we want them.

From experience, these maps are limited to a horizontal size of 256 pixels. This is because each pixel will be mapped to a value on greyscale colour range, which ranges from 0-255(256 options total). Think of this as the X coordinate in a graph.

For the Y coordinate, this is specified using the "Grayscale To Palette Scale" value in your material file, or using the "Color Remapping Index" value in a plugin material swap.



Using the above image as an example, we'd calculate this value as per below:
 * Get the number of colour sets in our palette,
 * 10 in this example
 * Divide 1 by the number of colour sets,
 * 1/10=0.1
 * This value would indicate the range of values that we can use for each colour set,
 * E.g If we want to reference set 1, we'd set the "Grayscale to Palette Scale"/ “Colour Remapping Index” to a value between 0.0 and 0.1. To reference set 2, we'd use a value between 0.11 and 0.2. Set 3 0.21 to 0.3 etc

Using the Palette File
Now that we’ve got a brief understanding on how the palette file works, how do we functionally use it in-game?

First for the easy bit, enabling palette use. This can be done in 3 ways:


 * Using material files, enable the “Grayscale to Palette Colour” option:


 * Using plugin material swaps, enable the "Colour Remapping Index" option in your material swap:


 * Using OMOD propert modifier "fColorRemappingIndex":

Secondly for the slightly more difficult part, setting up our Diffuse texture correctly. For palettes to work correctly, your diffuse must purely use greyscale as these will be the colours getting mapped to our palette image. Colour can be present here, however, there are no guarantees that it will map correctly, and the colour in your diffuse will not be used in-game.

As mentioned above, we can use the greyscale value of a pixel in our diffuse map to map it to our palette file. Using a cutout of a diffuse texture file as an example in image 3, we’ll walk through it.



So as shown in the above image, we have 3 greyscale values that we are using for different parts of the diffuse. This is what we’ll be using to map each greyscale value to a colour in our palette file


 * Main Colour - 229
 * Colour Scratches - 255
 * Lettering - 30

This would map to the colours shown that the vertical cyan lines intersect with:




 * Lettering - would result in it being white, regardless of our  "Grayscale to Palette Scale"/ “Colour Remapping Index” value.
 * Main Colour - would result in the colour change that we are looking for. The exact colour chosen would be dependent on the "Grayscale to Palette Scale"/ “Colour Remapping Index” value.
 * Colour Scratches - would result in the scratches being black, regardless of our "Grayscale to Palette Scale"/ “Colour Remapping Index” value.

In-game Examples
Using all of the above information, we can now show off some in-game examples of this

For the first example, the below values are being used: Main Colour - 229 Greyscale Colour Scratches - 255 Greyscale Lettering - 30 Greyscale "Grayscale to Palette Scale"/ “Colour Remapping Index” - 0.35



As we can see, this rightly results in us getting a yellow gun, with “black” scratches and white lettering. Note that the scratches do not show as black due to our specular map being setup to make these scratches more specular/glossy

For the second exa,mple, the below values are being used: Main Colour - 229 Greyscale Colour Scratches - 255 Greyscale Lettering - 30 Greyscale "Grayscale to Palette Scale"/ “Colour Remapping Index” - 0.35



As we can see, this rightly results in us getting an off-white gun, with “black” scratches and white lettering. Note that the scratches do not show as black due to our specular map being setup to make these scratches more specular/glossy

And finally for the third example, the below values are being used: Main Colour - 229 Greyscale Colour Scratches - 255 Greyscale Lettering - 30 Greyscale "Grayscale to Palette Scale"/ “Colour Remapping Index” - 0.35



As we can see, this rightly results in us getting a black gun, with “black” scratches and white lettering. Note that the scratches do not show as black due to our specular map being setup to make these scratches more specular/glossy, whereas the main slide is setup to be less specular.

License
This tutorial is under Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0)

Credits

 * Ajhakra for transcribing and testing this.