-
Notifications
You must be signed in to change notification settings - Fork 63
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
texture coordinate problem #46
Comments
obj files compress the vt coordinate, look at the face part. It is in following format: |
@shinxg,yes,because of the multi-edge "seams"effect,one vertex may corresponds to multiple texture coordinate,in marjority of 3D models they use perWedge UV map instead of perVertex UV map,so my question is how to compress the UV map so that make it own the same dimension of vertices number,to fit the rasterization operation in DIRT? |
For those vertices which have different uv coordinates on different faces, you can add some duplicated vertices with corresponding uv coordinates. |
For some reason ,I can not change the vertics number of the PCA model,I wonder if have any other solution to do texture rendering without using vertex-color because vertex-color is not realistic compare to texture rendering |
@quyanqiu You need to duplicate the vertices when they have different UVs, as @shinxg stated. First load the vertex positions and UVs from the obj file into separate arrays, and also the indices from the faces. obj_vertices = ...
obj_uvs = ...
obj_vertex_indices = ... - 1
obj_uv_indices = ... - 1
assert len(obj_vertex_indices) == len(obj_uv_indices) Then, build a new set of vertices, UVs, and faces, with each vertex/UV used exactly once per face, something like expanded_vertices = []
expanded_uvs = []
expanded_faces = []
for face_index in range(len(obj_vertex_indices)):
expanded_faces.append([len(expanded_vertices), len(expanded_vertices) + 1, len(expanded_vertices) + 2])
expanded_vertices.extend(obj_vertices[obj_vertex_indices[face_index]])
expanded_uvs.extend(obj_uvs[obj_uv_indices[face_index]])
assert len(expanded_vertices) == len(expanded_uvs) == len(expanded_faces) * 3 Then use the If you need the vertex positions to depend on some other tensor (rather than being constant), you may need to do the 'expansion' with tf.gather instead of a loop and numpy indexing. |
@pmh47@shinxg thanks for your guys response,I think that’s the solution here, I will try |
Hi~ Did you make it? I still confused how to make it, I tried and failed. Is there a method to do this? |
def convert_2_pervertex_uv(V, F, UV, TF):
V_new = np.zeros((F.shape[0]*3, 3))
UV_new = np.zeros((F.shape[0]*3, 2))
F_new = np.zeros((F.shape[0], 3))
for i in range(0, F.shape[0]):
for j in range(0, 3):
V_new[3*i+j, :] = V[F[i, j], :]
UV_new[3*i+j, :] = UV[TF[i, j], :]
F_new[i, j] = 3*i+j
return V_new, F_new, UV_new V: #V3 |
Hi~ Thanks! And when I use the above code to transfer, I got:
I think this is caused by the index. Thanks! |
@shinxg Hi~ I think the problem is caused by index.
|
@Frank-Dz the reason is smpl uv order is not compatible with OpenGL,try following code: |
Hi~ @quyanqiu Sorry for bothering you again. Do you know how to render an obj with a transparent background or specific image? I rendered some results, and all my results are like: I know I should adjust the background_attributes, but I do not know how to set it.
Thanks for any help and guidance! |
@Frank-Dz its very easy bro,the render result is RGBA format ,where the A channel indicate which pixel belong to the model,you can just doing substitution with following code. I do not debug these code,but the idea is here |
Thanks! But I am still a little confused. Hope not to be too bothering.
The render result is Thank you very much! Best, |
your code is wrong here: as for why rgb value is between 0-1 and why its can be 4 dimension,May be you should know what is rasterization first,its a classical issue in computer graphics |
Thanks again! So I just print it out:
The output is "(600, 600, 3)". And after using changed code
I got the following error:
That's why I am confused, the output of Thanks again! |
@quyanqiu Hi~ I know there is a code which uses rasterise:
The output is The code is in |
you may need consult the author for more detail ,if you just need rendering instead of backward,you could use other render such as pyrender |
Ok! Anyway,thanks!
On 04/25/2020 20:27, Dasrio wrote:
@quyanqiu Hi~ I know there is a code which uses rasterise:
pixels = dirt.rasterise(
vertices=cube_vertices_clip,
faces=cube_faces,
vertex_colors=vertex_colors_lit,
background=tf.zeros([frame_height, frame_width, 3])*255,
width=frame_width, height=frame_height, channels=3
)
print(pixels.shape)
The output is
(480, 640, 3)
Seems like the channel is 3 too.
The code is in sample\simple.py.
you may need consult the author for more detail ,if you just need rendering instead of backward,you could use other render such as pyrender
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
@Frank-Dz You need to use
|
|
Hi,I read your texture.py code and found that in rasterise_defered function you concate vertics coordinate 、texture coordinate and vertex normal together ,but in mostly scence the dimension of vertices and texture coordinate(vt)are not the same,which means that they can not use tf.concat to concat together,for example ,in smpl body models ,there are 6890 vertics and 7576 vt coordinate,how to solve this issue?
The text was updated successfully, but these errors were encountered: