Creating A Material Instance - Stellar-Blade-Modding-Team/Stellar-Blade-Modding-Guide GitHub Wiki

Overview

[!IMPORTANT] This section was written by our member Wtails. In this document we will be introducing how to manually create MIs(Material Instance) in Unreal Editor for Stellar Blade.

Appreciate Modder Wtails for providing source document and tips.

Alternatively you can also import Material data with help of Json2DA script in UE. Follow this page for more details.

Material and Material Instance

Before we begin, we need to establish what a Material and a Material Instance is.

Material

A “Material” (Sometimes called the Master Material, but that isn’t a term used by Epic/documentation so we’ll from here on refer to it as Material) is the foundation upon which all the parameters, settings, etc, are made that give a char or object in a game that distinct look/style.

This is what shows when you open a material, Ignore the spaghetti setup as this will be explained later.

[!TIP] Right click on image> open image in new tab to zoom in.

Capture2

You can compare it in a way to Blender’s Shader Editor, where you have all these nodes that make up the look and setup of the material.

Capture2

Material Instance

A “Material Instance” or MI for short, is a copy or “instance” of the Material, that allows you to play and mess around with the settings of the material in real time without worrying about needing shaders to compile every time you make a edit to check how your mat looks with changes made in real time. The Material Instance Inherits the values of the Material so whatever the Material has param/settings wise the Material Instance will have, it will also update in real time as well to include any edits made to the Material after if you already have an instance made.

Image below of how a MI looks when opened, looks generic here but this is cause this isn’t a proper setup since this is for mod purposes not to look pretty.

Capture2

[!NOTE] These are NOT “Custom Materials” which are materials made inside Unreal Engine itself that are modded into the game, but don’t exist in the game at all to begin with normally. (eg you make a toon/cel shaded material to use in a game whose style is realistic, when in reality such a material doesn’t exist in the vanilla game). In Stellar Blade’s Case, Custom Materials are “supported” (albeit under very specific/rare circumstances we will not go into here).

Now that that’s out of the way.

You can only replicate and reuse data that exists in the game already material/material instance wise. (It’s easier to replicate a Material Instance since it already inherits data from a Material where as a Material you need to recreate every single setting which while is more work and offers you flexibility in some cases, a Material Instance will do just fine for the most part)

You replicate a Material Instance (or Material if you want) for the following reasons:

  1. You need more materials to work with beyond the vanilla ones the mesh your working with has.

  2. You want to use another effect from another model like a hologram effect as an example, over a mesh that doesn’t have such a material called by default.

Workflow in UE

Before we get into the setup process we’ll go over the three main “Nodes” you need to set up in Unreal Engine for the most part.

TextureSampleParameter2D

Capture2

This is basically your Texture/Image input, your diffuse, normal map, etc. The node uses a default engine texture, so you don’t need to input anything here, as you’ll adjust it later to use your textures instead in your instance of this.

ScalarParameter

Capture2

This is the ScalarParameter, You can think of it as increasing/decreasing the strength of a variable like roughness or metal strength/influence. You can go into negatives or positives value wise.

VectorParam

Capture2

This is the same as scalarparameter, only with RGBA or color values, you can use this for coloring things say that use a mask/ID Map, or to affect only certain channels of a texture etc.

Capture2

Each Node has a “Parameter Name”, this is a Name you can assign to keep track of what your node does like Roughness Strength or Rimlight Strength etc.

Step 1: Inspecting Material Instance

In FModel, locate the Material (or Instance) you want to recreate in Unreal Engine.

In this example we’ll use MI_CH_P_EVE_09_Suit from SB/Content/Art/Character/PC/CH_P_EVE_09/Materials/ as a example. “MI” Stands for Material Instance.

Capture2

You can see the MI points to MA_CH_P_EVE_09, this is the “Material” it inherits its params and values from.

If we scroll down to the near bottom of the list. We’ll see a section called Texture Parameter Values

Capture2

This is where you’ll see the labels for the parameter names of your texturesamplerparameter2D you need to fill in for each texture like emission, normal map, etc, in this example.

We’ll use the basic color/diffuse map.

Capture2

Here we see the diffuse is labeled in its parameterinfo as Basecolor.

Step 2: Creating Nodes in UE

Now we go to our texturesampleparameter2d node and change the parameter name under General settings of the node, to make sure your adjusting/modifying the right node, make sure it's surrounded by a yellow orange like border when you click on it like in the example screenshot below. This also shows me making the param name for the diffuse/base color (here it’s capitalized the C but it doesn’t really matter as long as the name matches the vanilla name)

Capture2

For nodes with values like scalar, vector param, it’s the same thing.

Capture2

Find the ParameterInfo where you’ll find the name underneath it,
enter that into your scalar param/vector param.

(see below for example)

Capture2

Now your have done on setting up the param names of the scalar, vector, and texturesample2dparameter nodes.

Last thing to talk about when it comes to setting up parameter nodes like scalar/vector.

The output node at the end of the material editor for the visual/final result has a limited number of nodes. To be able to slot all the scalar and vector nodes,

Capture2

You need to use multiple Add or multiply nodes to combine them all continually in order to connect them to the end node.

Capture2

This can also be done for the TextureSampleParameter2D nodes as well if you like.

Step 3: Setting up Material Instance

Now onto the final setup.

With your “material” setup now. Right click on it and choose Create Material Instance.

Capture2

You should end up with a copy of the Material with _Inst appended at the end.

Capture2

Opening it should give you this window.

Capture2

This has all the values of the Material we made earlier. Click the boxes to checkmark them meaning they will be modified with the values we input for the scalar/vector parameters over what the material has set by default. Doing this for the textures means your textures will be called instead of the vanilla textures if you check the box and set the texture reference to your textures for your mod.

Once you make sure the instance has the values and tex you desire.

Open your skeletal mesh (your model), and assign the instance to your mesh.

Capture2

(example image using my own mod as a ref, it’s yellow due to my setup of the material so just ignore that as it’ll be different depending on your own setup, it’ll work fine in game)

Capture2

Once you assign the instance to your mesh, Create your PrimaryAssetLabel as data asset.

Add the textures, mesh, and the material instances you made to it.

Capture2

[!WARNING] Do NOT include the material itself as it’ll replace the vanilla material we are “borrowing” data from and cause your mesh to be checkerboarded.

[!NOTE] If your mesh or part of your model is skin based, Don't use a material meant for clothing for skin, they differ drastically setup wise, clothes uses ORM while skin uses ORSS which is completely different texture wise.

Once you make sure the instance is in your data asset alongside your mesh and textures, You can Package and test the mod and your custom instance of a existing vanilla material should work! If it doesn’t, make sure your names for the parameter names are exact to those of the vanilla ones in fmodel, and the material is in the right location in UE.