Skip to main content

History: HLMS Materials

Source of version: 11 (current)

Copy to clipboard
            !!High Level Materials System (HLMS)
HLMS is the new material system replacing the old material system of earlier Ogre versions. This doesn't mean that the old material system is completely gone, but for most of the cases the HLMS materials are sufficient. The HLMS system is extendable, e.g. you can implement a 'skin' or 'fur' HLMS yourself. Ogre includes two HLMS flavours out-of-the-box:
*__PBS - Physically Based Shading__; an approach for materials and rendering that creates more accurate and predictable results than previous game rendering techniques. See [http://wiki.polycount.com/wiki/PBR|Polycount wiki] for more information.
*__Unlit - Unlit rendering__; the textures in the material are not affected by light.
{img fileId="1759" thumb="y" width = "24" height = "24" rel="box[g]"}
Note, that there are 2 other HLMS implementations named PbsMobile and UnlitMobile. They are used for GLES2 rendering and may not be completely on-par with the regular Pbs and Unlit versions.

Materials can be loaded and saved as a file, but unlike the previous material system, the format of the HLMS material file is Json. Example:
{CODE()}{
    "samplers" :
    {
        "Sampler_3" :
        {
            "min" : "anisotropic",
            "mag" : "anisotropic",
            "mip" : "anisotropic",
            "u" : "wrap",
            "v" : "wrap",
            "w" : "wrap",
            "miplodbias" : 0,
            "max_anisotropic" : 1,
            "compare_function" : "disabled",
            "border" :[1, 1, 1, 1],
            "min_lod" : -3.40282e+38,
            "max_lod" : 3.40282e+38
        }
    },

    "macroblocks" :
    {
        "Macroblock_0" :
        {
            "scissor_test" : false,
            "depth_check" : true,
            "depth_write" : true,
            "depth_function" : "less_equal",
            "depth_bias_constant" : 0,
            "depth_bias_slope_scale" : 0,
            "cull_mode" : "clockwise",
            "polygon_mode" : "solid"
        }
    },

    "blendblocks" :
    {
        "Blendblock_0" :
        {
            "alpha_to_coverage" : false,
            "blendmask" : "rgba",
            "separate_blend" : false,
            "src_blend_factor" : "one",
            "dst_blend_factor" : "zero",
            "blend_operation" : "add"
        }
    },

    "pbs" : 
    {

        "aluminium" :
        {
            "macroblock" : "Macroblock_0",
            "blendblock" : "Blendblock_0",
            "shadow_const_bias" : 0.01,
            "workflow" : "metallic",
            "diffuse" :
            {
                "value" : [1, 1, 1],
                "background" : [1, 1, 1, 1]
            },
            "specular" :
            {
                "value" : [1, 1, 1]
            },
            "metallness" :
            {
                "value" : 0.38
            },
            "normal" :
            {
                "value" : 1.03,
                "texture" : "aluminum_normal.png",
                "sampler" : "Sampler_3"
            },
            "roughness" :
            {
                "value" : 1,
                "texture" : "aluminum_roughness.png",
                "sampler" : "Sampler_3"
            },
            "reflection" :
            {
                "texture" : "Tantolunden.dds",
                "sampler" : "Sampler_3"
            }
        }
    }
}{CODE}


!!Material structure
A material consists of a certain structure:
__Datablock__; this is basically the definition of a specific material and contains individual information about that material. It can 'consist' of:
~hs~~hs~~hs~~hs~|_ __Samplerblock__ (0..32); a sampler block contains the properties of a texture map. A texture map is represented by an image, usually loaded from a .png or .jpg file.
~hs~~hs~~hs~~hs~|_ __Macroblock__ (0..32); describes the rasterizer state and includes properties such as depth check, depth write, cull mode, ... Macrcoblocks may be shared between datablocks.
~hs~~hs~~hs~~hs~|_ __Blendblock__ (0..32); also describes the rasterizer state, but is separated from macroblocks because of sorting of transparent materials. Blendblocks may be shared between datablocks.  


!!Pbs
The Pbs material is probably the most used material type. It is build up by using different texture maps:
*__Diffuse map__; wraps the texture image onto the 3D geometry surface while displaying its original pixel color.
*__Normal map__; the textures' color representation affects surfaces (bumps, scratches, ...) while providing higher degrees of detail. Sometimes used by the name 'albedo'.
*__Specular / Metallic map__; when in metal workflow, the texture is used as a metallic texture and is expected to be a monochrome texture. When in specular workflow, the texture is used as a specular texture, and is expected to be either coloured or monochrome.
*__Roughness map__; the roughness map describes the surface irregularities that cause light diffusion. Rougher surfaces will have larger and dimmer looking highlights. Smoother surfaces will keep specular reflections focused, which can appear to look brighter or more intense even though the same total amount of light is reflected.
*__Detail weight map__; provides a mask to cover detail maps over the mesh, by controlling weight of each of the 4 maps via the RGBA channels of the weight map. 'R' controls the detail map 0, 'G' the detail map 1, 'B' the detail map 2, and 'A' the detail map 3.
*__Detail map 0__; is placed on top of the diffuse map. There can be max. 4 detail maps.
*__Detail map 1__; same
*__Detail map 2__; same
*__Detail map 3__; same
*__Detail normal map 0__; additional normal map, placed on top a a regular normal map. There can be max. 4 detail normal maps.
*__Detail normal map 1__; same
*__Detail normal map 2__; same
*__Detail normal map 3__; same
*__Environment probe map__; environment probe map is also referred to as Reflection map. The image map is projected onto a 3D surface to represent a reflection of the environment.  
!!Unlit
An Unlit material is used in cases where not lighting effect is needed. It is constructed by using up to 16 different texture maps.


!!Material workflow
Ogre V2 support three basic types of workflow: Specular workflow, Specular as fresnel workflow and Metallic workflow. The types of workflow are explained in more detail in [https://www.allegorithmic.com/system/files/software/download/build/PBR_volume_02_rev05.pdf|PBR Guide volume 2]
(See also [https://www.allegorithmic.com/system/files/software/download/build/PBR_Guide_Vol.1.pdf|PBR Guide volume 1] for the first part of the PBR guide).


!!Tools
There is a material editor, that can be used to create HLMS materials. It supports creation of Pbs and Unblit materials. See [https://github.com/spookyboo/HLMSEditor|HLMS Editor source] and [https://github.com/spookyboo/HLMSEditor_bin|HLMS Editor Windows setup]


!!Create your own Hlms
TODO