Grid / Mesh warping


I want to apply a texture to a 2D mesh, in order to do some projection mapping on an irregular surface. Something similar to what can be done in Mad Mapper

I made a while ago a mapping addon to do some simple mapping. For example, to correctly warp quad using homography.

But so far I’m unable to find the way to correctly map a 2D grid / mesh. If I approach this by using homography on each ‘cell’ of the grid I get the following result:

You can see that the chessboard texture does not correctly continue between the cell #2 and #4.

I searched the forum and found an old post describing the same issue (–homography-without-opencv/3121/7 ) but there is no reply to it.

Is homography on every quad/polygon forming the grid the correct way to do this?


this article explains two ways of doing deformations of a quad

you want to do linear interpolation, but you’re doing projective interpolation.

that said, i’m not sure how to do linear interpolation across a quad when you’re fundamentally rendering triangles… i can think of some hacks, but there is probably a “correct” solution someone else knows :slight_smile:

have you tried to create a mesh with texture coordinates for the image you want to map and then just move the vertices of the mesh?

also take a look at warpmap:

it’s done in OF, i think they wanted to release the source but not sure if they’ve done it yet

1 Like

To do linear interpolation,

kind of a shot from the hip:

have you tried to use the “noperspective” GLSL qualifier in the vertex / fragment shaders for your texture coordinates?

it might work on mac opengl 2.0 using the

#extension GL_EXT_gpu_shader4 : require  

flag similar to what i describe here:

Also, if you use the new openGl 3.2 renderer (from current develop) you should get GLSL 150 for free on a mac =)

as said, not sure it works, but it could be something relatively cheap (the flag way) to try.

Exactly, I don’t see how linear interpolation would work in that case. It would produce the issue of the seem between the two triangles?

The issue Playmodes’ WarpMap seems to have too

Thanks all for your help. If you have any other info send them my way :slight_smile:

maybe the mysterious two neglected texture coordinates might help you:


with interpolation set to: perspective