While working on a game project that involves 2D sprites in 3D space, applying a skew/shear effect resulted in unexpected behaviour as I overlooked (more accurately put, I temporarily forgot) that even though the sprites are in 3D space, the game is being rendered with an orthographic projection. Additionally the game is set up where the Y-axis is up. Thus the creation of this gist to act as a digital post-it note to remind myself and to allow anyone developing their own game / game engine to do the same.
The numeric order of the matricies match with the image visualizing the effects.
1) Skew along the X-Axis, relative to the Y-Axis
matrix_1[] =
{
1, 0, 0, 0,
tan(a), 1, 0, 0,
0, 0, 1, 0,
0, 0, 0, 1
};
2) Skew along the X-Axis, relative to the Z-Axis
matrix_2[] =
{
1, 0, 0, 0,
0, 1, 0, 0,
tan(a), 0, 1, 0,
0, 0, 0, 0
};
3) Skew along the Y-Axis, relative to the X-Axis
matrix_3[] =
{
1, tan(a), 0, 0,
0, 1, 0, 0,
0, 0, 1, 0,
0, 0, 0, 1
};
4) Skew along the Y-Axis, relative to the Z-Axis
matrix_4[] =
{
1, 0, 0, 0,
0, 1, 0, 0,
0, tan(a), 1, 0,
0, 0, 0, 1
};
5) Skew along the Z-Axis, relative to the X-Axis
matrix_5[] =
{
1, 0, tan(a), 0,
0, 1, 0, 0,
0, 0, 1, 0,
0, 0, 0, 1
};
6) Skew along the Z-Axis, relative to the Y-Axis
matrix_6[] =
{
1, 0, 0, 0,
0, 1, tan(a), 0,
0, 0, 1, 0,
0, 0, 0, 1
};