# Distort a quad with a World Matrix

Is it possible to distort a quad multiplying its vertices by a specific world matrix? See the picture to understand what kind of distortion I need:

Please note, that the quad is in 3d space and I particularly need it's VERTICES to be distorted and NOT to rotate a perspective camera. The quad is laying on a plane with Z=0, all of the quad's vertices have their Z components equal to 0 and they should have their Z component equal to 0 after the transformation.

I know that it can quite easily be done by moving the vertices in a vertex shader, but the reason why I need to distort the quad using a World matrix is because I am rendering hundreds of such quads with a single draw call. Some of them need to be distorted and some dont. So I need a uniform vertex shader for every case and before doing branching in the shader I would like to know if such distortion can be done with a World matrix.

Please note, that the quad is in 3d space and I particularly need it's VERTICES to be distorted and NOT to rotate a perspective camera. The quad is laying on a plane with Z=0, all of the quad's vertices have their Z components equal to 0 and they should have their Z component equal to 0 after the transformation.

Please note that even though you wish to dismiss a solution, it may still be valid. If you want quad's vertices to have Z=0, there's a scale matrix for that:

1 0 0 0
0 1 0 0
0 0 0 0
0 0 0 1


So, to sum up: rotate the quad, apply perspective transformation, divide by W (scale with 1/W) and flatten it along the Z axis in the end.

• snake5, could you please expand your answer? I do not know matrices superbly well, I usually use standard XNA constructors if I need to create one (e.g. Matrix.CreateRotationZ(1.8f)). I can create a rotation matrix and I know how to apply a perspective transformation matrix, but usually standard XNA perspective matrices (Matrix.CreatePerspectiveFieldOfView()) move the value range of the vertices into the view space (-1, 1). I don't know how to apply a perspective transformation wich will not move my vertices from the world space into a view space. And I don't know how to flatten with a matrix. Commented Sep 23, 2014 at 11:51
• @cubrman I meant flattening the quad, not the matrix - by scaling the vertices with a scale(1,1,0) matrix. As for perspective transformation and spaces - the spaces are made up to explain concepts. Vertices don't magically change their space, they're simply assumed to have some kind of space. Commented Sep 23, 2014 at 18:36
• Ok so I can basically mutliply my world matrix by a perspective distortion matrix? I'm gonna give it a try... Commented Sep 24, 2014 at 6:49