VAST-AI-Research / TripoSR

MIT License
4.27k stars 494 forks source link

How to dump .obj with texture.png instead of color on vertex? #8

Open SunzeY opened 6 months ago

SunzeY commented 6 months ago

Blender only support std .obj format with unwrapped uv in a texture.png file. Is it possible to use trimesh to achieve this?

yuedajiong commented 6 months ago
  1. modify this code
  2. re-fit: fix shape and fit texture, very simple.
SunzeY commented 6 months ago

@yuedajiong Could you show the code of this? I am trying the solution mentioned in here. But I am still having trouble writing the correct code...

yuedajiong commented 6 months ago

you can find code in pytorch3d: fit cube, etc. and you can use any other differentiable render to fit.

mrbid commented 6 months ago

blender works fine with vertex color models

https://github.com/VAST-AI-Research/TripoSR/assets/78346668/89f6572f-a1d0-435c-8208-99716f9bcf9b

PatricioFernandezF commented 6 months ago

Do you know how to do it in Unity?

mrbid commented 6 months ago

Do you know how to do it in Unity?

Most default Unity Shaders do not support vertex colors, but Polybrush comes with sample Shaders which you can import into your Project. For more information, see Importing Polybrush Shaders. https://docs.unity3d.com/Packages/com.unity.polybrush@1.0/manual/modes_color.html#:~:text=Most%20default%20Unity%20Shaders%20do,information%2C%20see%20Importing%20Polybrush%20Shaders.

Otherwise you will want to project the Vertex Colors to a UV Map before importing to Unity.

SunzeY commented 6 months ago

I have recently written a script to convert TripoSR exported .obj file into standard obj file with separated .png for kd_diffuse texture using Blender. Check it out if you have facing the same problem

stevens-Ai commented 6 months ago

SunzeY's script works. Thank you for a great script.

mlo0352 commented 6 months ago

I created a Colab doc for anyone who wants to test the script out. Thanks, @SunzeY https://colab.research.google.com/drive/1-MNGiAnk8f_6mpmJP42OMzS8xGfG-Y39

mapluisch commented 5 months ago

I've created a small Unity project for integrating TripoSR in Unity: https://github.com/mapluisch/TripoSR-for-Unity/. It uses a custom obj importer for correctly parsing the vertex colors for a custom shader.

Feel free to check it out 😊

MNeMoNiCuZ commented 5 months ago

I created a Colab doc for anyone who wants to test the script out. Thanks, @SunzeY https://colab.research.google.com/drive/1-MNGiAnk8f_6mpmJP42OMzS8xGfG-Y39

This one worked great for me! Thanks for sharing! <3

WuNein commented 5 months ago

blender works fine with vertex color models

But when i render the image , the color is none.

mrbid commented 5 months ago

blender works fine with vertex color models

But when i render the image , the color is none.

Please refer to this document: https://docs.blender.org/manual/en/2.79/sculpt_paint/painting/vertex_paint/introduction.html

Vertex colors can be painted by switching to Vertex Paint Mode; however, it will not show up in the render unless you check Vertex Color Paint in the Materials Options panel (for Blender Renderer). You can also the use Geometry Node to access vertex color information in the material node tree.

rawwerks commented 5 months ago

i believe that 1 line of code would fix this, which is adding the trimesh.to_texture() method.

see https://github.com/VAST-AI-Research/TripoSR/issues/76 for details