shunsukesaito / PIFu

This repository contains the code for the paper "PIFu: Pixel-Aligned Implicit Function for High-Resolution Clothed Human Digitization"
https://shunsukesaito.github.io/PIFu/
Other
1.77k stars 340 forks source link

render_data.py with Maya exported 3D model #111

Open bell-one opened 3 years ago

bell-one commented 3 years ago

Hello! I'd like to report some bug in render_data.py

I export 3D model from Maya with Quad format. And use prt_util.py and render_data.py script but obtain weird render results. image image

I found that trimesh imported quad face order is different with render_data imported face order.

https://github.com/shunsukesaito/PIFu/blob/02a6d8643d3267d06cb4a510b30a59e7e07255de/apps/prt_util.py#L132

this from trimesh imported

https://github.com/shunsukesaito/PIFu/blob/02a6d8643d3267d06cb4a510b30a59e7e07255de/apps/render_data.py#L175

and this face from source have different order and render bad results. I made _q lists to make same order with trimesh imported face like under

face_data = []
face_norm_data = []
face_uv_data = []
face_data_q = []
face_norm_data_q = []
face_uv_data_q = []
if isinstance(mesh_file, str):
    f = open(mesh_file, "r")
else:
    f = mesh_file
for line in f:
    if isinstance(line, bytes):
        line = line.decode("utf-8")
    if line.startswith('#'):
        continue
    values = line.split()
    if not values:
        continue

    if values[0] == 'v':
        v = list(map(float, values[1:4]))
        vertex_data.append(v)
    elif values[0] == 'vn':
        vn = list(map(float, values[1:4]))
        norm_data.append(vn)
    elif values[0] == 'vt':
        vt = list(map(float, values[1:3]))
        uv_data.append(vt)

    elif values[0] == 'f':
        # quad mesh
        if len(values) > 4:
            f = list(map(lambda x: int(x.split('/')[0]), values[1:4]))
            face_data.append(f)
            f = list(map(lambda x: int(x.split('/')[0]), [values[3], values[4], values[1]]))
            face_data_q.append(f)
        # tri mesh
        else:
            f = list(map(lambda x: int(x.split('/')[0]), values[1:4]))
            face_data.append(f)

        # deal with texture
        if len(values[1].split('/')) >= 2:
            # quad mesh
            if len(values) > 4:
                f = list(map(lambda x: int(x.split('/')[1]), values[1:4]))
                face_uv_data.append(f)
                f = list(map(lambda x: int(x.split('/')[1]), [values[3], values[4], values[1]]))
                face_uv_data_q.append(f)
            # tri mesh
            elif len(values[1].split('/')[1]) != 0:
                f = list(map(lambda x: int(x.split('/')[1]), values[1:4]))
                face_uv_data.append(f)
        # deal with normal
        if len(values[1].split('/')) == 3:
            # quad mesh
            if len(values) > 4:
                f = list(map(lambda x: int(x.split('/')[2]), values[1:4]))
                face_norm_data.append(f)
                f = list(map(lambda x: int(x.split('/')[2]), [values[3], values[4], values[1]]))
                face_norm_data_q.append(f)
            # tri mesh
            elif len(values[1].split('/')[2]) != 0:
                f = list(map(lambda x: int(x.split('/')[2]), values[1:4]))
                face_norm_data.append(f)

face_data+=face_data_q
face_uv_data+=face_uv_data_q
face_norm_data+=face_norm_data_q

this maybe caused by some environmental issues like Maya version or trimesh version I used! but report it with hoped that someone suffers like me

kampelmuehler commented 3 years ago

I suggest only using triangle meshes with PIFu. There are issues with the rendering with quad meshes. Best to triangulate them before importing.

bell-one commented 3 years ago

@kampelmuehler There is a part in the code that converts a quad mesh to a triangle mesh. The part I reported was that there was an index problem in the process of converting the triangle mesh of the quad mesh exported from Maya, and I reported the code that arranged the index order! Thanks for your interact

ArefMYTB commented 2 years ago

Hi, I got my dataset from makehuman app bc it was free. but the textures are separated. as you see I have the textures all but I can't just replace pifu dataset with these. image image image image image image

I checked the render_data file but I couldn't understand the opengl codes and how exactly pifu used the texture image.

any Idea?

Thank you so much :)