We all seen it, we have an old project using old textures where is implemented specular color. But what if we want to upgrade our project into more modern PBR (Physically Based Rendering) model? For example, I have an old model that was meant to be in my UDK project, it used textures like any normal model, Diffuse, Specular Color, Glossiness, Emisive, Normal Map, and masks. Now I wanted to remade my work into Unreal Engine 4. Most of the textures works fine, but the only problem is reflections.
In sake of this post, I will use Grex model from Xenoblade X.
3ds Max render: (notice yellow warp on its head shied, this is specular color)
First thing is, UE4 does not support specular color scheme and glossiness. Glossiness can be solved by inverting it and it’s acting like Roughness, whinch is fine. But Specular Color is different piece of cake, I can determine metal pieces, but when I plug them in Metalic node, albedo get much darker, whinch I don’t like. Most possible would be just recreate whole texture set, but what if I have more models using traditional scheme? It would be extremely time consuming to recreate every texture set for every model, especially when you have 100+ of them. So I had to look somewhere else.
Unreal Engine 4 fast scratched Metallic workaround:
Result on model: (No specular color)
UE 4 have this little material function called ConvertFromDiffSpec, where you just plug in diffuse and specular color and it will convert it to PBR scheme with Diffuse, Specular and Metallic on runtime. But there is main big problem. Calling this function is extremly expensive and it will eat 10 more pixel instructions, whinch is pretty much big deal, its performace eating good for nothing, I could use those 10 instructions somewhere else, right?
And yellow warp is back on its place:
So I started to look somewhere else for solution. Those textures can be baked directly outside, so we can take back those 10 instructions and save process right?
Since I don’t own Photoshop and I’m used to GIMP interface and scripting, I saw no problem to recreate function as script.
You can run it from Easy Stuff/Spec Color to PBR
You will need 2 layers, one for diffuse and one for specular color
Both layers must have same dimensions.
Both layers mush have removed alpha channel.
Specular layer mush have _s. or _spec. or _spm. in its name, otherwise script will not find it and exit itself.
Once you’ll start script, you will be left with Roughness, Metalness and one more layer, that is Diffuse. You can compose Metalness and Rougness into one image.
Here is sample result:
And here is how it looks in game.
Material: (You can use Roughness texture as Specular too, you just need invert it)
And on model:
As you can see, they are almost same, whinch is what I wanted to achieve. So not only we have improved pixel instructions, but we also have one more free channel (blue in this case) in our texture, we can use it for Emissive Color for example.
Copy es_speculardiff_to_pbr.py into %Gimp install folder%\lib\gimp\2.0\plug-ins\, thats all.
Current Version: BETA 4
- Script will not execute if one of layers have applied alpha channel, preventing fatal damage to both images and their alpha channels.
- Tweaked script for better results
- Added Specular layer in case user wants to use it.