Today I created a new system that can apply glowmasks and shaders to items based on their modifiers.

The above example is achieved by applying the following to a modifier:

public override ShaderEntity GetShaderEntity(Item item)
	return new ShaderEntity(item,
		drawLayer: ShaderDrawLayer.Front,
		drawOffsetStyle: ShaderDrawOffsetStyle.Alternate,
		shaderDrawColor: Color.IndianRed);

public override GlowmaskEntity GetGlowmaskEntity(Item item)
	return new GlowmaskEntity(item);

With this code, everything is automated. The system does not support custom shaders yet.

With the system, you can load in custom shader or glowmask assets.

All you have to do is specify to register your assets in Load():

if (!Main.dedServ)
	EMMLoader.RegisterAssets(this, "GraphicsAssets");

The above code will make it so that assets from the folder <YourMod>/GraphicAssets are added to the system. This path is relative to your mod, so if you enter MyFolder/SubFolder/DeeperFolder it will look in there. Currently only a single folder is supported, and you should put all assets in there.

Keynote: the assets will be removed from your mod’s internal texture array. You can disable this by passing: clearOwnTextures: false

All assets can be named by either the item name or its ID. The ID (or type) is recommended for vanilla items. Currently you can only add assets for your own mod or vanilla. Example asset names:

  • MyModItem_Glowmask.png –or– MyModItem_Glow.png
  • MyModItem_Shader.png –or– MyModItem_Shad.png

As shown, names can be suffixed with either the full variant or shorthand of the asset type. This suffix is important or else the asset will not be added.

The asset name internally will be converted to the item’s type so it can be matched:

Using the asset system, you can have shaders and glowmasks apply on specific portions of an item: