You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am rendering the two facades of the building obj with textures, and I have encountered some problems, such as the four vertices in the middle black area on the right are obviously wrong, and I feel that the depth value does not work, and there is no perspective effect (near large and far small), I Wondering why this is, the camera is defined with a PinholeIntrinsics with a custom focal length.Here is the code reference:
defrender(camera:kaolin.render.camera.Camera):
vertices_cam=camera.extrinsics.transform(mesh.vertices) # world-> camera vertices_img=camera.intrinsics.transform(vertices_cam)[...,0:2] # camera -> ndc# pre faceface_vertices_camera=kaolin.ops.mesh.index_vertices_by_faces(vertices_cam, mesh_faces)
face_vertices_img=kaolin.ops.mesh.index_vertices_by_faces(vertices_img,mesh_faces)
# normalface_normal_z=kaolin.ops.mesh.face_normals(face_vertices_camera,unit=True)
# uvmesh_faces_uv=kaolin.ops.mesh.index_vertices_by_faces(mesh.uvs,mesh_face_uvs_idx[0])
face_attributes=mesh_faces_uvtexture_coords,softmask,face_idx=kaolin.render.mesh.dibr_rasterization(camera.height,camera.width,face_vertices_camera[:,:,:,-1],
face_vertices_img,face_attributes,face_normal_z,
rast_backend='cuda')
softmask=torch.flip(softmask,dims=(2,)) # filp widthtexture_coords=torch.flip(texture_coords,dims=(2,))
face_idx=torch.flip(face_idx,dims=(2,))
hard_mask= (face_idx>-1)[..., None]
in_material_idx=mesh_material_assignments[0,...][face_idx]
in_material_idx[face_idx==-1] =-1# result imageimg=torch.zeros((1,camera.height,camera.width,3), dtype=torch.float, device='cuda')
fori,materialinenumerate(materials):
mask=in_material_idx==i# dense_texcoords=torch.where(mask.unsqueeze(3), texture_coords, torch.tensor(0.0).cuda())
if_texcoords[_texcoords>0].shape[0] >0:
print(f'material {i}')
pixel_val=kaolin.render.mesh.texture_mapping(_texcoords.contiguous(),
material.permute(0,3,1,2).contiguous(),mode='bilinear') # origin point in left-down sideimg[mask] =pixel_val[mask]
returntorch.clamp(img*hard_mask,0.0,1.0)
The text was updated successfully, but these errors were encountered:
I am rendering the two facades of the building obj with textures, and I have encountered some problems, such as the four vertices in the middle black area on the right are obviously wrong, and I feel that the depth value does not work, and there is no perspective effect (near large and far small), I Wondering why this is, the camera is defined with a PinholeIntrinsics with a custom focal length.Here is the code reference:
The text was updated successfully, but these errors were encountered: