Baking Materials for SecondLife

Baking Materials for SecondLife
Multi-Channel Image Tool
SecondLife is in the process of adding PBR/GLTF Support. This workflow will become out of date once that happens.
This tutorial assumes you already know how to create materials inside Blender using the Shader Editor and have done so already.

If you are a Blender user looking to bake materials for SecondLife correctly, follow this tutorial.

Understanding Channel Packing

Firstly, the most important thing to know is that SecondLife like most game engines uses a form of 'channel packing' to save bandwidth.

Images in SecondLife have up to four Channels, Red, Green, Blue and Alpha. Per pixel, there is a value between 0-255 on each of these channels, which combined gives the appearance of the texture.

So why am I speaking in these technical terms? Well, in SecondLife, the Alpha, which appears to be transparency to the naive user, is actually just being used as extra data for things like Glossiness, Environment Reflections, Emission and yes transparency depending on the texture and the Prim's Alpha Mode.

The Textures and the Channels

We have three textures, the 'Diffuse' Texture, 'Normal' Texture and 'Specular' Texture

Parameter Red Green Blue Alpha
Diffuse Map Red Green Blue selectable

see Alpha Mode

Normal Map Normal X Axis Normal Y Axis Normal Z Axis Specular exponent
Specular Map Red Green Blue Environment intensity

From SecondLife Wiki - Material Data

What to Bake

In Blender Cycles, there are lots of types of textures we can bake

All of the Bake Types inside Blender Cycles

Firstly, we need to get all of the image data out of Blender we're going to need, and then later we will combine them using a Channel Packing Technique.

Bake to images all of the following:-

  • Diffuse
    This will form the R,G,B Channels of the 'Diffuse' Texture Slot
  • Normal
    This will form the R,G,B Channels of the 'Normal' Texture Slot
  • Glossy
    This will form the R,G,B Channels of the 'Specular' Texture Slot
  • Roughness
    Forms the Alpha Channel of the Normal Texture, but we will have to invert it first (explained later)

If your material features emission (such as for example, a control panel with LED lights) bake Emission.

Did you know?
Even when Diffuse Alpha Mode is set to 'None' in SecondLife, the Alpha Channel in your Diffuse Map will act as a Glow multiplier!

If your material features transparency, we can't bake directly, so a small trick - plug Alpha into Emission in the shader editor temporarily and bake Emission.

Packing the data for SecondLife

To pack the data I recommend using a tool made for Channel Packing instead of an image editor as it is less likely to do anything 'clever' with your Alpha Channel. Image Editors such as Photoshop etc have a tendency to eat RGB data on fully transparent pixels.

For this reason we will use Multi-Channel Image Tool to pack our textures. It's Open Source and most importantly, free.

Multi-Channel Image Tool User Interface

Packing Normal Map

Pay attention, because the following is counter-intuitive.

We will open Multi-Channel Image Tool:

  1. On the Combine tab, for the R,G,B tabs we will select our Normal Map texture we baked, and select Channel to Extract to corresponding Channel.
  2. On the A tab, we will select the Roughness map and critically, we will check Invert and set Channel to Extract to R
  3. Finally, click 'Save As' to save our packed Image

Why Roughness on Alpha, Why Inverted and Why Extract Red instead of Alpha?

In SecondLife, the Alpha Channel value of Normal map is Multiplied per-pixel against the Gloss setting of your material. Roughness is the inverse of Glossiness, so we need to invert our Roughness to get a Glossiness map.

Our Roughness map is a Black and White Image, it has no Alpha value, so we don't extract the Alpha Channel. Red Green and Blue are all the same value on a gray scale value, so we just use Red, but it wouldn't matter if we chose Green or Blue.

Packing Diffuse

If your material does not use Emission or Transparency, there is no need to pack diffuse, however if you do, you can use the same method as outlined above to pack your Emission or Alpha into the Alpha Channel.

Packing Specular

The alpha channel on Specular in theory controls how much of the Environment is reflected on the object, but at time of writing currently only reflects a very basic environment map which doesn't look very pretty.

I recommend against packing your specular map until we get PBR and Environment Probes in the viewer (Hopefully coming later this year at time of writing)

However, you could bake a reflection map through emission and use that if you really wanted to. Not all PBR Materials come with Reflection maps. I haven't found a way to bake these properly yet as I don't think it's a good effect yet anyway.

All Done!

Now you know how to pack data together for SecondLife. Hope it helped!