Using patcht to texture map a triangle mesh in matlab

Alec Jacobson

August 09, 2013

weblog/

Recently I found the patcht script which lets you texture map a triangle mesh in matlab. It unfortunately does it in a brute force way: creating a textured surface for every triangle. But it's at least something. Here's how I use it for 2d meshes of images using the xy positions as texture coordinates:

im = imread('woody.png');
[V,F] = load_mesh('woody.obj');
patcht(F,V,F,[max(V(:,2))-V(:,2) V(:,1)],im);
axis equal

which produces:

patcht script texture mapping triangle mesh in matlab

We thank Scott Schaefer for providing the wooden gingerbread man image from "Image Deformation Using Moving Least Squares".