Skip to content

Conversation

@ft-lab
Copy link
Collaborator

@ft-lab ft-lab commented Dec 22, 2025

Description

Fixes #39

URDF materials and obj materials have been implemented.

  • URDF materials: Applies global materials within the URDF to the visual geometry.
  • OBJ materials: Apply the material assigned in obj. This material will be embedded in the GeometryLibrary. Materials used in obj are treated on the same level as URDF materials.
    • All materials(URDF materials, OBJ materials) used are stored in the MaterialLibrary.
    • Material referencing and binding is done in material layers.

Specification for assigning materials

  • When specifying URDF material colors, they are converted from sRGB to Linear and passed to USD.
  • The material uses UsdPreviewSurface.
  • If both color and texture are specified in the URDF material, they are multiplied together.
    • The multiplication is reflected using the "scale" of the UsdPreviewSurface texture.
  • If both color and texture are specified in the URDF material, The texture will be adopted.
    • The color is stored in the fallback, and if the texture fails to load, the fallback color is used.
  • When using textures as URDF materials and binding them to box/circle/cylinder geometries, a warning is issued because these USD geometries cannot use projected textures. In this case, the conversion will continue.
  Textures are not projection mapped for Cube, Sphere, and Cylinder:
  • Materials are bind to cube/sphere/cylinder/mesh.
  • If obj already has a material bind to its mesh, assigning a URDF material to it will override it.

Material parameters passed from obj

  • diffuse color (obj: Kd)
  • diffuse color texture (obj: map_Kd)
  • opacity (obj: dissolve)
  • opacity texture (obj: map_d)
  • ior (obj: Ni)
  • specular color (obj: Ks)
  • specular color texture (obj: map_Ks)
  • roughness (obj: Pr)
  • metallic (obj: Pm)
  • normal texture (obj: norm)
  • roughness texture (obj: map_Pr)
  • metallic texture (obj: map_Pm)

For obj files, since PBR materials are not applied, no other parameters are passed here.

The materials within these obj files are placed in the [Materials] scope, which is shared as a material layer across the entire project.
If a material name conflicts with the global material name of another obj or URDF, it will be processed to ensure it becomes a unique name.

Normal texture

Some DCC tools may use “bump” or “map_Bump” as the normal map texture for materials in obj files.
Here, if no normal map (obj: norm) is specified, the bump map is used as the normal map.

Specular

If the specular color is not (0,0,0), or if a specular color texture is present, the USD specular workflow is used.

Placing texture files

When referencing textures in URDF materials or OBJ materials, those textures are stored within the Payload/Textures directory.
This means that even if there are multiple obj files and each one references textures, they will all be stored together in the same Textures directory.
If there are identical file names in different paths, a unique file name will be given.

Others

  • If the "color" is omitted from a URDF material, it defaults to (0, 0, 0, 0) in the URDF schema.
    • However, in ROS2, omitting color and texture from material will result in an error, and if only texture is specified, it will appear to be processed as color=(1, 1, 1, 1).
    • Therefore, in the URDF parser part of this repository, the default value of color has been changed to (1, 1, 1, 1).

TODO

  • Check flattening process when exporting. Checked. Updated the unit test.

Checklist

@codecov
Copy link

codecov bot commented Dec 22, 2025

Codecov Report

❌ Patch coverage is 97.37828% with 7 lines in your changes missing coverage. Please review.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
urdf_usd_converter/_impl/material.py 95.42% 7 Missing ⚠️

📢 Thoughts on this report? Let us know!

@ft-lab ft-lab marked this pull request as ready for review December 23, 2025 05:08
@ft-lab
Copy link
Collaborator Author

ft-lab commented Dec 24, 2025

Verification of numpy methods in tinyobjloader

tinyobjloader 2.0.0rc13

It seems that the list is not being retrieved correctly.

reader = tinyobjloader.ObjReader()
reader.ParseFromFile("model.obj")
attrib = reader.GetAttrib()

vertices = attrib.numpy_vertices()

In this case, attrib.numpy_vertices() returned a result filled with the [0]th value, such as [1.0, 1.0, 1.0 ...].
The same goes for attrib.numpy_normals() and attrib.numpy_texcoords().
So I'll leave the obj loading as is.

@andrewkaufman andrewkaufman merged commit bcf7391 into newton-physics:main Jan 14, 2026
11 checks passed
@ft-lab ft-lab deleted the dev/material branch January 21, 2026 00:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Convert native & OBJ materials

2 participants