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

How to output unwrapped UV texture #66

Open
SHITINGCHEN opened this issue Feb 28, 2020 · 2 comments
Open

How to output unwrapped UV texture #66

SHITINGCHEN opened this issue Feb 28, 2020 · 2 comments

Comments

@SHITINGCHEN
Copy link

It is stated in the project how to unwrap texture cylindrically. But is there a way output/extract the unwrapped texture file? It is a question related to rendering and rasterization.

@SHITINGCHEN SHITINGCHEN changed the title How to output unwrap UV texture How to output unwrapped UV texture Feb 28, 2020
@RegisWu
Copy link

RegisWu commented Jun 30, 2020

@SHITINGCHEN
Hi, I am wondering how to unwrap the UV texture cylindrically as well. May I know whether you have solved this problem? Thanks!

@patricksnape
Copy link
Contributor

Something like this?

import menpo
import menpo3d
import numpy as np

template = menpo3d.io.import_builtin_asset.james_obj()

o_c_unwrap = menpo3d.unwrap.optimal_cylindrical_unwrap(template)
unwrapped_template = o_c_unwrap.apply(template)

u_t_aspect_ratio = np.divide(*unwrapped_template.range()[:2])

u_t_clip_transform = menpo3d.rasterize.transform.model_to_clip_transform(unwrapped_template)
u_t_clip = u_t_clip_transform.apply(unwrapped_template)

u_t_im_width = 1024
r = menpo3d.rasterize.GLRasterizer(width=u_t_im_width, height=int(u_t_im_width / u_t_aspect_ratio))

u_t_image = r.rasterize_mesh(u_t_clip)

new_tcoords = u_t_clip.points[:, :2] / 2 + .5
new_textured_mesh = menpo.shape.TexturedTriMesh(template.points, new_tcoords, u_t_image, trilist=template.trilist)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants