MATERIAL Files

MATERIAL MBIN's contain information about which texture maps as well as shader effects are used for a given mesh provided via a GEOMETRY file. Much like 'materials' in 3D modeling programs, there are a lot of options available for customizing the look and rendering of an in-game object.

It is highly recommended that you are already used to the workflow involving the import of custom models or is simply planning a re-texture mod. A basic MATERIAL file contains some basic attributes such as whether the object casts shadows.

## Initial Structure

**Name** - simply the name of this material.

**Class** - flags your texture onto whether it is Opaque (please expand)

**TransparencyLayerID** - likely has something to do with the Z drawing order of a transparent object. Always set to 0.

**CastShadow** - determines whether this object casts a shadow.

**DisableZTest** -

**Link** -

**Shader** - determines what shader to use. Shaders can be found in the /SHADER/ folder of your extracted PCBANKS directory. The most common shader is the UBERSHADER (SHADERS/UBSERSHADER.SHADER.BIN) which behaves similarly to Unity's Standard Shader.

**Flags** - declaring different material flags toggles on or off parts of the shader code. Listed below are options for the standard UBERSHADER.

**Uniforms** - uniforms are generic variables used by GLSL shaders. They are basically numerical properties that directly influence your material. There are several structs available, but only two are frequently used. See Material Properties below.

**Samplers** - sampler structs can be found here. Each struct references actual 2D textures from a given directory. There are three types of samplers.

* gDiffuseMap - the diffuse map is a DDS file where RGB channels are used for the diffuse texture and the ALPHA channel is used for metalness or transparency, depending on which flags you have declared in the MATERIAL file.
* gMaskMap - this DDS file is used for a wide variety of effects. ~~Roughness~~ glossiness is derived from the green channel. Ambient occlusion is derived from the red channel. (can someone write about the blue channel?) After some testing, the blue channel appears to be for determining where custom colors are applied while base building - White receives primary color, grey (I used #7b7b7b) receives secondary color, and black retains original texture color. More testing needed.
* gNormalMap - the normal map in DDS format. It might be important to know how NMS stores normal maps.

## Material Flags (UBERSHADER)

Most materials in the game, especially 3D objects, reference an Ubershader similiar to Unity's Standard Shader, which uses Physically Based Rendering. Declaring more flags will trigger more effects on the MATERIAL MBIN. Listed below are the various flags (specifically what is known at this time), how they function, an what maps or parameters they rely on.

**\_F01\_DIFFUSEMAP** - exactly does the same thing a diffuse map on any 3D application, a basic texture image your model uses.

**\_F03\_NORMALMAP** - with this flag declared, your model will use a supplied normal map if you have any.

**\_F07\_UNLIT** - this makes this material unlit or *shadeless*.

**\_F24\_AOMAP** - if your model has an ambient occlusion bake, it will be read from the RED CHANNEL of your mask map as opposed to being baked into your diffuse map. **Important note: As of Foundation 1.1, using this flag apparently causes the model to be entirely shaded black for some reason!**

**\_F25\_ROUGHNESS\_MASK** - this is the ~~roughness~~ glossiness property used for PBR rendering. It can be thought of as something like specularity map in older generations of games. ~~Roughness~~ glossiness masks rely on the GREEN CHANNEL of your provided mask map.

**\_F39\_METALLIC\_MASK** - this is the metalness property used for PBR rendering. Your metalness map comes from the ALPHA CHANNEL of your diffuse map.

**\_F09\_TRANSPARENT** - this will cause parts of your texture to be transparent. It will read from your diffuse map's ALPHA CHANNEL, effectively overriding the metalness map.

**\_F22\_TRANSPARENT\_SCALAR** - this will allow the declaration of a single value to determine the texture's transparency via the 'a' property in the material file's gMaterialColourVec4 struct.

**\_F11\_ALPHACUTOUT** - similar to any alpha cutout, where all pixels above a certain threshold or immediately transparent. Used for things like leaves or fences, where the actual object doesn't technically have a soft fade anywhere.

## Material Flags

The following is a full list of all the flags found in the shader source code as of v1.77.

No Man's Sky uses a modified version of the Horde3D engine which accepts custom material flags in the range of **\_F01\_** to **\_F64\_** *(NMS uses 64-bit flags while Horde3D uses 32-bit)*. The engine will detect any defines in the shader code that begins with the **\_Fxx\_** prefix. The suffix can be customized.

*From the documentation for the Horde3D render pipeline notes:*

> The code section can also contain the shader flags used for the automatic combination generation. The shader flags have a special naming convention: **\_F*<digit><digit>*\_*<name>***. The following would be a valid flag: \_F06\_MyFlag. The flag must have a number between 01 and 32 (note the leading zero). This number is exclusively used to identify the flag. The name is optional and just exists for convenience reasons in order to improve the code readability.
>
>

Most of these flags can be used with the Ubershader. Some are also or only used by other shaders.

Flags with the same value and different names are exclusive and cannot be combined. Others may not combine if they are functionally incompatible.

Some flags require additional material properties and/or samplers to be defined (not documented).

```
**\_F01\_DIFFUSEMAP**

```

```
**\_F02\_SKINNED**

```

```
**\_F03\_NORMALMAP**

```

```
**\_F04\_ENVMAP**

```

```
**\_F05\_INVERT\_ALPHA**

```

```
**\_F07\_UNLIT**

```

```
**\_F09\_TRANSPARENT**

```

```
**\_F10\_NORECEIVESHADOW**

```

```
**\_F11\_ALPHACUTOUT**

```

```
**\_F12\_BATCHED\_BILLBOARD**

```

```
**\_F13\_UVANIMATION**

```

```
**\_F14\_UVSCROLL**

```

```
**\_F15\_WIND**

```

```
**\_F16\_DETAILMAP | \_F16\_DIFFUSE2MAP**

```

```
**\_F17\_FADE | \_F17\_VERTEX\_ROTATION | \_F17\_MULTIPLYDIFFUSE2MAP**

```

```
**\_F18\_UVTILES**

```

```
**\_F19\_BILLBOARD**

```

```
**\_F20\_PARALLAXMAP**

```

```
**\_F21\_VERTEXCOLOUR**

```

```
**\_F22\_TRANSPARENT\_SCALAR**

```

```
**\_F24\_AOMAP**

```

```
**\_F25\_ROUGHNESS\_MASK**

```

```
**\_F26\_STRETCHY\_PARTICLE**

```

```
**\_F27\_VBTANGENT**

```

```
**\_F28\_VBSKINNED**

```

```
**\_F29\_VBCOLOUR**

```

```
**\_F30\_REFRACTION\_MAP**

```

```
**\_F31\_DISPLACEMENT**

```

```
**\_F33\_ALPHACUTOUT**

```

```
**\_F34\_GLOW**

```

```
**\_F35\_GLOW\_MASK**

```

```
**\_F36\_DOUBLESIDED**

```

```
**\_F37\_RECOLOUR**

```

```
**\_F38\_NO\_DEFORM**

```

```
**\_F39\_METALLIC\_MASK**

```

```
**\_F40\_SUBSURFACE\_MASK**

```

```
**\_F41\_DETAIL\_DIFFUSE**

```

```
**\_F42\_DETAIL\_NORMAL**

```

```
**\_F43\_NORMAL\_TILING**

```

```
**\_F44\_IMPOSTER**

```

```
**\_F45\_SCANABLE**

```

```
**\_F46\_BILLBOARD\_AT**

```

```
**\_F48\_WARPED\_DIFFUSE\_LIGHTING**

```

```
**\_F49\_DISABLE\_AMBIENT**

```

```
**\_F50\_DISABLE\_POSTPROCESS**

```

```
**\_F51\_DECAL\_DIFFUSE**

```

```
**\_F52\_DECAL\_NORMAL**

```

```
**\_F53\_COLOURISABLE**

```

```
**\_F54\_COLOURMASK**

```

```
**\_F55\_MULTITEXTURE**

```

```
**\_F56\_MATCH\_GROUND**

```

```
**\_F57\_DETAIL\_OVERLAY**

```

```
**\_F58\_USE\_CENTRAL\_NORMAL**

```

```
**\_F60\_ACUTE\_ANGLE\_FADE**

```

```
**\_F61\_CLAMP\_AMBIENT**

```

```
**\_F62\_DETAIL\_ALPHACUTOUT**

```

```
**\_F63\_DISSOLVE**

```

```
**\_F64\_**

```

### Unused Material Flags

The following flags are not referenced in any of the v1.77 shaders. Shader mods could utilize these for their own configurable modes and properties.

```
**\_F06\_, \_F08\_, \_F23\_, \_F32\_, \_F47\_**

```

## Material Properties

gMaterialColourVec4

* X, Y, Z - these variables likely determine that direct intensity of your diffuse map as per your RGB channels. A value of zero will probably cause your model to shade black.
* T - Transparency/Translucence. (0~1 range) The lower the value, the more transparent the object. (This may require the \_F22\_TRANSPARENT\_SCALAR shader called.)

gMaterialParamsVec4

* X - overall roughness coefficient of your material, if you did not provide a ROUGHNESS\_MASK flag.
	+ 1.0 makes the surface rougher (less shiny, like charcoal), 0.0 makes it smoother (much more shiny, like glass or a laminated object)
	+ If \_F25\_ROUGHNESS\_MASK is provided, this value will multiply the final result.
* Y - likely has something to do with the intensity of a detail normal map, still needs further confirmation. This seems to be left at 0.5 by default for most vanilla models.
* Z - overall metalness coefficent of your material, if you did not provide a METALLIC\_MASK flag.
	+ 1.0 makes the surface generally more metallic (reflections are precise) while values toward 0.0 make the surface less metallic (reflections become blurred and \*diffused\*)

* +
* T - not used