According to this page: https://matthewwellings.com/blog/the-new-vulkan-coordinate-system/
The Vulkan coordinate system has:
- The X axis increasing to the right
- The Y axis increasing downwards
- The Z axis increasing into the screen
In my own my own test, I can confirm the X and Y axis. However, for me, the -Z points into the screen, not +Z. By this, I mean:
- As X increases, the scene moves to the left, because the camera moves to the right.
- As Y increases, the scene moves up, because the camera moves downwards.
- As Z increases, the scene moves away, because the camera is moving backwards.
I believe the linked page over my own learning code, so I'm not sure why I'm getting this effect.
My scene consists of a single textured quad. This is the code that I'm using:
C++
// No rotation
auto identMat = glm::mat4(1.0f);
auto rotAmount = 0.0f;
auto rotAxis = glm::vec3(0.0f, 0.0f, 1.0f);
mUBO.mModel = glm::rotate(identMat, rotAmount, rotAxis);
float eyeXPos = 0.0f;
float eyeYPos = 0.0f;
float eyeZPos = time * 1.0f;
auto eyePosition = glm::vec3(eyeXPos, eyeYPos, eyeZPos);
auto centerPosition = glm::vec3(0.0f, 0.0f, 0.0f);
auto upAxis = glm::vec3(0.0f, 1.0f, 0.0f);
mUBO.mView = glm::lookAt(eyePosition, centerPosition, upAxis);
const float kWindowWidth = 800;
const float kWindowHeight = 600;
auto verticalFOV = glm::radians(45.0f);
auto aspectRatio = kWindowWidth / kWindowHeight;
auto nearPlane = 0.1f;
auto farPlane = 100.0f;
mUBO.mProj = glm::perspective(verticalFOV, aspectRatio, nearPlane, farPlane);
Vertex Shader
layout(location = 0) in vec2 inPosition;
// ...
gl_Position = ubo.proj * ubo.view * ubo.model * vec4(inPosition, 0.0, 1.0);
------------------------ EDIT ----------------------------------
I'm not losing sleep over this, or anything like that. But, since I decided to get myself a Vulkan t-shirt, I went ahead and created a test-case for this question, in case anyone is curious enough to run it. The function name that updates the UBO is called UpdateUniformBuffer(). The code is self contained, except that it needs the GLFW library. Also, it needs an up-to-date C++ compiler (I use VS2017).
t-shirt: https://teespring.com/vulkan#pid=2&cid=2397&sid=front
main.cpp https://pastebin.com/RWpNDfjc
TestRenderer.hpp https://pastebin.com/09TTF1e3
TestRenderer.cpp https://pastebin.com/wCDV0CEk
shader.vert https://pastebin.com/fb5f4hvF
shader.frag https://pastebin.com/CCVpnmwj