Difference between revisions of "NMS:Reference Guides/MATERIAL Files"

From STEP Modding Wiki
m (Material Flags (UBERSHADER))
m
 
Line 1: Line 1:
 
__NOTITLE__
 
__NOTITLE__
{{NMSPage|contentTitle=Reference Guides // MATERIAL MBIN Files}}
+
{{NMSPage|contentTitle=Game Structure // MATERIAL MBIN Files}}
 
{{TOC_right}}
 
{{TOC_right}}
 
== MATERIAL Files ==
 
== MATERIAL Files ==

Latest revision as of 09:35, August 10, 2020

BannerLogo
Game Structure // MATERIAL MBIN Files

Contents

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.

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
Unknown
Link
Unknown
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.
Info-Logo.png      Notice: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 glossiness property used for PBR rendering. It can be thought of as something like specularity map in older generations of games. 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