Skip to content
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

No mtl file provided #7

Closed
LordLiang opened this issue Aug 15, 2023 · 2 comments
Closed

No mtl file provided #7

LordLiang opened this issue Aug 15, 2023 · 2 comments

Comments

@LordLiang
Copy link

Thank you for excellent work! I want to generate texture for a simple chair and I have OBJ mesh (I put it into ./data/chair/mesh.obj) but no mtl file.
I run:

python scripts/generate_texture.py \
    --input_dir data/chair/ \
    --output_dir outputs/chair \
    --obj_name mesh \
    --obj_file mesh.obj \
    --prompt "wooden chair" \
    --add_view_to_prompt \
    --ddim_steps 50 \
    --new_strength 1 \
    --update_strength 0.3 \
    --view_threshold 0.1 \
    --blend 0 \
    --dist 1 \
    --num_viewpoints 36 \
    --viewpoint_mode predefined \
    --use_principle \
    --update_steps 20 \
    --update_mode heuristic \
    --seed 42 \
    --post_process \
    --device "2080" \
    --use_objaverse

then I get this error:

=> initializing input arguments...
=> OUTPUT_DIR: outputs/chair/42-p36-h20-1.0-0.3-0.1
=> loading target mesh...
/home/zhoujie/anaconda3/envs/text2tex/lib/python3.9/site-packages/pytorch3d/io/obj_io.py:544: UserWarning: No mtl file provided
  warnings.warn("No mtl file provided")
Traceback (most recent call last):
  File "/home/zhoujie/Projects_08/Text2Tex/scripts/generate_texture.py", line 202, in <module>
    verts_uvs=new_verts_uvs[None, ...]
TypeError: 'NoneType' object is not subscriptable

Can you tell me how to prepare the mtl file?

@daveredrum
Copy link
Owner

Hi @LordLiang, I guess you can apply the dummy texture (samples/dummy.png) to your mesh in MeshLab (Filters->Texture->Set Texture), and export the mesh. The .mtl file you were asking for should be available after this.

Or in an even simpler way: copy data/backpack/mesh.mtl over to your folder, and add these lines in your .obj file:

mtllib mesh.mtl
usemtl mesh

Now you should have a material for your untextured mesh.

@LordLiang
Copy link
Author

Hi @LordLiang, I guess you can apply the dummy texture (samples/dummy.png) to your mesh in MeshLab (Filters->Texture->Set Texture), and export the mesh. The .mtl file you were asking for should be available after this.

Or in an even simpler way: copy data/backpack/mesh.mtl over to your folder, and add these lines in your .obj file:

mtllib mesh.mtl
usemtl mesh

Now you should have a material for your untextured mesh.

Thank you for your reply! I found that if the obj file contains 'vt' info (texture coordination), your suggestion work well. But for a bare mesh which has no 'vt' info (e.g., only contains 'v' and 'f'), UV mapping need to be done first. Finally, I generated 'vt' info using blender's "smart UV project". ^-^

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

2 participants