qcMSAQuadWarper

GLSL Shader to do Quad Warping and map textures to surfaces. Created as a Quartz Composer patch which allows it to be used as a plugin for any QC compatible host. In the video below, the plugin is demonstrated in VDMX.

 

The main magic happens in the GLSL shader below.

uniform vec2 BL, BR, TL, TR;
uniform vec2 renderSize;

void main() {
   // transform from QC object coords to 0...1
   vec2 p = (vec2(gl_Vertex.x, gl_Vertex.y) + 1.) * 0.5;

   // interpolate bottom edge x coordinate
   vec2 x1 = mix(BL, BR, p.x);

   // interpolate top edge x coordinate
   vec2 x2 = mix(TL, TR, p.x);

   // interpolate y position
   p = mix(x1, x2, p.y);

   // transform from 0...1 to QC screen coords
   p = (p - 0.5) * renderSize;

   gl_Position = gl_ModelViewProjectionMatrix * vec4(p, 0, 1);
   gl_FrontColor = gl_Color;
   gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;
}

 

Download

msa_Quad Warp.qtz

 

License

Released under the MIT License

 

Acknowledgements

Paul Heckbert’s Masters Thesis – Fundamentals of Texture Mapping and Image Warping.

 

The projection mapping tutorial demo (VDMX + Quartz Composer) is inspired by deepvisual’s modul8 demo

youtube.com/watch?v=2bRfdn9lNO8