2
$\begingroup$

Has anyone else had issues with appearances while trying to use the new CadShape node instead of an imported model with a PBRAppearance?

I've been trying to convert the imported 3D objects in one of my simulations to be CadShape nodes instead of actually imported. I've realized this now means that the colour/material info needs to be in the .mtl file corresponding to the .obj file Webots references for the model, so I've been trying to add this info in Blender (Fusion360 doesn't export .mtl files with obj).

In Blender I set various material properties, but when I export it and reference it in Webots, it looks nothing like it did in Blender and, more importantly, nothing like the previous PBRAppearance. The main issue seems to be that the new models just won't reflect the surroundings correctly (unless the colour of the model is basically black).

For example, I've included an image of 4 of the same model, the bottom left being the old model with the PBRAppearance defined in Webots, and the other 3 being obj exports from Blender with various settings. The silver part is the part I'm having issues with. All three of the Blender exports are supposed to be 100% metallic where it should look like a mirror (even more so than the one with the PBRAppearance), but they won't reflect any of the surroundings properly. I've included an image of the object in Blender, and I've also included another image of these 4 models with a different Webots background, showing the difference between the PBRAppearance model and the Blender ones quite well.

First image

Second image

Blender image

I've spent hours trying to change settings in Blender and the actual .mtl file to get the same look that the PBRAppearance has to no avail. I've also tried collada files but they have absolutely no reflectivity/metallic looks at all (and fusion will only accept one of these two file types now).

It's not just for this lidar model - it seems that all appearances from Blender just don't appear correctly in Webots, mainly with respect to reflectivity being either way too high or way too low.

Has anyone else had this issue and found a way to solve it? Webots removing the ability to import models seems to have absolutely removed the functionality of getting models to look how they should, I'm really hoping that's not the case. I know that I can import each individual object as a mesh and colour it within Webots as well, but this would then cause me to have a separate obj file for every differently coloured face in my model, which would be hundreds. Not only would that make the file folder nightmarish and huge, I expect that Webots would be very, very slow each time it loaded these hundreds of models in from the folder, so I'm hoping there's a better solution than that.

Also, I tried exporting from Blender as an obj with PBR extensions, but then Webots fails to read the .mtl file properly.

$\endgroup$

1 Answer 1

0
$\begingroup$

The mtl files are interpreted by 3D rendering software in different ways depending on their capabilities. Thus, you won't get the exact same rendering in different 3D software (e.g., Webots and Blender) for the same mtl file.

The mtl capability was introduced in Webots with the CadShape node to facilitate the import of obj files which include materials.

However, if you need a precise and more advanced material rendering, I would strongly recommend to use the Mesh node instead for importing obj files. The Mesh node will simply ignore the mtl file if any, and the appearance of the mesh should be defined in a Webots PBRAppearance node which provides you with a much better control on the quality of the PBR rendering than a mtl file. So, instead of:

CadShape {
  url "my_model.obj"
}

You should use:

Shape {
  appearance PBRAppearance {
    // insert here your PBRAppearance parameters
  }
  geometry Mesh {
    url "my_model.obj"
  }
}

Alternatively, you may want to use one of the predefined PRB appearances, like for example:

EXTERNPROTO "https://raw.githubusercontent.com/cyberbotics/webots/R2023b/projects/appearances/protos/BlanketFabric.proto"

Shape {
  appearance BlanketFabric {
    colorOverride 1 1 0.5
  }
  geometry Mesh {
    url "my_model.obj"
  }
}

Disclaimer: I am a Webots developer working at Cyberbotics.

$\endgroup$
2
  • 1
    $\begingroup$ I did mention in my question that I know meshes would be a possibility, but that it would require having an individual obj file for every face that's a different colour, which means I'd have hundreds of obj files (and I'd need to figure out how to export individual faces of my 3D model as separate obj files, which I'm not even sure is possible). The previous functionality of importing one file and having each coloured face be already separated to be coloured individually is gone. Also, will Webots ever update so that it doesn't give an error when reading an mtl file with PBR extensions? $\endgroup$
    – Pyphais
    Jun 27, 2023 at 17:11
  • $\begingroup$ I believe you can create your own PBR appearance, with complex texture maps that includes several areas with different colors or sub-textures which will be mapped to your mesh according the texture coordinates defined in the obj file. This applies to all types of textures, e.g., base color, roughness, metalness, occlusion, emissive color etc. However, the PBR attributes (basec color, etc.) will be common to all sub-textures. If you need to have different PBR parameters for different objects, then, yes, you need to split your mesh into different sub-meshes, each having its own PBR appearance. $\endgroup$ Jun 28, 2023 at 13:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.