thygate / stable-diffusion-webui-depthmap-script

High Resolution Depth Maps for Stable Diffusion WebUI
MIT License
1.73k stars 159 forks source link

Loading obj and png in Blender #361

Open jaggzh opened 1 year ago

jaggzh commented 1 year ago

Is there a way to load this into blender?

So:

  1. How do we get a textured .obj (or the texture itself)?
  2. How do we map it onto the obj? (I am familiar with nodes in blender)
  3. (How do we handle the camera params? I see the .obj has h and vfov)

SS_20231022_222531

SS_20231022_223531

jaggzh commented 1 year ago

In looking at the code it appears it does infill calculation for each frame of video; so there's not some single-texture to map onto the mesh object.... Darn. :}

mbloflin commented 1 year ago

you can do it. I have done it. I'm not at Blender right now, but I think you use vertex color to apply your image properly.

KlenM commented 11 months ago

You need to select Color Attribute | Color for the Base Color of the mesh (see the red rectangle in the image). ksnip_20231209-010625 For me, this works just fine for the Simple mesh. But for the Inpainted Mesh it does not work as expected (see above). I don't know why, but I found that the trimesh package is used to export to .obj for the Simple mesh, but for the Inpainted mesh a custom written export is used: https://github.com/thygate/stable-diffusion-webui-depthmap-script/blob/b8120b41a9223796ba42393c0c07ba90870cddd0/inpaint/mesh.py#L2160-L2168

aulerius commented 8 months ago

You need to select Color Attribute | Color for the Base Color of the mesh (see the red rectangle in the image). ksnip_20231209-010625 For me, this works just fine for the Simple mesh. But for the Inpainted Mesh it does not work as expected (see above). I don't know why, but I found that the trimesh package is used to export to .obj for the Simple mesh, but for the Inpainted mesh a custom written export is used:

https://github.com/thygate/stable-diffusion-webui-depthmap-script/blob/b8120b41a9223796ba42393c0c07ba90870cddd0/inpaint/mesh.py#L2160-L2168

Hey, did you ever figure this out?

The .ply export option does have correct color mappings, but the .obj mesh option has this glitchy, grainy look to it for me as well.

KlenM commented 8 months ago

Sadly, no, I haven't worked on this issue.

aulerius commented 8 months ago

Sadly, no, I haven't worked on this issue.

Just now I tested importing these .obj into something else (TouchDesigner), and there the colors actually map correctly. So it may be something to do with the blender .obj importer after all.

frustaci commented 3 months ago

i ran into this issue but clearly its a blender only obj bug, ply works. Replicated the issue in blender only, by subdving a cube 3 times and then dupped a few vertices (4 or 5 or 6 vertices) to be faceless-edgeless, vertex painted a bunch, exported and reimported and this is the result. Ill try to open a bug report in blender repo.

*PS. Added a report into that bug. https://projects.blender.org/blender/blender/issues/117367#issuecomment-1257731

objbug