Materials - MassiveMiniteam/OddModKit GitHub Wiki

Materials Quick Reference

Here’s an overview of useful Materials and functions. It’s not a complete list, but it’s what might be useful.

While we do have many base materials, admittedly a few of them end up pretty similar, as for example M_Base_Object had to absorb features of other materials for a variety of reasons. So in the end it’s not bad to just start out with M_Base_Object.

Materials

M_Base_Object

Our most base material, used for most objects in the world. It’s layered, and supports many of our basic functions like burn and freeze effects, ping coloring, plant swaying etc.

M_Base_Character, M_Base_Character_Layered

This material is intended for characters, but at this point this is very similar to M_Base_Object. The unique features it retains is builtin color customization, and the emissive texture to represent enemy aggro. It has rim light enabled by default as we want all characters to stick out from the environment.

M_Base_Terrain

Our base material for all terrain. Its features include noisy mesh distortion for a more irregular terrain, and to make ground type border materials

M_Base_Water, M_Base_Waterfall

Default water material and the equivalent material for waterfalls. Supports different coloring depending on depth and shoreline waves.

M_Liquid

A material with which you can control the amount of a liquid in a container, as well as simple movement of the liquid. the diffuse is however only a solid color.

M_Base_Ice, M_Base_IceLake

The ice materials are made with the focus on stellar ice, supporting a texture for stars and another for clouds in the depths. The IceLake further has the terrain feature of distorting the mesh, while M_Base_Ice has an option for depth visibility and for being used as particle

M_Base_Lava

Our lava uses the terrain noise distortion and a custom primitive data control (index 2) for lava heat (0 it has no emissive/no heat, 1 it has full emissive). Lava is made up of a moving surface layer emissive, and a deeper static emissive.

M_Base_Glass

The main difference to the object material is that there is a refraction setting, as well as the possibility to raise the transparency as the temperature of the glass is raised.

M_Base_Grass

All grass is based on this material. It can bend, it can sway. It has a subtle hue shift so it varies a bit in color. While it supports a diffuse, in our project we mainly use it for its alpha, and instead handle colors through color parameters.

M_Path_Decal_Layered, M_Path_Ghost_Decal

The paths are meant to be pretty simple decals, however we started using layered path materials as we wanted to add a paint layer to it. This is a decal with a builtin grassmask functionality (to be used on an additional plane mesh) and hostility coloring.

The ghost version is for the building mode in-game and is meant to hold the same textures as the non-ghost version. It has several color parameters to indicate different things in the build mode, which color being used is controlled by a float NoneBlockedFree. 0 Just a default color, 1 this location is blocked (not used on paths), 2 this is buildable here, 3 this is being relocated (not possible with paths)

M_Darkness, M_DarknessFlicker

The darkness materials are generally used to darken the interiors of workstations with a color and a visibility distance until it’s fully dark. The Flicker version additionally simulates a flickering light being somewhere in the darkness. You can pick a color, a local position point, and a light range. You can also control this light with a custom primitive data (index 19, 0 no light, 1 full light), to display workstation activity, like in the furnace and the recycler.

M_BuildingIcon, M_BuildingIcon_NoDepth, M_Decal_IconIndicator

these are simple materials meant for just displaying an icon. The NoDepth version will draw over everything, while the Decal is of course a decal.

M_Construction_Area

Material used to indicate the area where things are being deleted or copied. Needs to be used as a dynamic material, assigning the size of the area (in centimeters) to the Size parameter.

M_Construction_Grid, M_Construction_Grid_Decal

Used to display the grid. Custom Primitive Data is used to control some visual things. Index 1 will choose which color channel from the texture is used (0: red, 1: green, 2: blue). In 1 the texture will be tinted in “Input Color”, in 2 it will be in “Output Color”. CPD 0 defines the color tint (0: “None Color”, 1: “Blocked Color”, 2: “Free Color”) used if CPD 1 is equals 0.

M_Construction_MoveGhost

The MoveGhost material is used in buildmode to show where you’re building a building or where the building you’re relocating was at. You can control which color is used with the parameter “NoneBlockedFree” (0: None Color, 1: Blocked Color, 2: Free Color, 3: Relocate Color)

M_Environment_Fog_Additive

The main material we use to display fog.

M_GroundDecal

A decal used to indicate a different type of ground in a limited area. You have a world space tiling texture to represent the ground type, and UV space one that masks it.

M_IncubatorFoundation

This material uses a heightmap to simulate depth. It will blend a dirt texture in the top layer down to another texture at the bottom.

M_Impact_Decal

This decal can be used to show ground impacts. It can spread and contract based on the “Progress” parameter (0 not visible yet, 1 fully visible) or if set to be used as a Niagara decal, can be controlled through the DecalFade Particle parameter. You can have one color channel on your texture represent the cracks, which spread from the center of the decal. Another color channel can represent a scorch mark on the ground which will fade in smoothly instead.

M_PlacementRuleIndication

This material is used on a series of planes to indicate which tiles can be built on, or even to display hostility or temperature information for each tile. The green color channel on the texture represents the tile corners and is used in UV space. The red color channel is for a pattern which is used in world space. You can also add a sprite sheet to display things like numbers or other icons.

Material Layers

MF_Layer_Character_Base

A very basic layer that takes in all the textures needed to display anything.

MF_Layer_Object_Base

The Object layer has some extra options, like texture rotation, or controllable emissive (Custom primitive data index 4, -1: blinking emissive, 0: no emissive, 1: constant emissive)

MF_Layer_Path

Basically just a diffuse texture (with alpha) and a normal map.

MF_Layer_Character_ColorCustomization

The same as MF_Layer_Character_Base, but with the color customization feature

MF_Layer_Terrain_Texture

This is our main material layer used in terrain. All textures are world aligned, and it has a rimlight to make the cliff edges pop a bit. You can also enable the same noisy terrain distortion as the Material has, if needed.

MF_Layer_Object_Coloring

It literally just contains a color (with alpha), and a normal map (though in most cases you don’t need it). You can switch it to use a Custom Primitive Data vector (indices 20-23), which is required for it to receive the arty spark’s paint color.

MF_Layer_Object_Diggable

It’s a lot like the terrain Layer, though instead of a random world noise mesh distortion, it uses a heightmap to help give the texture dimensionality. It also will receive from code damage information to progressively show more and more of an alternate cracked/damaged version of the texture.

MF_Layer_Object_Flicker

Just an emissive color that is flickering. You can use Custom Primitive Data (index 4) to control how much it flickers. You can use a texture, though it’s not necessary.

MF_Layer_Object_Shine

This layer adds a shine passing over an object. We use this on all Aether items as well as in a more muted form on metal items. You can have it use world space to define its movement, or you can use UV coordinate channel 1 (it’ll use channel 0 if you don’t have channel 1) to have more control ovber how it moves over the object.

MF_Layer_Object_Glitter

Adds a glitter effect to your material. It has it both in the diffuse and emissive. Keep in mind that glitter works by having a noise texture in camera space and another on a mesh. When white spots from both textures overlap, you see the glitter.

MF_Layer_Object_Flag

This material layer will through world position offset make your mesh wave like a flag. UV coordinate channel 1’s Y axis is used to define how much each vertex waves. If a vertex is at the top, it won’t move, but if it’s at the bottom it will wave the maximum amount.

MF_Layer_Character_Rustle

This world position offset layer adds some randomized movement to your mesh, like it’s rustling in the wind. Ideally you use a texture mask or vertex colors to control which parts of the mesh move.

MF_Layer_Object_Float

This world position offset layer makes an object float according to the set parameters. You can create an offset for individual parts of your mesh by using the red vertex color channel. You can use Custom Primitive Data (Index 4) to control if it should be floating or not (0: no float, 1: full floating)

MF_Layer_Object_Rotate

This world position offset layer makes the mesh rotate, with the option to add a wobble to the rotation to make it less perfect. You can use Custom Primitive Data (Index 4) to control if it should be rotating or not (0: no rotation, 1: full rotation)

MF_Layer_Object_Wobble

This world position offset layer just makes the mesh wobble. Useful for anything that is meant to be more liquid or wobbly. For instance for a very simple lava lamp-like effect.

MF_Layer_Object_Liquid

Same as the Liquid base material, bus usable as a layer and it can also represent rotating liquid as in the paint bucket workstation.

MF_Layer_Object_Snow

The snow layer is similar to the terrain layer, though instead of the noise mesh distortion it has the functionality of vertices being pushed down when a character walks through. It also has glitter builtin.

MF_Layer_Corruption

With this layer you can use corruption in your material. If you use MFI_Layer_Corruption, it comes preset with our final settings. You can switch between UV coordinates and world aligned coordinates depending on your needs.

MF_Layer_SpaceIce

With this layer you can use the space ice in your material.

Blend Assets

MF_Blend_Alpha

Blends the layer through interpolation according to the blend asset’s settings.

MF_Blend_AddWorldPositionOffset

Adds the world position offset from the layer to the material. Good for layers that add floating, or wobbling

MF_Blend_AddEmissive

Adds the Emissive of the layer onto the material instead of interpolating like in MF_Blend_Alpha

MF_Blend_Coloring

Used specifically with the coloring layer. Applies the paint color from the coloring layer according to a mask to the material.

MF_Blend_Logic

Adds World Position Offset into the material and then blend the rest of the material according to the layer’s opacity.

Material Functions

MF_BurnState

This function takes care of everything necessary to display a material as having high heat. There’s several options to customize it as needed for the particular object you’re using it for.

MF_FreezeState

This function takes care of everything necessary to display a material as having high cold. There’s several options to customize it as needed for the particular object you’re using it for.

MF_Flicker

Makes a color flicker.

MF_Floating

can be used to create a bobbing floating effect, when used on the world position offset pin in a material.

MF_FoliageSway

Connected to the world position offset pin will make the mesh sway in the wind.

MF_GrassMask_Create

will distribute info needed for the grass mask (used to indicate to a plant that it should bend, or that snow should be dug) to the correct color channels and material output pins

MF_GrassMask_Apply

Will transform the grassmask the available grassmask info into usable data for the material to distort a mesh for e.g. bending.

MF_Lava

Does everything that is needed to render lava.

MF_MaterialBase

Used in most materials to unify some functionality, like having tints, or even on option for tinting the diffuse a different color during the autumn event

MF_PingColoring

Colors the diffuse into the color provided by the ping feature.

MF_RimLight

Adds a rim light to the emissive based on the diffuse color

MF_SetColors

will evaluate a given color mask and assign colors according to it.

MF_SpaceIce

Does everything that is needed to render ice.

MF_Wobble

Connected to the world position offset pin will make the mesh wobble.

Custom Primitive Data

With Custom Primitive Data we don’t have to handle Dynamic Materials, allowing us to have less unique materials and thus less draw calls (more draw calls = bad performance).

However there’s a limited amount of CPDs and thus we need to be smart about our usage. To avoid overlaps which could lead to features interfering with each other, here’s a list of how we’re using it. Overlaps happen due to mixing functionalities that weren’t meant to be mixed originally, as well as a mesh using more than one material.

It’s not consistent across everything, but is the more common usages

Index Name Description
0 Random Number 1 for visual randomization
1 Random Number 2 for visual randomization
2 FreezingBurning negative values represent cold with -1 as maximum cold. positive values represent burning with 1 as maximum burning.
3 Disabled used to display a workstation greyed out. 1 greys out, 0 displays like normal.
4 Emissive State for showing if workstation is active. if emissive is off 0, blinking -1, or on 1
5 Aggroness (characters), Active (Teleporters) for showing if a creature is in an aggressive state towards a target. 1 means the creature is fully aggro. For teleporters it indicates if it’s active
6    
7 Corruption  
8 Progress used with e.g. candles and bomb spark to change length of candle/wick
9    
10 Ping Color R  
11 Ping Color G  
12 Ping Color B  
13 Ping Color A  
14    
15    
16    
17    
18 Coal Activity shows if fuel is present
19 Fullness (for liquids), work (for using fuel/producing) essentially if a workstation is working. Might represent production progress 0-1, or always be 1 while producing
20 Custom Color 1 R for applying custom colors, used for paint
21 Custom Color 1 G for applying custom colors, used for paint
22 Custom Color 1 B for applying custom colors, used for paint
23 Custom Color 1 A for applying custom colors, used for paint
24 Custom Color 2 R for applying custom colors
25 Custom Color 2 G for applying custom colors
26 Custom Color 2 B for applying custom colors
27 Custom Color 2 A for applying custom colors
28 Custom Color 3 R for applying custom colors
29 Custom Color 3 G for applying custom colors
30 Custom Color 3 B for applying custom colors
31 Custom Color 3 A for applying custom colors

Player Customization

Since the materials on the Player Character are all Dynamic Materials, you can write directly to the available material parameters.

For the color customization we transmit colors to the parameters Color 1 to Color 6. In the 1.0 release which colors are assigned is different for each mesh, this changes in a later release to have a more consistent access to color.

Color Masks

We use color masks to distribute the customized colors to the right spots on each mesh

The color mask is a texture set up with the Compression Setting “Masks (no sRGB)”. The exact mapping depends on if the material has “more colors” enabled.

Color # Mask color
Color 1 Red channel 0-255, if more colors enabled 128-255
Color 2 Green channel 0-255, if more colors enabled 128-255
Color 3 Blue channel 0-255, if more colors enabled 128-255
Color 4 Only if more colors enabled, Red channel 0-127
Color 5 Only if more colors enabled, Green channel 0-127
Color 6 Only if more colors enabled, Blue channel 0-127

Make sure color gradients are intentional. Soft borders on a poncho pattern due to a brush with hard edges may cause some color artifacts.

Poncho Pattern

All Poncho meshes have to have the same UV layout unless you give the Poncho a material that doesn't use the pattern system (for example the tree)

Every Poncho Pattern is made up of a color mask listed in DT_CharacterCustomization_PonchoPatterns. By default it only uses Color 1 to Color 3, even if it should receive all of them.

A Poncho Pattern can also be its own material. this is useful if you don’t want the normal poncho pattern system and instead want to achieve something specific (for instance the pride flags)

Color Distribution per body part

Color # Hair Body Poncho Head Accessory Face Accessory Staff Pants Shoes Brooch
Color 1 Hair Color Skin Color Primary Color Skin Color Skin Color Brooch Color
Color 2 Primary Color Primary Color Primary Color Hair Color Primary Color Primary Color Primary Color
Color 3 Secondary Color Secondary Color Secondary Color Secondary Color Primary Color Tertiary Color Secondary Color Brooch Color
Color 4   Brooch Color Brooch Color Brooch Color
Color 5  
Color 6   Eye Color

Plant bending & snow pathing

RVT

For all functionality related to characters affecting their surroundings we rely on Runtime Virtual Textures. The ones we have available are these.

RVT Name Description
VT_Environment_GrassMask Used to bend grass, plants, and to make paths in the snow
VT_Environment_CharacterHeight Also used for plants to know the height of a character, which for example helps trees bend back to the normal position naturally above characters
VT_Environment_CorruptionMask Used to bend fully corrupted buildings. Only used on corruption enemies.

Grassmask

The grassmask is a misnomer, this whole system just happened to start with grass.

A plane with a material derived from M_GrassMask will write into the relevant RVTs.

Name Description
BaseColor.R Mask. If the plant is supposed to be masked away
BaseColor.G Flatten. If the plant should be pressed down
BaseColor.B Depth. How deep can this dig
Normal Bending direction
Height (in the CharacterHeight RVT) Character Height

Create

Generally it’s enough to just use a material derived from M_GrassMask on a plane, but if you want to make your own, this is how you could set yours up. You could use MF_GrassMask_Create.

MF_GrassMask_Create

you can use a texture to create the shape of the grass mask, or use a radial or rectangular shape provided by the material function. You can define if the mask is meant to bend plants, mask them away, and/or flatten them. You can set the character/building/etc.’s height, as well as the depth they can burrow through snow (in percentage 0-1)

The Opacity created by the material function is just the shape of the grass mask.

On the plane Make sure to add the correct RVTs (Grassmask and CharacterHeight for example) to the “Draw in Virtual Textures” array. Make sure to also set “Never” on Draw in Main Pass, so you don’t see it in-game. You should also add the Component Tags “ExludeFromMaterialAdjustDefault”, “Grassmask”, “grassmask”, “NoOutline” (there were a few typos involved :D)

Apply

With MF_GrassMask_Apply you can easily use the data from the grassmask, for instance here is an example of how it can be used.

MF_GrassMask_Apply

In this example it’s a plant that can be bent sideways, but also receives from the vertex color blue channel how dense the plant is, to receive some resistance to being bent. You just add the result of this to the world position offset of your material and it’ll work. Don’t forget that world position offset is a vector3, which is why we need to append a 0 for the Z axis in the example.

Snow

Snow is simpler and isn’t widely used, so there’s no material function for it.

snow material

We access the grassmask RVT, and take the blue channel from the base color. We have a special curve C_SnowCurve in CA_EnvironmentCurves which controls how the snow reacts color and shape-wise closer to the (for instance) character. With Absolute Depth you can control if the snow goes all the way down, or only up to a certain height.

Foliage sway

The swaying trees and plants are handled by MF_FoliageSway. It relies on a couple of things, like the biome’s wind speed and direction.

Our default implementation looks like this. We just add into the world position offset.

MF_FoliageSway

Branch Height Stiffness reduces rustling of plant parts further from the center the lower it is on the plant. Avoids too much rustling on what would otherwise be pretty stiff branches.

Branch Stiffness also reduces rustling, but across the entire plant. Here we have it controlled by vertex color channel green. The more green, the less stiff that part is. (a trunk would have no green at all)

The higher the rotation stiffness, the less the plant rotates with the wind.

Trunk Stiffness controls how much the tree can sway. This has to be applied equally across most of the plant, so that branches sway along with the trunk. This is controlled by the red channel of the vertex color. The more red, the less stiff.

⚠️ **GitHub.com Fallback** ⚠️