Materials & Textures - LeeTwentyThree/ECCLibrary-Legacy GitHub Wiki
Materials & Textures
Initial remarks
This page exists to document the specifics of adding Textures and Materials onto your creatures.
The Standard Shaders in Unity do not work properly in Subnautica and must be converted to the MarmosetUBER Shader via code. Luckily, ECCLibrary helps make it very easy.
If you do not know what a Material is, you should gain some more experience in using Unity before creating a mod.
Material conversion
ECC automatically converts materials on Creature Assets. The method that contains the logic for this process is ECCHelpers.ApplySNShaders.
This method takes in a GameObject to apply the Shader conversions to, and also takes in a UBERMaterialProperties struct to control how the conversion is done. In CreatureAssets where this method is called internally, the UBERMaterialProperties parameter comes from the overrideable MaterialSettings property.
ApplySNShaders method specifics and limitations
The ApplySNShaders method edits ALL renders in a GameObject and its children, whether inactive or not. It even applies to ParticleSystems. It applies the same settings to all renderers. While this is generally a convenience, there may be times this gets in the way. More specific material settings should be applied in AddCustomBehaviour of your CreatureAsset.
For each material, the method begins by converting the Material to use the MarmosetUBER Shader. It then applies the Diffuse, Specular, Normal, and Emission maps, if any are applied to the material.
Next, the method checks if the material contains certain keywords in the name (these checks are not case-sensitive).
- If the material name contains "Cutout", a Cutout/Alpha clip will be applied to the material.
- If the material name contains "Transparent", transparency is applied to the material.
MarmosetUBER material properties and keywords
- Diffuse
_MainTex
: The main texture._Color
: The color that is applied to the main texture via multiplication.
- Specular
MARMO_SPECMAP
: Keyword that determines whether the specular should be applied or not. This should be always true unless you want an unlit-looking object._SpecTex
: The specular texture._SpecInt
: Specular intensity, by default 1._Shininess
: Shininess. 8 is a good value._Fresnel
: Range of 0-1. A fresnel effect that affects the specular intensity around the edges of objects.- A high fresnel mixed with a high specular intensity can create a ghost-like effect.
- Emission
MARMO_EMISSION
: Keyword that determines whether the emission should appear or not._Illum
: Emission texture._GlowStrength
: Glow strength during day_GlowStrengthNight
: Glow strength during night
- Normals
MARMO_NORMALMAP
: Keyword that determines whether the normal map should appear or not._BumpMap
: Normal map