I’m using Vulkan APIs to render meshes with the standard projection-view-model matrix approach. However, when translating objects, they appear tilted and distorted, always facing the camera. I don’t think this is normal, because the deformation can get pretty bad and unnatural. (Also it’s just a translation, so the objects shouldn’t rotate at all).
I obtained the current results by hardcoding the matrices directly in my vertex shader as shown below:
void main()
{
Vertex v = PushConstants.vertexBuffer.vertices[gl_VertexIndex];
vec4 position = vec4(v.position, 1.0f);
// Projection matrix
mat4 proj = mat4(
1.363963, 0.000000, 0.000000, 0.000000,
0.000000, 2.414213, 0.000000, 0.000000,
0.000000, 0.000000, -1.000200, -1.000000,
0.000000, 0.000000, -0.200020, 0.000000
);
// Translation matrix (used to position the camera)
mat4 translation = mat4(
1.000000, 0.000000, 0.000000, 0.000000,
0.000000, 1.000000, 0.000000, 0.000000,
0.000000, 0.000000, 1.000000, 0.000000,
0.000000, 0.000000, 10.000000, 1.000000
);
// Model matrix (scaling and positioning the object)
mat4 model = mat4(
0.100000, 0.000000, 0.000000, 0.000000,
0.000000, 0.100000, 0.000000, 0.000000,
0.000000, 0.000000, 0.100000, 0.000000,
-6.000000, -1.500000, 0.000000, 1.000000
);
// View matrix (inverse of the translation matrix)
mat4 view = inverse(translation);
gl_Position = proj * view * model * position;
}
What I’m missing?