Skip to content

Colouring in Images

Sera edited this page May 13, 2017 · 5 revisions

A majority of rimworld textures are mainly black & white, so the game can colour the images itself. Thats how rimworld draws a table made of wood as brown, while a table made of jade is green.

for example, this baby deer

Multiply Layers & Alpha Masks

The game colours the texture picture by overlaying a fill layer (a solid block of one colour) on top of the picture. The layer is set to the blending mode multiply which works like this:

the vertical columns are a separate layer blended onto the horizontal rows

When a colour is multiply blended over black and white, it works similar to a colouring-in book, or ink on paper. Unfortunately when you multiply blend a colour over another colour, the effect isn't that clean. If you look at the red column, where it overlays over green is a similar effect to mixing paints until you get brown/black.

So what if you want to utilise multiply blending/being able fill objects different colours, but have some of the original textures colours preserved?

Well back to our deer example, this is what it looks like if we just colour it normally with multiply in rimworld;

multiply colour only

*versus* what it actually looks like in the game:

multiply colour + alpha mask

The white spots and the deer's stomach are not coloured in by our fill layer. Rimworld achieves this by having a second texture file for the deer called an alpha mask:

The mask is used as an alpha channel; it tells rimworld where to make the fill layer opaque/visible (the red areas) and were to make it transparent/invisible (the black areas).

XML

How does this work with XML? Well here is the the relevant XML for our deer:

<bodyGraphicData>
          <texPath>Things/Pawn/Animal/Deer/DeerBaby</texPath>
          <color>(140,74,41)</color>
          <shaderType>CutoutComplex</shaderType>
</bodyGraphicData>

The <color> tag defines what colour we want our deer to be with RGB values, while <shaderType> defines that we want to use an alpha mask. If we wanted to not use an alpha mask, just our fill colour, we would use <shaderType>CutoutSkin</shaderType> instead.

However this xml doesn't ask us for a texture path to our alpha mask. When it looks for the DeerBaby texture, rimworld is looking for DeerBaby_front.png,DeerBaby_side.png and DeerBaby_back.png. When we tell rimworld that the shader type is CutoutComplex it will also look for the alpha mask textures DeerBaby_frontm.png,DeerBaby_sidem.png and DeerBaby_backm.png at the same location.

Important things to remember

  • Your texture and alpha mask should be the same image size (e.g. 128x128px)
  • Your mask file needs to be in the same folder as its corresponding texture
  • The mask has to have an identical name to its original texture except for a m appended to the end (e.g. LABRATORY.png ➡️ LABRATORYm.png or Pig_side.png ➡️ Pig_sidem.png)
  • This only works for thingdefs or races
Written by Sera