Class MaterialUtils
Utilities related to Materials and Shaders.
public static class MaterialUtils
- Inheritance
-
MaterialUtils
- Inherited Members
Fields
kOpaqueRenderQueue
Render queue used by opaque objects.
public const int kOpaqueRenderQueue = 2000
Field Value
kTransparencyRenderQueue
Render queue used by transparent objects.
public const int kTransparencyRenderQueue = 3101
Field Value
Properties
AirWaterBarrierMaterial
Gets the Material used by Alien Bases for the transition between water and air.
public static Material AirWaterBarrierMaterial { get; }
Property Value
- Material
ForceFieldMaterial
Gets the Precursor Force Field Material.
public static Material ForceFieldMaterial { get; }
Property Value
- Material
GhostMaterial
Gets the material used by unfinished constructions.
public static Material GhostMaterial { get; }
Property Value
- Material
IonCubeMaterial
Gets the default Ion Cube Material.
public static Material IonCubeMaterial { get; }
Property Value
- Material
PrecursorGlassMaterial
Gets the Precursor Glass Material.
public static Material PrecursorGlassMaterial { get; }
Property Value
- Material
StasisFieldMaterial
Gets the Stasis Rifle's ball Material.
public static Material StasisFieldMaterial { get; }
Property Value
- Material
Methods
ApplySNShaders(GameObject, float, float, float, params MaterialModifier[])
Applies the necessary settings for Subnautica's standard shader (MarmosetUBER) to the passed UnityEngine.GameObject.
The specific changes to each material are influenced by certain keywords in their asset names:
"TRANSPARENT": Enables transparency.
"CUTOUT": Enables alpha clipping.
public static void ApplySNShaders(GameObject gameObject, float shininess = 4, float specularIntensity = 1, float glowStrength = 1, params MaterialModifier[] modifiers)
Parameters
gameObjectGameObject- The UnityEngine.GameObject to apply the shaders to (includes all children).
shininessfloat- '_Shininess' value of the shader. Recommended range of 1.0f-8.0f.
specularIntensityfloat- '_SpecularInt' value of the shader. Values around 1f are recommended.
glowStrengthfloat- '_GlowStrength' and '_GlowStrengthNight' value of the shader. Should not be absurdly high.
modifiersMaterialModifier[]- Optional array of classes that inherit from the MaterialModifier class. This allows for extensive customization of the method. Called in ascending order on every material.
ApplyUBERShader(Material, float, float, float, MaterialType)
Applies the MarmosetUBER Shader to the given material.
public static void ApplyUBERShader(Material material, float shininess, float specularIntensity, float glowStrength, MaterialUtils.MaterialType materialType)
Parameters
materialMaterial- The material to apply changes to.
shininessfloat- '_Shininess' value of the shader. Recommended range of 1.0f-8.0f.
specularIntensityfloat- '_SpecularInt' value of the shader. Values around 1f are recommended.
glowStrengthfloat- '_GlowStrength' and '_GlowStrengthNight' value of the shader. Should not be absurdly high.
materialTypeMaterialUtils.MaterialType- Controls various settings including alpha clipping and transparency.
SetMaterialCutout(Material, bool)
Toggle alpha clipping on a material. Incompatbile with transparency.
public static void SetMaterialCutout(Material material, bool cutout)
Parameters
materialMaterialcutoutbool
SetMaterialTransparent(Material, bool)
Toggle the transparency on a material.
public static void SetMaterialTransparent(Material material, bool transparent)
Parameters
materialMaterialtransparentbool