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
IsReady
Only returns true once all relevant materials/shaders have been loaded by the MaterialUtils class and are safe to be used.
public static bool IsReady { get; }
Property Value
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 (case-insensitive) 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
gameObject
GameObject- The UnityEngine.GameObject to apply the shaders to (includes all children).
shininess
float- '_Shininess' value of the shader. Recommended range of 1.0f-8.0f.
specularIntensity
float- '_SpecularInt' value of the shader. Values around 1f are recommended.
glowStrength
float- '_GlowStrength' and '_GlowStrengthNight' value of the shader. Should not be absurdly high.
modifiers
MaterialModifier[]- 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
material
Material- The material to apply changes to.
shininess
float- '_Shininess' value of the shader. Recommended range of 1.0f-8.0f.
specularIntensity
float- '_SpecularInt' value of the shader. Values around 1f are recommended.
glowStrength
float- '_GlowStrength' and '_GlowStrengthNight' value of the shader. Should not be absurdly high.
materialType
MaterialUtils.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
material
Materialcutout
bool
SetMaterialTransparent(Material, bool)
Toggle the transparency on a material.
public static void SetMaterialTransparent(Material material, bool transparent)
Parameters
material
Materialtransparent
bool