Material files are used instead of the textures assigned in the modeling program, they have to use the same name. E.g. if you assign a texture named "grass.dds" to your model, a material file called "grass.mat" will be loaded which should define this material.
Materials have many settings which can be altered directly within the mat file. And because you can specify your own shaders in addition to the surface shaders that come with the engine (including shaders for standard diffuse, bumpmap, specular and parallax mapping effects), the possibilities for material appearances are nearly endless.
Materials attached to/used by animated/skinned parts of meshes have to use the "mesh_..._skin.vert" vertex shaders.
Specifies the texture to use for the nth texture unit (texture0, texture1, etc.). This can be a file path string, e.g.
texture0="abstract::texture.dds"or a texture tag name, e.g.:
texture0="tag::renderdepth"This texture can be set later on in the program using SetGlobalObject() (e.g SetGlobalObject(GetDepthBuffer(gbuffer),"renderdepth"))
clampn=<clamp x?>,<clamp y?>[,<clamp z?>]Specifies if clamping should be used on the u/v (x/y) axis of the specified texture unit. E.g. clamp0=1,1 Will clamp the texture on texture unit 0 (texture0) in both x and y direction.
Clamping means that, if a lookup on the texture is done outside the 0 - 1 uv range, it'll just return the pixel that is at the closest border (since uv values greater/smaller than 0 - 1 will get put back into that range -> so clamping disables texture wrapping).
See also Repeating and Clamping Textures.
Specifies the RGBA color for the surface. Something like:
If set to 0, this will disable depth-writing when this material is rendered. Use this for particle effects. The default value is 1.
If set to 0, this will disable color-writing when this material is rendered. The default value is 1.
If disabled the surface will be drawn on top of all previously rendered surfaces. However, triangles within a surface may not appear in correct order.
If disabled (=0), surfaces using this material won't cast shadows. To hide an entity completely, use HideEntity.
If enabled (=1), surfaces using this material won't be drawn (this only skips standard rendering, the shadow will still be rendered and visible). To hide an entity completely, use HideEntity.
Defines the specular intensity. This is multiplied with the alpha channel of the normal map, which specifies relative specularity. [0.0 - 1.0]. This is the uniform float specular value passed to the material's shaders.
Defines the gloss factor of the specular effect [with default shaders 0.0 - 1.0]. This sharpens the specular reflection (really low makes everything look white, really high makes it very sharp, only a small dot). This is the uniform float gloss value passed to the material's shaders.
Defines the intensity of the bump effect. 0 means no bump. This is the uniform float bumpscale value passed to the material's shaders.
If set to 1, the surface will be sorted with other z-sorted object in the scene. Sorted objects will be drawn last, from back to front. Use this setting with transparency.
In Leadwerks Engine 2.1, if zsort is set to -1, the surface will be drawn first. This can be used to create a depth-pass material which gets rendered first. The material can be applied to surfaces hidden inside walls and large objects. This will minimize fragment processing in scenes with a high overdraw factor:
zsort=-1 cullface=0 colormask=0 castshadows=0 shader="abstract::mesh.vert"
If set to 0 surfaces will appear two-sided. The default setting is 1.
If set to 1 the surface will be drawn with a slight offset towards the camera. This setting can be used to render decals on top of another surface.
Sets the material blend mode. Available blend modes are below - both the word and the number can be used:
- 0 - solid (default)
- 1 - alpha
- 2 - light
- 3 - shade
- 4 - mod2x
Specifies a shader to use with the material. The vertex and fragment shaders should be specified, as below:
Specifies a shadow shader to use with the material. The vertex and fragment shaders should be specified, as below. If a fragment shader is not specified, none will be used:
Sets the material collision type. This allows the the user to specify collision interactions on a submesh basis. The collision type will only affect submeshes it is applied to. Entities other than meshes will use the entity collision type. If a collision occurs with a submesh and no material is present, or the material does not have a specified collision type, the mesh entity collision type will be used.
Example Material Files
Assuming you assigned a file called "texture.xxx" to the mesh (and have a converted dds version of this texture) in a modeling application, the material file (which should be ideally placed in the same folder as the converted gmf mesh) should look like:
texture0="abstract::texture.dds" shader="abstract::mesh_diffuse.vert","abstract::mesh_diffuse.frag"The filename should be texture.mat.
Diffuse, Bumpmap and Specular
Assuming you assigned a file called "texture.xxx" to the meshin a modeling application:
You should have a dds version of the texture, which can have any name, but ideally the same as the texture you assigned (-> "texture.dds")
and a tangent space normal map (also in dds format, recommended filename "texturedot3.dds").
with the specular intensity in it's alpha channel (completely white alpha channel means full specular intensity everywhere, black means none)
the material file (which should be ideally placed in the same folder as the converted gmf mesh) should look like:
texture0="abstract::texture.dds" texture1="abstract::texturedot3.dds" shader="abstract::mesh_diffuse_bumpmap.vert","abstract::mesh_diffuse_bumpmap_specular.frag"The filename should be texture.mat
Diffuse, Bumpmap and Specular Animated
The same as above, but the "mesh_diffuse_bumpmap_skin.vert" vertex shader and the "mesh_shadow_skin.vert" shadow vertex shader have to be used:
texture0="abstract::texture.dds" texture1="abstract::texturedot3.dds" shader="abstract::mesh_diffuse_bumpmap_skin.vert","abstract::mesh_diffuse_bumpmap_specular.frag" shadowshader="mesh_shadow_skin.vert"