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

bug fix for texture render #34

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions examples/5_render.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@
uv_coords = face3d.morphable_model.load.load_uv_coords('Data/BFM/Out/BFM_UV.mat') # general UV coords: range [0-1]
# to texture size
texcoord = np.zeros_like(uv_coords)
texcoord[:,0] = uv_coords[:,0]*(tex_h - 1)
texcoord[:,1] = uv_coords[:,1]*(tex_w - 1)
texcoord[:,1] = tex_w - texcoord[:,1] - 1
texcoord[:,0] = uv_coords[:,0]*(tex_w - 1)
texcoord[:,1] = uv_coords[:,1]*(tex_h - 1)
texcoord[:,1] = tex_h - texcoord[:,1] - 1
texcoord = np.hstack((texcoord, np.zeros((texcoord.shape[0], 1)))) # add z# render texture python
# tex_triangles
tex_triangles = triangles
Expand Down
6 changes: 3 additions & 3 deletions face3d/mesh/cython/mesh_core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -270,9 +270,9 @@ void _render_texture_core(
tex_tri_p1_ind = tex_triangles[3*i + 1];
tex_tri_p2_ind = tex_triangles[3*i + 2];

tex_p0.x = tex_coords[3*tex_tri_p0_ind]; tex_p0.y = tex_coords[3*tri_p0_ind + 1];
tex_p1.x = tex_coords[3*tex_tri_p1_ind]; tex_p1.y = tex_coords[3*tri_p1_ind + 1];
tex_p2.x = tex_coords[3*tex_tri_p2_ind]; tex_p2.y = tex_coords[3*tri_p2_ind + 1];
tex_p0.x = tex_coords[3*tex_tri_p0_ind]; tex_p0.y = tex_coords[3*tex_tri_p0_ind + 1];
tex_p1.x = tex_coords[3*tex_tri_p1_ind]; tex_p1.y = tex_coords[3*tex_tri_p1_ind + 1];
tex_p2.x = tex_coords[3*tex_tri_p2_ind]; tex_p2.y = tex_coords[3*tex_tri_p2_ind + 1];


x_min = max((int)ceil(min(p0.x, min(p1.x, p2.x))), 0);
Expand Down