Table of Contents

Materials

Materials are stored in the .mtl format in the res\models\material\ folder.

Overview

The format mainly consists of a list of properties. The material type (type) specifies the required set of properties (see below for a reference). order is used for sorting the materials for rendering, if two materials have the same type.

function data()
return {
  order = 0,          -- render order (used for same materials only)
  params = {          -- holds list of properties
 
  },
  type = "PHYSICAL"   -- material type
}
end

Reference

Properties
props = {                     -- properties for standard-shading (Phong reflection model)
  coeffs = { 1, 1, 0.25, 20 } -- Ka, Kd, Ks, specular exponent (shininess)
}
two_sided = {                 -- two sided materials
  twoSided = false,
  flipNormal = false
}
light_scale = {
  lightScale = 15.0           -- scale RGB-texture-value of emissive materials
}
alpha_scale = {
  alphaScale = 1.0            -- scale alpha value of transparent materials
}
normal_scale = {
  normalScale = 1.0           -- scale normals of materials with normal mapping
}
alpha_test = {
  preferAlphaToCoverage = false,  -- enable Alpha to coverage (requires multisampling)
  alphaThreshold = 0.5,       -- discard pixels with lower alpha
  blend = true                -- enable alpha blending
}
color_blend = {
  albedoScale = 0.07,         -- scale gray value (which is overlayed with color)
  color = { 50/255, 85/255, 38/255} -- color used for blending
}
 
color_blend = {
  albedoScales = { 1.1, 1.9, 1.8, 0.5 },
  colors = { }
}
dirt_rust = {
  dirtColor = { 62/255, 58/255, 51/255 },
  dirtOpacity = 5/100,
  dirtScale = 100/12.5,
 
  rustColor = { 89/255, 61/255, 38/255 },
  rustOpacity = 50/100,
  rustScale = 100/34.77
}
fade_out_range = {           -- start/end for calculating fade out alpha
  fadeOutEndDist = 20000,
  fadeOutStartDist = 10000,
}
polygon_offset = {           -- parameters for OpenGL function glPolygonOffset()
  factor = -4.0,
  units = -4.0
}

Maps

Maps are used to describe the textures used by a material. There are three types: two dimensional (TWOD), cube map (CUBE_MAP) and an array of two dimensional textures (TWOD_ARRAY). The accepted file formats are TGA and preferably DDS.

map_albedo_opacity = {
  type = "TWOD",                      -- texture type: TWOD, CUBE_MAP, TWOD_ARRAY
  fileName = "models/vehicle/bus/bus_d40_albedo_opacity.dds",
 
  magFilter = "LINEAR",               -- maps to GL_TEXTURE_MAG_FILTER: NEAREST, LINEAR
  minFilter = "LINEAR_MIPMAP_LINEAR", -- maps to GL_TEXTURE_MIN_FILTER: NEAREST, LINEAR, LINEAR_MIPMAP_LINEAR
  wrapS = "CLAMP_TO_EDGE",            -- maps to GL_TEXTURE_WRAP_S: REPEAT, CLAMP_TO_EDGE
  wrapT = "CLAMP_TO_EDGE",            -- maps to GL_TEXTURE_WRAP_T: REPEAT, CLAMP_TO_EDGE
 
  mipmapAlphaScale = 0,               -- scale alpha channel on mip map generation
  compressionAllowed = true,          -- texture compression
  redGreen = false,                   -- two channel format (BC5)
  scaleDownAllowed = false            -- texture can be scaled down, if texture quality is not set to 'Very high'
}

Operations

A material can use multiple overlay operations (currently at most two) with textures. For each operation, a map and a set of parameters have to be specified. Apart from being disabled (NO_OP), there are three types of operations. There are three modi of obtaining the texture coordinates for the overlay texture: use the local coordinates (NORMAL), the world coordinates (WORLD_XY) or the uv-coordinates (TEXCOORD).

operation = {
  op = "OVERLAY",        -- NO_OP, MULTIPLICATION, OVERLAY, LINEAR_BURN
  mode = "NORMAL",       -- TEXCOORD, WORLD_XY, NORMAL
  scale = { 0.05, 0.5 }, -- scale of overlay texture
  opacity = 0.5          -- opacity of operation
},
 
map_op = {
 
}
Material Types

REFLECTIVE

REFLECTIVE_NRML_MAP

REFLECTIVE_OP

REFLECTIVE_NRML_MAP_OP

PHYSICAL

PHYSICAL_OP

PHYSICAL_NRML_MAP

PHYSICAL_NRML_MAP_CBLEND

PHYSICAL_NRML_MAP_CBLEND_DIRT

PHYSICAL_NRML_MAP_OP

PHYSICAL_NRML_MAP_CBLEND_OP

PHYSICAL_NRML_MAP_OP_UV1_AO

PHYSICAL_NRML_MAP_OP_UV1_AO

PHYSICAL_OP_GLOSS_ONLY

PHYSICAL_OP_GLOSS_ONLY

SKINNING_TEXTURED

SKINNING_PHYS_CBLEND4

SKINNING_PHYS_NRML_MAP_CBLEND4

PHYSICAL_ALPHA_NRML_MAP

PHYSICAL_ALPHA_NRML_MAP_OP

PHYS_TRANSPARENT

PHYS_TRANSPARENT_NRML_MAP

PHYS_TRANSPARENT_NRML_MAP_CBLEND_DIRT

PHYSICAL_NRML_MAP_CBLEND_DIRT_LOGO

TRANSPARENT

TRANSPARENT_DETAIL

TRANSPARENT_NRML_MAP

TRANSPARENT_OP

TRANSPARENT_NRML_MAP_OP

EMISSIVE

LEAF_CARD

BILLBOARD

BILLBOARD_MULTI