8000 How to import mesh with textures on vertices into Sapien · Issue #208 · haosulab/SAPIEN · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

How to import mesh with textures on vertices into Sapien #208

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
saulgooodman opened this issue Mar 7, 2025 · 2 comments
Open

How to import mesh with textures on vertices into Sapien #208

saulgooodman opened this issue Mar 7, 2025 · 2 comments

Comments

@saulgooodman
Copy link
saulgooodman commented Mar 7, 2025

Hi. I have one mesh with texture on vertices that I want to import to sapien and build actor with it.

I tried this, but it didn't include the texture in the rendering output.

builder = self.scene.create_actor_builder()
builder.add_convex_collision_from_file(filename='./case.ply')
builder.add_visual_from_file(filename='./case.pbj')
self.mesh = builder.build_static(name='mesh')

I also tried .obj and .ply. They all contains colors, which could be shown in Meshlab. But when I import them, the color is missing.

Is there any specific way (e.g., different APIs or different format of texture files) to do this?

Thank you.

case.ply looks like

Image

@yolkarian
Copy link

With this method builder.add_visual_from_file(filename='./case.pbj'). you can assign material with this method. Probably, you can import textures manually by assigning texture to one material and then pass also the material through this function.

Like:

mt = sapien.render.RenderMaterial()
mt.diffuse_texture = sapien.render.RenderTexture2D(filename=texture_file)
builder.add_visual_from_file(filename=mesh_file, material=mt)

In my case, I use .obj mesh files with .mtl files which define the texture. I just call the method without defining material. SAPIEN can import the texture.

@fbxiang
Copy link
Collaborator
fbxiang commented Mar 9, 2025

Color on vertices is known is vertex color (which is not a texture). We strongly encourage using actual textures instead of vertex colors since

  1. Vertex color is less powerful. Most formats only let you specify color, but not other material properties such as roughness.
  2. Vertex color is less standardized. And different software will export vertex color in different color spaces. It is also not clear whether it should be loaded as emission color or diffuse color.

While we implemented shaders without vertex colors, the vertex color properties are still loaded so you can implement your own custom shader to use it in your intended way. For example, the "vertex_color" shader shows how to display vertex color (but all other textures are disabled). You can also edit other shaders to use the vertex color in your own way.

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

No branches or pull requests

3 participants
0