Hi,
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.
https://github.com/morethanlogic/ofxMtlMapping2D
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 ( http://forum.openframeworks.cc/t/quad-warping–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?
Thanks!
this article explains two ways of doing deformations of a quad http://www.reedbeta.com/blog/2012/05/26/quadrilateral-interpolation-part-1/
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
arturo
July 11, 2013, 9:40am
#3
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:
http://www.playmodes.com/index.php?option=com-content&view=article&id=118:warpmap-first-release-&catid=41:researchgeneral
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?
http://www.geeks3d.com/20130514/opengl-interpolation-qualifiers-glsl-tutorial/
it might work on mac opengl 2.0 using the
#extension GL_EXT_gpu_shader4 : require
flag similar to what i describe here: http://poniesandlight.com/notes/flat-shading-on-osx/
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.
@kyle
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?
@arturo
The issue Playmodes’ WarpMap seems to have too
Thanks all for your help. If you have any other info send them my way
maybe the mysterious two neglected texture coordinates might help you:
http://stackoverflow.com/questions/10832909/quad-strip-texturing-distortion
and
http://www.xyzw.us/~cass/qcoord/
with interpolation set to: perspective