Search code examples
kotlintexturesassetsarcoresceneform

ARCore Sceneform SDK linking materials Error?


I just have a simple table model has a 3 segments Top,Brick,Bottom. I applied Normal maps to the bottom part and it was successful but when i tried to apply normal map for the Brick and Top part it says, duplicate field name. I can figure it out what error it says. I was doing what says in this documentation. https://developers.google.com/sceneform/develop/sfa

{
  animations: [
    {
      path: 'sampledata/models/sculpting-table/source/SculptingTable.fbx',
    },
  ],
  materials: [
    {
      name: 'TableTop',
      parameters: [
        {
          baseColor: [
            1,
            1,
            1,
            1,
          ],
        },
        {
          baseColorMap: 'SculptingTable_TableTop_AlbedoTransparency',
        },
        {
          normalMap: null,
        },
        {
          interpolatedColor: null,
        },
        {
          metallic: 0,
        },
        {
          metallicMap: null,
        },
        {
          roughness: 1,
        },
        {
          roughnessMap: null,
        },
        {
          opacity: null,
        },
      ],
      source: 'build/sceneform_sdk/default_materials/fbx_material.sfm',
    },
    {
      name: 'TableBottom',
      parameters: [
        {
          baseColor: [
            1,
            1,
            1,
            1,
          ],
        },
        {
          baseColorMap: 'SculptingTable_TableBottom_AlbedoTranspare',
        },
        {
          normalMap: 'bumps',
        },
        {
          interpolatedColor: null,
        },
        {
          metallic: 0,
        },
        {
          metallicMap: null,
        },
        {
          roughness: 1,
        },
        {
          roughnessMap: null,
        },
        {
          opacity: null,
        },
      ],
      source: 'build/sceneform_sdk/default_materials/fbx_material.sfm',
    },
    {
      name: 'TableBricks',
      parameters: [
        {
          baseColor: [
            1,
            1,
            1,
            1,
          ],
        },
        {
          baseColorMap: 'SculptingTable_TableBricks_AlbedoTranspare',
        },
        {
          normalMap: null,
        },
        {
          interpolatedColor: null,
        },
        {
          metallic: 0,
        },
        {
          metallicMap: null,
        },
        {
          roughness: 1,
        },
        {
          roughnessMap: null,
        },
        {
          opacity: null,
        },
      ],
      source: 'build/sceneform_sdk/default_materials/fbx_material.sfm',
    },
  ],
  model: {
    attributes: [
      'Position',
      'TexCoord',
      'Orientation',
      'BoneIndices',
      'BoneWeights',
    ],
    collision: {},
    file: 'sampledata/models/sculpting-table/source/SculptingTable.fbx',
    name: 'SculptingTable',
    recenter: 'root',
  },
  samplers: [
    {
      file: '/Users/vishweshwaran/Downloads/sculpting-table/textures/SculptingTable_TableBricks_AlbedoTranspare.png',
      name: 'SculptingTable_TableBricks_AlbedoTranspare',
      pipeline_name: '/Users/vishweshwaran/Downloads/sculpting-table/textures/SculptingTable_TableBricks_AlbedoTranspare.png',
    },
    {
      file: '/Users/vishweshwaran/Downloads/sculpting-table/textures/SculptingTable_TableBottom_AlbedoTranspare.png',
      name: 'SculptingTable_TableBottom_AlbedoTranspare',
      pipeline_name: '/Users/vishweshwaran/Downloads/sculpting-table/textures/SculptingTable_TableBottom_AlbedoTranspare.png',
    },
    {
      file: '/Users/vishweshwaran/Downloads/sculpting-table/textures/SculptingTable_TableTop_AlbedoTransparency.png',
      name: 'SculptingTable_TableTop_AlbedoTransparency',
      pipeline_name: '/Users/vishweshwaran/Downloads/sculpting-table/textures/SculptingTable_TableTop_AlbedoTransparency.png',
    },
    {
    file: '/Users/vishweshwaran/Downloads/sculpting-table/textures/SculptingTable_TableBottom_Normal.png',
    name: 'bumps',
    injections: [
           {usage: "Normal",},
         ],
    },

    {
        file: '/Users/vishweshwaran/Downloads/sculpting-table/textures/SculptingTable_TableBricks_Normal.png',
        name: 'bumpsBrick',
        injections: [
               {usage: "Normal",},
             ],
        },


  ],
  version: '0.54:2',
}

About is the SFA file of the model.

Validating Materials: Validating material: Jsonnet Error: [1]: RUNTIME ERROR: duplicate field name: "Normal"

This is the log error that appears.


Solution

  • I got the answer we needed to add material_name attribute inside the injection block too. This will get rid of the duplication of "Normal" keyword.

    {
        file: '/Users/vishweshwaran/Downloads/sculpting-table/textures/SculptingTable_TableBottom_Normal.png',
        name: 'bumps',
        injections: [
               {
                  material_name:"name_of_your_material",
                  usage: "Normal",},
             ],
        },