Custom Paint Mods

From Automation Game Wiki

Beginning with LCv4.2, Automation supports the creation of custom paint materials which can be applied to cars, fixtures, and engine parts. These materials also support the Exporter, including exporting to BeamNG.

Overview

A Custom Paint mod is a collection of files, of which a Custom Paint file is the parent.

The Custom Paint file contains the settings and applicable options for the Custom Paint, as well as a reference to the paint material.

The custom paint material itself is a Material in UE4, which is set up in a specific way. Material variables can have an editable_ prefix in the name if you want the player to have access to it in the custom paint settings in-game. Variables and parameters also need to be input into the export user data, contained within the material, for them to export correctly. Materials will not export correctly at all without this export user data.

Workflow

  1. In UE4:
    1. Set up a mod.
    2. Create and fill out a Custom Paint file.
    3. Create your Custom Paint material.
    4. Assign variables to the export user data.
  2. In the Automation Workshop Publishing Tool:
    1. Set up a workshop item.
    2. Share your mod.

Create your Custom Paint mod

Create A New Mod

After setting up the modding SDK from Here, create a new blank mod:

Create A Custom Paint File

In your mod content folder, right-click and add a new Custom Paint file. This is the file the game uses to load the paint into the UI.

CreateCustomPaintFile1.jpg

Open the Custom Paint file. It has a few parameters:

  • Name - This will be the name of the paint as it will appear in-game.
  • Material Instance - This is the actual paint itself. The material instance defines how the paint looks, what parameters are available, and how it looks when exported.
  • GUID - This is an unique identifier for this custom paint. It is a random value. This is how the paint is stored and saved by the game.
  • Family GUID - As above, this is an unique identifier. This one is currently un-used, but could in the future be used for storing what paints are part of the same family, if you decide to make several.

Create A Material

Right-click the content browser again, and create a new Material. This is the actual shader: it defines how the paint looks.

CreateCustomPaintMaterial.jpg

Open the material. UE4 uses standard PBR Metallic-Roughness workflows. What this means is you define a material by giving it:

  • a colour (0,0,0 - 1,1,1)
  • telling it how rough it is (0 - 1, 0 being shiny)
  • how metallic it is (0 - 1, 0 being plastic)

as well as a few additional things that help optimise parts of the rendering process, such as:

  • a Normal map (this defines surface detail that would be too fine or complicated to be geometry)
  • an Ambient Occlusion map (this helps darken and reduce reflections and specular highlighting on parts of the geometry that should be darker than usual, and which the lighting model cannot properly calculate)
  • Opacity/Opacity Mask
  • etc..

Material Requirements

Opacity

All Custom Paint materials must be set to Masked, unless it is a transparent material.

Two nodes should be a part of the Opacity or Opacity Mask input. If your material does not have any transparent or masked info, these two nodes are still required.

SetMaterialToMasked.png

If your material does have opacity information, simply add these two nodes at the end with a multiply:

SetMaterialToMasked1.png

Two-Sided Material

If at all possible, your material should be set to two-sided. This ensures the interior of the car doesn't have any transparency holes in it from fixtures or paints. To enable Two-Sided, click on the main material node in the material editor, and in the details panel, under the Material category, Tick Two Sided.

CustomPaintSetTwoSided.jpg

Parameter Names

For parameters to appear in-game in the UI for the player to customize, it must have the editable_ prefix. Only Vector and Scalar parameters will appear in the UI. Vector parameters will always appear as a Colour Picker, and Scalar parameters will mostly always appear as a Slider. If a Scalar parameter also has the _Bool suffix, it will instead appear as an Enable/Disable switch. A Vector parameter cannot have the _Bool suffix.

Example parameters:

CustomPaintParameterNameExamples.jpg

CustomPaintParameterNameExamplesInGame.jpg

Note how in-game the Burn Colour parameter isn't visible, and the Burned parameter is an Enable/Disable toggle. This is because the Burn Colour parameter did not have the editable_ prefix, and the Burned parameter had the _Bool suffix. Also note how the Scalar parameter appears as a slider, and the Vector parameter appears as a colour picker.

Export Material User Data

Export Material User Data main page

From the details panel of the material, expand the Material category, and from the Asset User Data array, add an Export Material User Data. This is where the values and parameters for the material are stored for the exporter. The exporter can only see the parameter names in the export user data. The exporter cannot know the layout of the parameters in the material, and cannot, therefore, know how to use those parameters. The export user data exists to simplify the parameters down to a known layout, such that the exporter can then line those values up with what the BeamNG material system uses, as well as other potential exporter plugins.

Note that the export user data only has access to a limited subset of behaviors for materials, and cannot do a lot of the fancy things that the UE4 material editor is capable of. It should, however, still be sufficient for most basic and intermediate-level materials.

Once you have fed your parameters into the export user data, your material should now export correctly.

Helper Functions For Materials

Inside materials and from the palette menu, or the right-click menu, you can access custom material functions that have been made and exposed to the material system. These nodes are designed to help you with designing your materials. Camso has designed a few material functions that help with designing custom paint materials. These materials can be accessed from the Camso or Custom Paint sub-categories within the palette or right-click menu inside materials.

The following nodes and material functions will help you to make materials easier:

  • GetStampAlpha
    MatFunction GetStampAlpha.jpg
    • This is one of the most important nodes, as it deals with all the functions, variables, and textures, that are used by the game to put the stamp holes on cars and fixtures. Without this node, fixture stamping does not work. Your material must be set to masked, and this node must be plugged into the opacity mask section.
    • It has one input, and you should not do anything with it.
  • MF_AASmoothStep
    MatFunction AASmoothStep.jpg
    • This is useful for turning a range of values into a 0 or a 1, or turning a range of values into a step where black suddenly turns to white.
    • It has three inputs;
      • In - this is the value you want to turn into a 1 or a 0
      • CompValue - If the In value is above this, the out value will be 1. if In is less than this value, the output will be 0.
      • Range - This is how large of a transition period the value should change in, in screen-space pixels. A small value will change over the course of a single pixel or less, and a large value will change over many pixels.
  • MF_BlendAngleCorrectedNormals
    MatFunction BlendAngleCorrectedNormals.jpg
    • This blends multiple normal maps together, with correctly normalized results. Other methods of blending normal maps do not correctly account for the blue vector, or do not accurately derive the blue vector. This method is more compute-intensive, but results in perfectly-blended normals.
    • It has four inputs;
      • In - this is the base normal, which you want to blend another normal with
      • Blend - this is the second normal that you want to add to the first
      • Strength - This is how much of the Blend normal you want to add to the base normal
      • Clamp - this ensures that none of the normal
  • MF_BlendFade
    MatFunction BlendFade.jpg
    • This is a mandatory node as part of the material for custom paints or fixture materials. Multiply it with any other part of your opacity mask network, or if you dont have any, plug it right in.
    • it has one input;
      • Opacity - This lets you pass in any other opacity value, and it will be blended with this node. this is mostly used to plug in the GetStampAlpha material function.
  • MF_CarpaintBackfaceBlend
    MatFunction CarpaintBackfaceBlend.jpg
    • This node will take two material attributes, and let one pass through for the front faces, and the other through for the backfaces.
    • It has three inputs;
      • Backface- This takes a Material Attributes in, and will pass it through to the output only if the current pixel is of the backface of a polygon.
      • Front face- This takes a Material Attributes in, and will pass it through to the output only if the current pixel is of the front face of a polygon.
      • Alpha - This is an optional input, and will override the default mask used to detect whether a face is the front or back of a polygon.
  • MF_DynamicGrungeAndWear_Mask
  • MF_FakeDarkenedMattePaint
  • MF_HeightLerp
  • MF_MipOverride_Mask
  • MF_StepScaleable
  • MF_WorldAlignedUVs
  • MF_CustomPaint_Lerp_Scalar
  • MF_CustomPaint_Lerp_Vec2
  • MF_CustomPaint_Lerp_Vec3
  • MF_CustomPaint_Lerp_Vec4
  • MF_CustomPaint_Mixer
  • MF_CustomPaint_TexList_002
  • MF_CustomPaint_TexList_003
  • MF_CustomPaint_TexList_004
  • MF_CustomPaint_TexList_005
  • MF_CustomPaint_TexList_006
  • MF_CustomPaint_TexList_007
  • MF_CustomPaint_TexList_008
  • MF_CustomPaint_TexList_009
  • MF_CustomPaint_TexList_010
  • MF_CustomPaint_TexList_011
  • MF_CustomPaint_TexList_012
  • MF_CustomPaint_TexList_013
  • MF_CustomPaint_TexList_014
  • MF_CustomPaint_TexList_015
  • MF_CustomPaint_TexList_NthDegree
  • MF_CustomPaint_Texture
  • MF_CustomPaint_TextureMaskChannel
  • MF_CustomPaintScale
  • MF_ExportParameterSwitch_Scalar
  • MF_ExportParameterSwitch_Vec3
  • MF_FakeDarkenedMattePaint
  • MF_FixtureUVs
  • MF_NormalStrength