Working with material state files

Once you have a scene manually setup and the lookdev is where you like it, it’s useful to export these settings to be re-used in other scenes. Currently Material State files are used for this, which store these settings in JSON format.

Approach

The material state file is platform-agnostic and each rendering environment can use this to set the parameters (uniforms) for each material. So for example, if a material is lookdev’d in Maya, a material state file can then be generated and imported into Unity or our browser renderer and applied to the parameters of the equivalent material, ensuring the material looks the same in both environments.

For example:

  "info": {
    "repo": "https://git.didimo.co/didimo/shaders", 
    "commit": "", 
    "shaderVersion": 1.0, 
    "generatedFrom": "G:/Shared drives/Assets/HIFI Faces/assets/character/baseFace/realtimeShaders/baseFace/versions/baseFace_realtimeShaders_baseFace_v013.mb"
  }, 
  "materials": [
    {
      "shaderPath": "C:/cg_pipeline/shaders/materials/textureLighting.ogsfx", 
      "name": "mouthMat", 
      "parameters": [
        {
          "type": "float", 
          "name": "roughness", 
          "value": 0.20000000298023224
        }, 
        {
          "type": "float", 
          "name": "fresnel", 
          "value": 0.5
        }, 
        ...

Automatic Setup of Realtime Materials

The json files contain all the material settings, including textures paths, and also information on what geometry on what geometry each material was assigned to.

Based on the skin color determined by the pipeline, a material state file is generated (in the pipeline) as an interpolation of the material state files that closest match the skin color. This is then sent to the API client along with the rest of the didimo bundle, so that the client sets the shader parameters defined in this JSON file.


Last updated on 2020-10-06