Materials are stored in the .mtl format in the res\models\material\ folder.
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
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 = { }
REFLECTIVE
propstwo_sidedmap_color_reflectfade_out_rangemap_envpolygon_offsetREFLECTIVE_NRML_MAP
propstwo_sidedmap_color_reflectmap_normalfade_out_rangemap_envpolygon_offsetREFLECTIVE_OP
propsoperationtwo_sidedmap_color_reflectfade_out_rangemap_envmap_oppolygon_offsetREFLECTIVE_NRML_MAP_OP
operationpropsmap_normalmap_color_reflecttwo_sidedfade_out_rangemap_envpolygon_offsetmap_opPHYSICAL
two_sidedfade_out_rangemap_metal_gloss_aomap_albedopolygon_offsetPHYSICAL_OP
two_sidedoperation_1map_metal_gloss_aofade_out_rangeoperation_2polygon_offsetmap_albedomap_op_1map_op_2PHYSICAL_NRML_MAP
two_sidedmap_normalfade_out_rangemap_metal_gloss_aomap_albedopolygon_offsetnormal_scalePHYSICAL_NRML_MAP_CBLEND
map_normaltwo_sidedmap_metal_gloss_aofade_out_rangepolygon_offsetmap_albedomap_cblendcolor_blendnormal_scalePHYSICAL_NRML_MAP_CBLEND_DIRT
map_normaltwo_sidedmap_metal_gloss_aofade_out_rangemap_albedopolygon_offsetmap_cblend_dirt_rustmap_dirtmap_dirt_normalmap_rustmap_rust_normalcolor_blenddirt_rustnormal_scalePHYSICAL_NRML_MAP_OP
map_normaltwo_sidedoperation_1map_metal_gloss_aofade_out_rangepolygon_offsetmap_albedomap_op_1map_op_2operation_2normal_scalePHYSICAL_NRML_MAP_CBLEND_OP
map_normaltwo_sidedmap_metal_gloss_aofade_out_rangepolygon_offsetmap_albedomap_cblendmap_op_1map_op_2color_blendoperation_1operation_2normal_scalePHYSICAL_NRML_MAP_OP_UV1_AO
map_normaltwo_sidedmap_metal_gloss_aofade_out_rangepolygon_offsetmap_albedomap_op_1map_aomap_op_2operation_1operation_2normal_scalePHYSICAL_NRML_MAP_OP_UV1_AO
map_normaltwo_sidedmap_metal_gloss_aofade_out_rangepolygon_offsetmap_albedomap_op_1map_aomap_op_2operation_1operation_2normal_scalePHYSICAL_OP_GLOSS_ONLY
two_sidedfade_out_rangeoperation_1map_albedo_glossmap_op_2map_op_1polygon_offsetoperation_2PHYSICAL_OP_GLOSS_ONLY
two_sidedfade_out_rangeoperation_1map_albedo_glossmap_op_2map_op_1polygon_offsetoperation_2SKINNING_TEXTURED
propstwo_sidedmap_colorSKINNING_PHYS_CBLEND4
two_sidedmap_albedomap_cblendmap_metal_gloss_aocolor_blendSKINNING_PHYS_NRML_MAP_CBLEND4
two_sidedmap_normalmap_albedomap_cblendmap_metal_gloss_aocolor_blendnormal_scalePHYSICAL_ALPHA_NRML_MAP
map_normaltwo_sidednormal_scalealpha_scalemap_albedo_alphaalpha_testmap_metal_gloss_aofade_out_rangepolygon_offsetPHYSICAL_ALPHA_NRML_MAP_OP
map_normaltwo_sidedmap_albedo_alphaalpha_testalpha_scalenormal_scalemap_metal_gloss_aofade_out_rangemap_op_1map_op_2polygon_offsetoperation_1operation_2PHYS_TRANSPARENT
two_sidedmap_albedo_opacityalpha_scalealpha_testfade_out_rangemap_metal_gloss_aopolygon_offsetPHYS_TRANSPARENT_NRML_MAP
map_normalmap_albedo_opacitytwo_sidednormal_scalealpha_scalealpha_testmap_metal_gloss_aofade_out_rangepolygon_offsetPHYS_TRANSPARENT_NRML_MAP_CBLEND_DIRT
map_normalmap_albedo_opacitytwo_sidedalpha_testalpha_scaledirt_rustnormal_scalemap_metal_gloss_aofade_out_rangemap_cblend_dirt_rustmap_dirtmap_dirt_normalmap_rustmap_rust_normalpolygon_offsetcolor_blendPHYSICAL_NRML_MAP_CBLEND_DIRT_LOGO
map_normaltwo_sidedmap_metal_gloss_aofade_out_rangemap_albedopolygon_offsetmap_cblend_dirt_rustmap_dirtmap_dirt_normalmap_rustmap_rust_normalmap_logocolor_blenddirt_rustnormal_scaleTRANSPARENT
propstwo_sidedalpha_scalealpha_testfade_out_rangemap_color_alphapolygon_offsetTRANSPARENT_DETAIL
propstwo_sidedmap_detailalpha_scalealpha_testfade_out_rangemap_color_alphapolygon_offsetTRANSPARENT_NRML_MAP
propstwo_sidedmap_normalalpha_scalealpha_testfade_out_rangemap_color_alphapolygon_offsetTRANSPARENT_OP
operationpropstwo_sidedalpha_testalpha_scalefade_out_rangepolygon_offsetmap_opmap_color_alphaTRANSPARENT_NRML_MAP_OP
operationpropsmap_normaltwo_sidedalpha_testalpha_scalefade_out_rangemap_opmap_color_alphapolygon_offsetEMISSIVE
two_sidedlight_scalefade_out_rangemap_emissivepolygon_offsetLEAF_CARD
propsalpha_scalealpha_testfade_out_rangemap_color_alphamap_normalBILLBOARD
propsalpha_scalealpha_testfade_out_rangemap_color_alphabillboardmap_normalBILLBOARD_MULTI
propsfade_out_rangesalpha_scalesalpha_testmap_color_alphamap_normalbillboards