glm matrix initialization
This commit is contained in:
parent
e7b371eef3
commit
cd8274c294
49 changed files with 127 additions and 127 deletions
|
|
@ -20,14 +20,14 @@ private:
|
||||||
|
|
||||||
void updateViewMatrix()
|
void updateViewMatrix()
|
||||||
{
|
{
|
||||||
glm::mat4 rotM = glm::mat4();
|
glm::mat4 rotM = glm::mat4(1.0f);
|
||||||
glm::mat4 transM;
|
glm::mat4 transM;
|
||||||
|
|
||||||
rotM = glm::rotate(rotM, glm::radians(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f));
|
rotM = glm::rotate(rotM, glm::radians(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f));
|
||||||
rotM = glm::rotate(rotM, glm::radians(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f));
|
rotM = glm::rotate(rotM, glm::radians(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f));
|
||||||
rotM = glm::rotate(rotM, glm::radians(rotation.z), glm::vec3(0.0f, 0.0f, 1.0f));
|
rotM = glm::rotate(rotM, glm::radians(rotation.z), glm::vec3(0.0f, 0.0f, 1.0f));
|
||||||
|
|
||||||
transM = glm::translate(glm::mat4(), position);
|
transM = glm::translate(glm::mat4(1.0f), position);
|
||||||
|
|
||||||
if (type == CameraType::firstperson)
|
if (type == CameraType::firstperson)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -827,7 +827,7 @@ public:
|
||||||
ubos.scene.projection = camera.matrices.perspective;
|
ubos.scene.projection = camera.matrices.perspective;
|
||||||
ubos.scene.view = camera.matrices.view;
|
ubos.scene.view = camera.matrices.view;
|
||||||
|
|
||||||
ubos.scene.model = glm::translate(glm::mat4(), glm::vec3(sin(glm::radians(timer * 360.0f)) * 0.25f, -1.0f, cos(glm::radians(timer * 360.0f)) * 0.25f) + cameraPos);
|
ubos.scene.model = glm::translate(glm::mat4(1.0f), glm::vec3(sin(glm::radians(timer * 360.0f)) * 0.25f, -1.0f, cos(glm::radians(timer * 360.0f)) * 0.25f) + cameraPos);
|
||||||
ubos.scene.model = glm::rotate(ubos.scene.model, -sinf(glm::radians(timer * 360.0f)) * 0.15f, glm::vec3(1.0f, 0.0f, 0.0f));
|
ubos.scene.model = glm::rotate(ubos.scene.model, -sinf(glm::radians(timer * 360.0f)) * 0.15f, glm::vec3(1.0f, 0.0f, 0.0f));
|
||||||
ubos.scene.model = glm::rotate(ubos.scene.model, glm::radians(timer * 360.0f), glm::vec3(0.0f, 1.0f, 0.0f));
|
ubos.scene.model = glm::rotate(ubos.scene.model, glm::radians(timer * 360.0f), glm::vec3(0.0f, 1.0f, 0.0f));
|
||||||
|
|
||||||
|
|
@ -836,7 +836,7 @@ public:
|
||||||
// Skybox
|
// Skybox
|
||||||
ubos.skyBox.projection = glm::perspective(glm::radians(45.0f), (float)width / (float)height, 0.1f, 256.0f);
|
ubos.skyBox.projection = glm::perspective(glm::radians(45.0f), (float)width / (float)height, 0.1f, 256.0f);
|
||||||
ubos.skyBox.view = glm::mat4(glm::mat3(camera.matrices.view));
|
ubos.skyBox.view = glm::mat4(glm::mat3(camera.matrices.view));
|
||||||
ubos.skyBox.model = glm::mat4();
|
ubos.skyBox.model = glm::mat4(1.0f);
|
||||||
|
|
||||||
memcpy(uniformBuffers.skyBox.mapped, &ubos.skyBox, sizeof(ubos.skyBox));
|
memcpy(uniformBuffers.skyBox.mapped, &ubos.skyBox, sizeof(ubos.skyBox));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -320,7 +320,7 @@ public:
|
||||||
case 0 :
|
case 0 :
|
||||||
{
|
{
|
||||||
// Horz. cloth falls onto sphere
|
// Horz. cloth falls onto sphere
|
||||||
glm::mat4 transM = glm::translate(glm::mat4(), glm::vec3(- cloth.size.x / 2.0f, -2.0f, - cloth.size.y / 2.0f));
|
glm::mat4 transM = glm::translate(glm::mat4(1.0f), glm::vec3(- cloth.size.x / 2.0f, -2.0f, - cloth.size.y / 2.0f));
|
||||||
for (uint32_t i = 0; i < cloth.gridsize.y; i++) {
|
for (uint32_t i = 0; i < cloth.gridsize.y; i++) {
|
||||||
for (uint32_t j = 0; j < cloth.gridsize.x; j++) {
|
for (uint32_t j = 0; j < cloth.gridsize.x; j++) {
|
||||||
particleBuffer[i + j * cloth.gridsize.y].pos = transM * glm::vec4(dx * j, 0.0f, dy * i, 1.0f);
|
particleBuffer[i + j * cloth.gridsize.y].pos = transM * glm::vec4(dx * j, 0.0f, dy * i, 1.0f);
|
||||||
|
|
@ -333,7 +333,7 @@ public:
|
||||||
case 1:
|
case 1:
|
||||||
{
|
{
|
||||||
// Vert. Pinned cloth
|
// Vert. Pinned cloth
|
||||||
glm::mat4 transM = glm::translate(glm::mat4(), glm::vec3(- cloth.size.x / 2.0f, - cloth.size.y / 2.0f, 0.0f));
|
glm::mat4 transM = glm::translate(glm::mat4(1.0f), glm::vec3(- cloth.size.x / 2.0f, - cloth.size.y / 2.0f, 0.0f));
|
||||||
for (uint32_t i = 0; i < cloth.gridsize.y; i++) {
|
for (uint32_t i = 0; i < cloth.gridsize.y; i++) {
|
||||||
for (uint32_t j = 0; j < cloth.gridsize.x; j++) {
|
for (uint32_t j = 0; j < cloth.gridsize.x; j++) {
|
||||||
particleBuffer[i + j * cloth.gridsize.y].pos = transM * glm::vec4(dx * j, dy * i, 0.0f, 1.0f);
|
particleBuffer[i + j * cloth.gridsize.y].pos = transM * glm::vec4(dx * j, dy * i, 0.0f, 1.0f);
|
||||||
|
|
|
||||||
|
|
@ -728,9 +728,9 @@ public:
|
||||||
{
|
{
|
||||||
// Vertex shader uniform buffer block
|
// Vertex shader uniform buffer block
|
||||||
uboVS.projection = glm::perspective(glm::radians(60.0f), (float)width*0.5f / (float)height, 0.1f, 256.0f);
|
uboVS.projection = glm::perspective(glm::radians(60.0f), (float)width*0.5f / (float)height, 0.1f, 256.0f);
|
||||||
glm::mat4 viewMatrix = glm::translate(glm::mat4(), glm::vec3(0.0f, 0.0f, zoom));
|
glm::mat4 viewMatrix = glm::translate(glm::mat4(1.0f), glm::vec3(0.0f, 0.0f, zoom));
|
||||||
|
|
||||||
uboVS.model = viewMatrix * glm::translate(glm::mat4(), cameraPos);
|
uboVS.model = viewMatrix * glm::translate(glm::mat4(1.0f), cameraPos);
|
||||||
uboVS.model = glm::rotate(uboVS.model, glm::radians(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f));
|
uboVS.model = glm::rotate(uboVS.model, glm::radians(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f));
|
||||||
uboVS.model = glm::rotate(uboVS.model, glm::radians(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f));
|
uboVS.model = glm::rotate(uboVS.model, glm::radians(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f));
|
||||||
uboVS.model = glm::rotate(uboVS.model, glm::radians(rotation.z), glm::vec3(0.0f, 0.0f, 1.0f));
|
uboVS.model = glm::rotate(uboVS.model, glm::radians(rotation.z), glm::vec3(0.0f, 0.0f, 1.0f));
|
||||||
|
|
|
||||||
|
|
@ -893,9 +893,9 @@ public:
|
||||||
void updateUniformBuffers()
|
void updateUniformBuffers()
|
||||||
{
|
{
|
||||||
uboVS.projection = glm::perspective(glm::radians(60.0f), (float)width / (float)height, 0.1f, 256.0f);
|
uboVS.projection = glm::perspective(glm::radians(60.0f), (float)width / (float)height, 0.1f, 256.0f);
|
||||||
glm::mat4 viewMatrix = glm::translate(glm::mat4(), glm::vec3(0.0f, 0.0f, zoom));
|
glm::mat4 viewMatrix = glm::translate(glm::mat4(1.0f), glm::vec3(0.0f, 0.0f, zoom));
|
||||||
|
|
||||||
uboVS.model = viewMatrix * glm::translate(glm::mat4(), cameraPos);
|
uboVS.model = viewMatrix * glm::translate(glm::mat4(1.0f), cameraPos);
|
||||||
uboVS.model = glm::rotate(uboVS.model, glm::radians(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f));
|
uboVS.model = glm::rotate(uboVS.model, glm::radians(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f));
|
||||||
uboVS.model = glm::rotate(uboVS.model, glm::radians(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f));
|
uboVS.model = glm::rotate(uboVS.model, glm::radians(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f));
|
||||||
uboVS.model = glm::rotate(uboVS.model, glm::radians(rotation.z), glm::vec3(0.0f, 0.0f, 1.0f));
|
uboVS.model = glm::rotate(uboVS.model, glm::radians(rotation.z), glm::vec3(0.0f, 0.0f, 1.0f));
|
||||||
|
|
|
||||||
|
|
@ -1061,7 +1061,7 @@ public:
|
||||||
{
|
{
|
||||||
uboVS.projection = glm::ortho(0.0f, 1.0f, 0.0f, 1.0f, -1.0f, 1.0f);
|
uboVS.projection = glm::ortho(0.0f, 1.0f, 0.0f, 1.0f, -1.0f, 1.0f);
|
||||||
}
|
}
|
||||||
uboVS.model = glm::mat4();
|
uboVS.model = glm::mat4(1.0f);
|
||||||
|
|
||||||
memcpy(uniformBuffers.vsFullScreen.mapped, &uboVS, sizeof(uboVS));
|
memcpy(uniformBuffers.vsFullScreen.mapped, &uboVS, sizeof(uboVS));
|
||||||
}
|
}
|
||||||
|
|
@ -1070,7 +1070,7 @@ public:
|
||||||
{
|
{
|
||||||
uboOffscreenVS.projection = camera.matrices.perspective;
|
uboOffscreenVS.projection = camera.matrices.perspective;
|
||||||
uboOffscreenVS.view = camera.matrices.view;
|
uboOffscreenVS.view = camera.matrices.view;
|
||||||
uboOffscreenVS.model = glm::mat4();
|
uboOffscreenVS.model = glm::mat4(1.0f);
|
||||||
|
|
||||||
memcpy(uniformBuffers.vsOffscreen.mapped, &uboOffscreenVS, sizeof(uboOffscreenVS));
|
memcpy(uniformBuffers.vsOffscreen.mapped, &uboOffscreenVS, sizeof(uboOffscreenVS));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1039,7 +1039,7 @@ public:
|
||||||
{
|
{
|
||||||
uboVS.projection = glm::ortho(0.0f, 1.0f, 0.0f, 1.0f, -1.0f, 1.0f);
|
uboVS.projection = glm::ortho(0.0f, 1.0f, 0.0f, 1.0f, -1.0f, 1.0f);
|
||||||
}
|
}
|
||||||
uboVS.model = glm::mat4();
|
uboVS.model = glm::mat4(1.0f);
|
||||||
|
|
||||||
memcpy(uniformBuffers.vsFullScreen.mapped, &uboVS, sizeof(uboVS));
|
memcpy(uniformBuffers.vsFullScreen.mapped, &uboVS, sizeof(uboVS));
|
||||||
}
|
}
|
||||||
|
|
@ -1047,17 +1047,17 @@ public:
|
||||||
void updateUniformBufferDeferredMatrices()
|
void updateUniformBufferDeferredMatrices()
|
||||||
{
|
{
|
||||||
uboOffscreenVS.projection = glm::perspective(glm::radians(45.0f), (float)width / (float)height, 0.1f, 256.0f);
|
uboOffscreenVS.projection = glm::perspective(glm::radians(45.0f), (float)width / (float)height, 0.1f, 256.0f);
|
||||||
uboOffscreenVS.view = glm::translate(glm::mat4(), glm::vec3(0.0f, 0.0f, zoom));
|
uboOffscreenVS.view = glm::translate(glm::mat4(1.0f), glm::vec3(0.0f, 0.0f, zoom));
|
||||||
|
|
||||||
uboOffscreenVS.model = glm::mat4();
|
uboOffscreenVS.model = glm::mat4(1.0f);
|
||||||
uboOffscreenVS.model = glm::translate(glm::mat4(), glm::vec3(0.0f, 0.25f, 0.0f) + cameraPos);
|
uboOffscreenVS.model = glm::translate(glm::mat4(1.0f), glm::vec3(0.0f, 0.25f, 0.0f) + cameraPos);
|
||||||
uboOffscreenVS.model = glm::rotate(uboOffscreenVS.model, glm::radians(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f));
|
uboOffscreenVS.model = glm::rotate(uboOffscreenVS.model, glm::radians(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f));
|
||||||
uboOffscreenVS.model = glm::rotate(uboOffscreenVS.model, glm::radians(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f));
|
uboOffscreenVS.model = glm::rotate(uboOffscreenVS.model, glm::radians(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f));
|
||||||
uboOffscreenVS.model = glm::rotate(uboOffscreenVS.model, glm::radians(rotation.z), glm::vec3(0.0f, 0.0f, 1.0f));
|
uboOffscreenVS.model = glm::rotate(uboOffscreenVS.model, glm::radians(rotation.z), glm::vec3(0.0f, 0.0f, 1.0f));
|
||||||
|
|
||||||
uboOffscreenVS.projection = camera.matrices.perspective;
|
uboOffscreenVS.projection = camera.matrices.perspective;
|
||||||
uboOffscreenVS.view = camera.matrices.view;
|
uboOffscreenVS.view = camera.matrices.view;
|
||||||
uboOffscreenVS.model = glm::mat4();
|
uboOffscreenVS.model = glm::mat4(1.0f);
|
||||||
|
|
||||||
memcpy(uniformBuffers.vsOffscreen.mapped, &uboOffscreenVS, sizeof(uboOffscreenVS));
|
memcpy(uniformBuffers.vsOffscreen.mapped, &uboOffscreenVS, sizeof(uboOffscreenVS));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1042,7 +1042,7 @@ public:
|
||||||
void updateUniformBuffersScreen()
|
void updateUniformBuffersScreen()
|
||||||
{
|
{
|
||||||
uboVS.projection = glm::ortho(0.0f, 1.0f, 0.0f, 1.0f, -1.0f, 1.0f);
|
uboVS.projection = glm::ortho(0.0f, 1.0f, 0.0f, 1.0f, -1.0f, 1.0f);
|
||||||
uboVS.model = glm::mat4();
|
uboVS.model = glm::mat4(1.0f);
|
||||||
memcpy(uniformBuffers.vsFullScreen.mapped, &uboVS, sizeof(uboVS));
|
memcpy(uniformBuffers.vsFullScreen.mapped, &uboVS, sizeof(uboVS));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1050,7 +1050,7 @@ public:
|
||||||
{
|
{
|
||||||
uboOffscreenVS.projection = camera.matrices.perspective;
|
uboOffscreenVS.projection = camera.matrices.perspective;
|
||||||
uboOffscreenVS.view = camera.matrices.view;
|
uboOffscreenVS.view = camera.matrices.view;
|
||||||
uboOffscreenVS.model = glm::mat4();
|
uboOffscreenVS.model = glm::mat4(1.0f);
|
||||||
memcpy(uniformBuffers.vsOffscreen.mapped, &uboOffscreenVS, sizeof(uboOffscreenVS));
|
memcpy(uniformBuffers.vsOffscreen.mapped, &uboOffscreenVS, sizeof(uboOffscreenVS));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1091,7 +1091,7 @@ public:
|
||||||
// mvp from light's pov (for shadows)
|
// mvp from light's pov (for shadows)
|
||||||
glm::mat4 shadowProj = glm::perspective(glm::radians(lightFOV), 1.0f, zNear, zFar);
|
glm::mat4 shadowProj = glm::perspective(glm::radians(lightFOV), 1.0f, zNear, zFar);
|
||||||
glm::mat4 shadowView = glm::lookAt(glm::vec3(uboFragmentLights.lights[i].position), glm::vec3(uboFragmentLights.lights[i].target), glm::vec3(0.0f, 1.0f, 0.0f));
|
glm::mat4 shadowView = glm::lookAt(glm::vec3(uboFragmentLights.lights[i].position), glm::vec3(uboFragmentLights.lights[i].target), glm::vec3(0.0f, 1.0f, 0.0f));
|
||||||
glm::mat4 shadowModel = glm::mat4();
|
glm::mat4 shadowModel = glm::mat4(1.0f);
|
||||||
|
|
||||||
uboShadowGS.mvp[i] = shadowProj * shadowView * shadowModel;
|
uboShadowGS.mvp[i] = shadowProj * shadowView * shadowModel;
|
||||||
uboFragmentLights.lights[i].viewMatrix = uboShadowGS.mvp[i];
|
uboFragmentLights.lights[i].viewMatrix = uboShadowGS.mvp[i];
|
||||||
|
|
|
||||||
|
|
@ -468,11 +468,11 @@ public:
|
||||||
void updateUniformBuffers()
|
void updateUniformBuffers()
|
||||||
{
|
{
|
||||||
// Tessellation eval
|
// Tessellation eval
|
||||||
glm::mat4 viewMatrix = glm::mat4();
|
glm::mat4 viewMatrix = glm::mat4(1.0f);
|
||||||
uboTessEval.projection = glm::perspective(glm::radians(45.0f), (float)(width) / (float)height, 0.1f, 256.0f);
|
uboTessEval.projection = glm::perspective(glm::radians(45.0f), (float)(width) / (float)height, 0.1f, 256.0f);
|
||||||
viewMatrix = glm::translate(viewMatrix, glm::vec3(0.0f, 0.0f, zoom));
|
viewMatrix = glm::translate(viewMatrix, glm::vec3(0.0f, 0.0f, zoom));
|
||||||
|
|
||||||
uboTessEval.model = glm::mat4();
|
uboTessEval.model = glm::mat4(1.0f);
|
||||||
uboTessEval.model = viewMatrix * glm::translate(uboTessEval.model, glm::vec3(0, 0, 0));
|
uboTessEval.model = viewMatrix * glm::translate(uboTessEval.model, glm::vec3(0, 0, 0));
|
||||||
uboTessEval.model = glm::rotate(uboTessEval.model, glm::radians(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f));
|
uboTessEval.model = glm::rotate(uboTessEval.model, glm::radians(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f));
|
||||||
uboTessEval.model = glm::rotate(uboTessEval.model, glm::radians(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f));
|
uboTessEval.model = glm::rotate(uboTessEval.model, glm::radians(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f));
|
||||||
|
|
|
||||||
|
|
@ -617,11 +617,11 @@ public:
|
||||||
void updateUniformBuffers()
|
void updateUniformBuffers()
|
||||||
{
|
{
|
||||||
// Vertex shader
|
// Vertex shader
|
||||||
glm::mat4 viewMatrix = glm::mat4();
|
glm::mat4 viewMatrix = glm::mat4(1.0f);
|
||||||
uboVS.projection = glm::perspective(glm::radians(splitScreen ? 30.0f : 45.0f), (float)width / (float)(height * ((splitScreen) ? 0.5f : 1.0f)), 0.001f, 256.0f);
|
uboVS.projection = glm::perspective(glm::radians(splitScreen ? 30.0f : 45.0f), (float)width / (float)(height * ((splitScreen) ? 0.5f : 1.0f)), 0.001f, 256.0f);
|
||||||
viewMatrix = glm::translate(viewMatrix, glm::vec3(0.0f, 0.0f, splitScreen ? zoom : zoom - 2.0f));
|
viewMatrix = glm::translate(viewMatrix, glm::vec3(0.0f, 0.0f, splitScreen ? zoom : zoom - 2.0f));
|
||||||
|
|
||||||
uboVS.model = glm::mat4();
|
uboVS.model = glm::mat4(1.0f);
|
||||||
uboVS.model = viewMatrix * glm::translate(uboVS.model, cameraPos);
|
uboVS.model = viewMatrix * glm::translate(uboVS.model, cameraPos);
|
||||||
uboVS.model = glm::rotate(uboVS.model, glm::radians(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f));
|
uboVS.model = glm::rotate(uboVS.model, glm::radians(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f));
|
||||||
uboVS.model = glm::rotate(uboVS.model, glm::radians(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f));
|
uboVS.model = glm::rotate(uboVS.model, glm::radians(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f));
|
||||||
|
|
|
||||||
|
|
@ -492,7 +492,7 @@ public:
|
||||||
|
|
||||||
// Update matrices
|
// Update matrices
|
||||||
glm::vec3 pos = glm::vec3(-((dim * offset.x) / 2.0f) + offset.x / 2.0f + x * offset.x, -((dim * offset.y) / 2.0f) + offset.y / 2.0f + y * offset.y, -((dim * offset.z) / 2.0f) + offset.z / 2.0f + z * offset.z);
|
glm::vec3 pos = glm::vec3(-((dim * offset.x) / 2.0f) + offset.x / 2.0f + x * offset.x, -((dim * offset.y) / 2.0f) + offset.y / 2.0f + y * offset.y, -((dim * offset.z) / 2.0f) + offset.z / 2.0f + z * offset.z);
|
||||||
*modelMat = glm::translate(glm::mat4(), pos);
|
*modelMat = glm::translate(glm::mat4(1.0f), pos);
|
||||||
*modelMat = glm::rotate(*modelMat, rotations[index].x, glm::vec3(1.0f, 1.0f, 0.0f));
|
*modelMat = glm::rotate(*modelMat, rotations[index].x, glm::vec3(1.0f, 1.0f, 0.0f));
|
||||||
*modelMat = glm::rotate(*modelMat, rotations[index].y, glm::vec3(0.0f, 1.0f, 0.0f));
|
*modelMat = glm::rotate(*modelMat, rotations[index].y, glm::vec3(0.0f, 1.0f, 0.0f));
|
||||||
*modelMat = glm::rotate(*modelMat, rotations[index].z, glm::vec3(0.0f, 0.0f, 1.0f));
|
*modelMat = glm::rotate(*modelMat, rotations[index].z, glm::vec3(0.0f, 0.0f, 1.0f));
|
||||||
|
|
|
||||||
|
|
@ -277,7 +277,7 @@ void VulkanGear::updateUniformBuffer(glm::mat4 perspective, glm::vec3 rotation,
|
||||||
ubo.view = glm::rotate(ubo.view, glm::radians(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f));
|
ubo.view = glm::rotate(ubo.view, glm::radians(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f));
|
||||||
ubo.view = glm::rotate(ubo.view, glm::radians(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f));
|
ubo.view = glm::rotate(ubo.view, glm::radians(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f));
|
||||||
|
|
||||||
ubo.model = glm::mat4();
|
ubo.model = glm::mat4(1.0f);
|
||||||
ubo.model = glm::translate(ubo.model, pos);
|
ubo.model = glm::translate(ubo.model, pos);
|
||||||
rotation.z = (rotSpeed * timer) + rotOffset;
|
rotation.z = (rotSpeed * timer) + rotOffset;
|
||||||
ubo.model = glm::rotate(ubo.model, glm::radians(rotation.z), glm::vec3(0.0f, 0.0f, 1.0f));
|
ubo.model = glm::rotate(ubo.model, glm::radians(rotation.z), glm::vec3(0.0f, 0.0f, 1.0f));
|
||||||
|
|
|
||||||
|
|
@ -417,8 +417,8 @@ public:
|
||||||
{
|
{
|
||||||
// Vertex shader
|
// Vertex shader
|
||||||
uboVS.projection = glm::perspective(glm::radians(60.0f), (float)width / (float)height, 0.001f, 256.0f);
|
uboVS.projection = glm::perspective(glm::radians(60.0f), (float)width / (float)height, 0.001f, 256.0f);
|
||||||
glm::mat4 viewMatrix = glm::translate(glm::mat4(), glm::vec3(0.0f, 0.0f, zoom));
|
glm::mat4 viewMatrix = glm::translate(glm::mat4(1.0f), glm::vec3(0.0f, 0.0f, zoom));
|
||||||
uboVS.model = viewMatrix * glm::translate(glm::mat4(), cameraPos);
|
uboVS.model = viewMatrix * glm::translate(glm::mat4(1.0f), cameraPos);
|
||||||
uboVS.model = glm::rotate(uboVS.model, glm::radians(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f));
|
uboVS.model = glm::rotate(uboVS.model, glm::radians(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f));
|
||||||
uboVS.model = glm::rotate(uboVS.model, glm::radians(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f));
|
uboVS.model = glm::rotate(uboVS.model, glm::radians(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f));
|
||||||
uboVS.model = glm::rotate(uboVS.model, glm::radians(rotation.z), glm::vec3(0.0f, 0.0f, 1.0f));
|
uboVS.model = glm::rotate(uboVS.model, glm::radians(rotation.z), glm::vec3(0.0f, 0.0f, 1.0f));
|
||||||
|
|
|
||||||
|
|
@ -718,7 +718,7 @@ public:
|
||||||
{
|
{
|
||||||
// Vertex shader
|
// Vertex shader
|
||||||
uboVS.projection = camera.matrices.perspective;
|
uboVS.projection = camera.matrices.perspective;
|
||||||
uboVS.modelview = camera.matrices.view * glm::mat4();
|
uboVS.modelview = camera.matrices.view * glm::mat4(1.0f);
|
||||||
|
|
||||||
// Light source
|
// Light source
|
||||||
if (uiSettings.animateLight) {
|
if (uiSettings.animateLight) {
|
||||||
|
|
|
||||||
|
|
@ -545,7 +545,7 @@ public:
|
||||||
if (viewChanged)
|
if (viewChanged)
|
||||||
{
|
{
|
||||||
uboVS.projection = glm::perspective(glm::radians(60.0f), (float)width / (float)height, 0.1f, 256.0f);
|
uboVS.projection = glm::perspective(glm::radians(60.0f), (float)width / (float)height, 0.1f, 256.0f);
|
||||||
uboVS.view = glm::translate(glm::mat4(), cameraPos + glm::vec3(0.0f, 0.0f, zoom));
|
uboVS.view = glm::translate(glm::mat4(1.0f), cameraPos + glm::vec3(0.0f, 0.0f, zoom));
|
||||||
uboVS.view = glm::rotate(uboVS.view, glm::radians(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f));
|
uboVS.view = glm::rotate(uboVS.view, glm::radians(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f));
|
||||||
uboVS.view = glm::rotate(uboVS.view, glm::radians(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f));
|
uboVS.view = glm::rotate(uboVS.view, glm::radians(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f));
|
||||||
uboVS.view = glm::rotate(uboVS.view, glm::radians(rotation.z), glm::vec3(0.0f, 0.0f, 1.0f));
|
uboVS.view = glm::rotate(uboVS.view, glm::radians(rotation.z), glm::vec3(0.0f, 0.0f, 1.0f));
|
||||||
|
|
|
||||||
|
|
@ -613,9 +613,9 @@ public:
|
||||||
void updateUniformBuffers()
|
void updateUniformBuffers()
|
||||||
{
|
{
|
||||||
uboVS.projection = glm::perspective(glm::radians(60.0f), (float)width / (float)height, 0.1f, 256.0f);
|
uboVS.projection = glm::perspective(glm::radians(60.0f), (float)width / (float)height, 0.1f, 256.0f);
|
||||||
glm::mat4 viewMatrix = glm::translate(glm::mat4(), glm::vec3(0.0f, 0.0f, zoom));
|
glm::mat4 viewMatrix = glm::translate(glm::mat4(1.0f), glm::vec3(0.0f, 0.0f, zoom));
|
||||||
|
|
||||||
uboVS.model = viewMatrix * glm::translate(glm::mat4(), cameraPos);
|
uboVS.model = viewMatrix * glm::translate(glm::mat4(1.0f), cameraPos);
|
||||||
uboVS.model = glm::rotate(uboVS.model, glm::radians(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f));
|
uboVS.model = glm::rotate(uboVS.model, glm::radians(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f));
|
||||||
uboVS.model = glm::rotate(uboVS.model, glm::radians(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f));
|
uboVS.model = glm::rotate(uboVS.model, glm::radians(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f));
|
||||||
uboVS.model = glm::rotate(uboVS.model, glm::radians(rotation.z), glm::vec3(0.0f, 0.0f, 1.0f));
|
uboVS.model = glm::rotate(uboVS.model, glm::radians(rotation.z), glm::vec3(0.0f, 0.0f, 1.0f));
|
||||||
|
|
|
||||||
|
|
@ -662,13 +662,13 @@ public:
|
||||||
void updateUniformBuffers()
|
void updateUniformBuffers()
|
||||||
{
|
{
|
||||||
// Vertex shader
|
// Vertex shader
|
||||||
glm::mat4 viewMatrix = glm::mat4();
|
glm::mat4 viewMatrix = glm::mat4(1.0f);
|
||||||
uboVS.projection = glm::perspective(glm::radians(60.0f), (float)width / (float)height, 0.1f, 256.0f);
|
uboVS.projection = glm::perspective(glm::radians(60.0f), (float)width / (float)height, 0.1f, 256.0f);
|
||||||
viewMatrix = glm::translate(viewMatrix, glm::vec3(0.0f, 0.0f, zoom));
|
viewMatrix = glm::translate(viewMatrix, glm::vec3(0.0f, 0.0f, zoom));
|
||||||
|
|
||||||
float offset = 0.5f;
|
float offset = 0.5f;
|
||||||
int uboIndex = 1;
|
int uboIndex = 1;
|
||||||
uboVS.model = glm::mat4();
|
uboVS.model = glm::mat4(1.0f);
|
||||||
uboVS.model = viewMatrix * glm::translate(uboVS.model, cameraPos);
|
uboVS.model = viewMatrix * glm::translate(uboVS.model, cameraPos);
|
||||||
uboVS.model = glm::rotate(uboVS.model, glm::radians(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f));
|
uboVS.model = glm::rotate(uboVS.model, glm::radians(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f));
|
||||||
uboVS.model = glm::rotate(uboVS.model, glm::radians(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f));
|
uboVS.model = glm::rotate(uboVS.model, glm::radians(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f));
|
||||||
|
|
|
||||||
|
|
@ -278,7 +278,7 @@ public:
|
||||||
objectData->deltaT -= 1.0f;
|
objectData->deltaT -= 1.0f;
|
||||||
objectData->pos.y = sin(glm::radians(objectData->deltaT * 360.0f)) * 2.5f;
|
objectData->pos.y = sin(glm::radians(objectData->deltaT * 360.0f)) * 2.5f;
|
||||||
|
|
||||||
objectData->model = glm::translate(glm::mat4(), objectData->pos);
|
objectData->model = glm::translate(glm::mat4(1.0f), objectData->pos);
|
||||||
objectData->model = glm::rotate(objectData->model, -sinf(glm::radians(objectData->deltaT * 360.0f)) * 0.25f, glm::vec3(objectData->rotationDir, 0.0f, 0.0f));
|
objectData->model = glm::rotate(objectData->model, -sinf(glm::radians(objectData->deltaT * 360.0f)) * 0.25f, glm::vec3(objectData->rotationDir, 0.0f, 0.0f));
|
||||||
objectData->model = glm::rotate(objectData->model, glm::radians(objectData->rotation.y), glm::vec3(0.0f, objectData->rotationDir, 0.0f));
|
objectData->model = glm::rotate(objectData->model, glm::radians(objectData->rotation.y), glm::vec3(0.0f, objectData->rotationDir, 0.0f));
|
||||||
objectData->model = glm::rotate(objectData->model, glm::radians(objectData->deltaT * 360.0f), glm::vec3(0.0f, objectData->rotationDir, 0.0f));
|
objectData->model = glm::rotate(objectData->model, glm::radians(objectData->deltaT * 360.0f), glm::vec3(0.0f, objectData->rotationDir, 0.0f));
|
||||||
|
|
@ -321,7 +321,7 @@ public:
|
||||||
|
|
||||||
vkCmdBindPipeline(secondaryCommandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, pipelines.starsphere);
|
vkCmdBindPipeline(secondaryCommandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, pipelines.starsphere);
|
||||||
|
|
||||||
glm::mat4 view = glm::mat4();
|
glm::mat4 view = glm::mat4(1.0f);
|
||||||
view = glm::rotate(view, glm::radians(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f));
|
view = glm::rotate(view, glm::radians(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f));
|
||||||
view = glm::rotate(view, glm::radians(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f));
|
view = glm::rotate(view, glm::radians(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f));
|
||||||
view = glm::rotate(view, glm::radians(rotation.z), glm::vec3(0.0f, 0.0f, 1.0f));
|
view = glm::rotate(view, glm::radians(rotation.z), glm::vec3(0.0f, 0.0f, 1.0f));
|
||||||
|
|
@ -572,7 +572,7 @@ public:
|
||||||
void updateMatrices()
|
void updateMatrices()
|
||||||
{
|
{
|
||||||
matrices.projection = glm::perspective(glm::radians(60.0f), (float)width / (float)height, 0.1f, 256.0f);
|
matrices.projection = glm::perspective(glm::radians(60.0f), (float)width / (float)height, 0.1f, 256.0f);
|
||||||
matrices.view = glm::translate(glm::mat4(), glm::vec3(0.0f, 0.0f, zoom));
|
matrices.view = glm::translate(glm::mat4(1.0f), glm::vec3(0.0f, 0.0f, zoom));
|
||||||
matrices.view = glm::rotate(matrices.view, glm::radians(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f));
|
matrices.view = glm::rotate(matrices.view, glm::radians(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f));
|
||||||
matrices.view = glm::rotate(matrices.view, glm::radians(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f));
|
matrices.view = glm::rotate(matrices.view, glm::radians(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f));
|
||||||
matrices.view = glm::rotate(matrices.view, glm::radians(rotation.z), glm::vec3(0.0f, 0.0f, 1.0f));
|
matrices.view = glm::rotate(matrices.view, glm::radians(rotation.z), glm::vec3(0.0f, 0.0f, 1.0f));
|
||||||
|
|
|
||||||
|
|
@ -218,7 +218,7 @@ public:
|
||||||
|
|
||||||
VkDeviceSize offsets[1] = { 0 };
|
VkDeviceSize offsets[1] = { 0 };
|
||||||
|
|
||||||
glm::mat4 modelMatrix = glm::mat4();
|
glm::mat4 modelMatrix = glm::mat4(1.0f);
|
||||||
|
|
||||||
// Occlusion pass
|
// Occlusion pass
|
||||||
vkCmdBindPipeline(drawCmdBuffers[i], VK_PIPELINE_BIND_POINT_GRAPHICS, pipelines.simple);
|
vkCmdBindPipeline(drawCmdBuffers[i], VK_PIPELINE_BIND_POINT_GRAPHICS, pipelines.simple);
|
||||||
|
|
@ -572,9 +572,9 @@ public:
|
||||||
{
|
{
|
||||||
// Vertex shader
|
// Vertex shader
|
||||||
uboVS.projection = glm::perspective(glm::radians(60.0f), (float)width / (float)height, 0.1f, 256.0f);
|
uboVS.projection = glm::perspective(glm::radians(60.0f), (float)width / (float)height, 0.1f, 256.0f);
|
||||||
glm::mat4 viewMatrix = glm::translate(glm::mat4(), glm::vec3(0.0f, 0.0f, zoom));
|
glm::mat4 viewMatrix = glm::translate(glm::mat4(1.0f), glm::vec3(0.0f, 0.0f, zoom));
|
||||||
|
|
||||||
glm::mat4 rotMatrix = glm::mat4();
|
glm::mat4 rotMatrix = glm::mat4(1.0f);
|
||||||
rotMatrix = glm::rotate(rotMatrix, glm::radians(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f));
|
rotMatrix = glm::rotate(rotMatrix, glm::radians(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f));
|
||||||
rotMatrix = glm::rotate(rotMatrix, glm::radians(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f));
|
rotMatrix = glm::rotate(rotMatrix, glm::radians(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f));
|
||||||
rotMatrix = glm::rotate(rotMatrix, glm::radians(rotation.z), glm::vec3(0.0f, 0.0f, 1.0f));
|
rotMatrix = glm::rotate(rotMatrix, glm::radians(rotation.z), glm::vec3(0.0f, 0.0f, 1.0f));
|
||||||
|
|
@ -590,13 +590,13 @@ public:
|
||||||
// Teapot
|
// Teapot
|
||||||
// Toggle color depending on visibility
|
// Toggle color depending on visibility
|
||||||
uboVS.visible = (passedSamples[0] > 0) ? 1.0f : 0.0f;
|
uboVS.visible = (passedSamples[0] > 0) ? 1.0f : 0.0f;
|
||||||
uboVS.model = viewMatrix * rotMatrix * glm::translate(glm::mat4(), glm::vec3(0.0f, 0.0f, -10.0f));
|
uboVS.model = viewMatrix * rotMatrix * glm::translate(glm::mat4(1.0f), glm::vec3(0.0f, 0.0f, -10.0f));
|
||||||
memcpy(uniformBuffers.teapot.mapped, &uboVS, sizeof(uboVS));
|
memcpy(uniformBuffers.teapot.mapped, &uboVS, sizeof(uboVS));
|
||||||
|
|
||||||
// Sphere
|
// Sphere
|
||||||
// Toggle color depending on visibility
|
// Toggle color depending on visibility
|
||||||
uboVS.visible = (passedSamples[1] > 0) ? 1.0f : 0.0f;
|
uboVS.visible = (passedSamples[1] > 0) ? 1.0f : 0.0f;
|
||||||
uboVS.model = viewMatrix * rotMatrix * glm::translate(glm::mat4(), glm::vec3(0.0f, 0.0f, 10.0f));
|
uboVS.model = viewMatrix * rotMatrix * glm::translate(glm::mat4(1.0f), glm::vec3(0.0f, 0.0f, 10.0f));
|
||||||
memcpy(uniformBuffers.sphere.mapped, &uboVS, sizeof(uboVS));
|
memcpy(uniformBuffers.sphere.mapped, &uboVS, sizeof(uboVS));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -873,9 +873,9 @@ public:
|
||||||
{
|
{
|
||||||
// Mesh
|
// Mesh
|
||||||
uboShared.projection = glm::perspective(glm::radians(60.0f), (float)width / (float)height, 0.1f, 256.0f);
|
uboShared.projection = glm::perspective(glm::radians(60.0f), (float)width / (float)height, 0.1f, 256.0f);
|
||||||
glm::mat4 viewMatrix = glm::translate(glm::mat4(), glm::vec3(0.0f, 0.0f, zoom));
|
glm::mat4 viewMatrix = glm::translate(glm::mat4(1.0f), glm::vec3(0.0f, 0.0f, zoom));
|
||||||
|
|
||||||
uboShared.model = viewMatrix * glm::translate(glm::mat4(), cameraPos);
|
uboShared.model = viewMatrix * glm::translate(glm::mat4(1.0f), cameraPos);
|
||||||
uboShared.model = glm::rotate(uboShared.model, glm::radians(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f));
|
uboShared.model = glm::rotate(uboShared.model, glm::radians(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f));
|
||||||
uboShared.model = glm::rotate(uboShared.model, glm::radians(rotation.y + meshRot.y), glm::vec3(0.0f, 1.0f, 0.0f));
|
uboShared.model = glm::rotate(uboShared.model, glm::radians(rotation.y + meshRot.y), glm::vec3(0.0f, 1.0f, 0.0f));
|
||||||
uboShared.model = glm::rotate(uboShared.model, glm::radians(rotation.z), glm::vec3(0.0f, 0.0f, 1.0f));
|
uboShared.model = glm::rotate(uboShared.model, glm::radians(rotation.z), glm::vec3(0.0f, 0.0f, 1.0f));
|
||||||
|
|
@ -885,7 +885,7 @@ public:
|
||||||
memcpy(uniformBuffers.vsShared.mapped, &uboShared, sizeof(uboShared));
|
memcpy(uniformBuffers.vsShared.mapped, &uboShared, sizeof(uboShared));
|
||||||
|
|
||||||
// Mirror
|
// Mirror
|
||||||
uboShared.model = viewMatrix * glm::translate(glm::mat4(), cameraPos);
|
uboShared.model = viewMatrix * glm::translate(glm::mat4(1.0f), cameraPos);
|
||||||
uboShared.model = glm::rotate(uboShared.model, glm::radians(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f));
|
uboShared.model = glm::rotate(uboShared.model, glm::radians(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f));
|
||||||
uboShared.model = glm::rotate(uboShared.model, glm::radians(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f));
|
uboShared.model = glm::rotate(uboShared.model, glm::radians(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f));
|
||||||
uboShared.model = glm::rotate(uboShared.model, glm::radians(rotation.z), glm::vec3(0.0f, 0.0f, 1.0f));
|
uboShared.model = glm::rotate(uboShared.model, glm::radians(rotation.z), glm::vec3(0.0f, 0.0f, 1.0f));
|
||||||
|
|
@ -894,7 +894,7 @@ public:
|
||||||
|
|
||||||
// Debug quad
|
// Debug quad
|
||||||
uboShared.projection = glm::ortho(4.0f, 0.0f, 0.0f, 4.0f*(float)height / (float)width, -1.0f, 1.0f);
|
uboShared.projection = glm::ortho(4.0f, 0.0f, 0.0f, 4.0f*(float)height / (float)width, -1.0f, 1.0f);
|
||||||
uboShared.model = glm::translate(glm::mat4(), glm::vec3(0.0f, 0.0f, 0.0f));
|
uboShared.model = glm::translate(glm::mat4(1.0f), glm::vec3(0.0f, 0.0f, 0.0f));
|
||||||
|
|
||||||
memcpy(uniformBuffers.vsDebugQuad.mapped, &uboShared, sizeof(uboShared));
|
memcpy(uniformBuffers.vsDebugQuad.mapped, &uboShared, sizeof(uboShared));
|
||||||
}
|
}
|
||||||
|
|
@ -902,9 +902,9 @@ public:
|
||||||
void updateUniformBufferOffscreen()
|
void updateUniformBufferOffscreen()
|
||||||
{
|
{
|
||||||
uboShared.projection = glm::perspective(glm::radians(60.0f), (float)width / (float)height, 0.1f, 256.0f);
|
uboShared.projection = glm::perspective(glm::radians(60.0f), (float)width / (float)height, 0.1f, 256.0f);
|
||||||
glm::mat4 viewMatrix = glm::translate(glm::mat4(), glm::vec3(0.0f, 0.0f, zoom));
|
glm::mat4 viewMatrix = glm::translate(glm::mat4(1.0f), glm::vec3(0.0f, 0.0f, zoom));
|
||||||
|
|
||||||
uboShared.model = viewMatrix * glm::translate(glm::mat4(), cameraPos);
|
uboShared.model = viewMatrix * glm::translate(glm::mat4(1.0f), cameraPos);
|
||||||
uboShared.model = glm::rotate(uboShared.model, glm::radians(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f));
|
uboShared.model = glm::rotate(uboShared.model, glm::radians(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f));
|
||||||
uboShared.model = glm::rotate(uboShared.model, glm::radians(rotation.y + meshRot.y), glm::vec3(0.0f, 1.0f, 0.0f));
|
uboShared.model = glm::rotate(uboShared.model, glm::radians(rotation.y + meshRot.y), glm::vec3(0.0f, 1.0f, 0.0f));
|
||||||
uboShared.model = glm::rotate(uboShared.model, glm::radians(rotation.z), glm::vec3(0.0f, 0.0f, 1.0f));
|
uboShared.model = glm::rotate(uboShared.model, glm::radians(rotation.z), glm::vec3(0.0f, 0.0f, 1.0f));
|
||||||
|
|
|
||||||
|
|
@ -332,7 +332,7 @@ public:
|
||||||
// Vertex shader
|
// Vertex shader
|
||||||
ubos.vertexShader.projection = camera.matrices.perspective;
|
ubos.vertexShader.projection = camera.matrices.perspective;
|
||||||
ubos.vertexShader.view = camera.matrices.view;
|
ubos.vertexShader.view = camera.matrices.view;
|
||||||
ubos.vertexShader.model = glm::rotate(glm::mat4(), glm::radians(90.0f), glm::vec3(1.0f, 0.0f, 0.0f));;
|
ubos.vertexShader.model = glm::rotate(glm::mat4(1.0f), glm::radians(90.0f), glm::vec3(1.0f, 0.0f, 0.0f));;
|
||||||
ubos.vertexShader.model = glm::rotate(ubos.vertexShader.model, glm::radians(180.0f), glm::vec3(0.0f, 0.0f, 1.0f));;
|
ubos.vertexShader.model = glm::rotate(ubos.vertexShader.model, glm::radians(180.0f), glm::vec3(0.0f, 0.0f, 1.0f));;
|
||||||
|
|
||||||
if (!paused) {
|
if (!paused) {
|
||||||
|
|
|
||||||
|
|
@ -688,11 +688,11 @@ public:
|
||||||
void updateUniformBuffers()
|
void updateUniformBuffers()
|
||||||
{
|
{
|
||||||
// Vertex shader
|
// Vertex shader
|
||||||
glm::mat4 viewMatrix = glm::mat4();
|
glm::mat4 viewMatrix = glm::mat4(1.0f);
|
||||||
uboVS.projection = glm::perspective(glm::radians(60.0f), (float)width / (float)height, 0.001f, 256.0f);
|
uboVS.projection = glm::perspective(glm::radians(60.0f), (float)width / (float)height, 0.001f, 256.0f);
|
||||||
viewMatrix = glm::translate(viewMatrix, glm::vec3(0.0f, 0.0f, zoom));
|
viewMatrix = glm::translate(viewMatrix, glm::vec3(0.0f, 0.0f, zoom));
|
||||||
|
|
||||||
uboVS.model = glm::mat4();
|
uboVS.model = glm::mat4(1.0f);
|
||||||
uboVS.model = viewMatrix * glm::translate(uboVS.model, glm::vec3(0.0f, 15.0f, 0.0f));
|
uboVS.model = viewMatrix * glm::translate(uboVS.model, glm::vec3(0.0f, 15.0f, 0.0f));
|
||||||
uboVS.model = glm::rotate(uboVS.model, glm::radians(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f));
|
uboVS.model = glm::rotate(uboVS.model, glm::radians(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f));
|
||||||
uboVS.model = glm::rotate(uboVS.model, glm::radians(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f));
|
uboVS.model = glm::rotate(uboVS.model, glm::radians(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f));
|
||||||
|
|
|
||||||
|
|
@ -391,7 +391,7 @@ public:
|
||||||
// 3D object
|
// 3D object
|
||||||
uboMatrices.projection = camera.matrices.perspective;
|
uboMatrices.projection = camera.matrices.perspective;
|
||||||
uboMatrices.view = camera.matrices.view;
|
uboMatrices.view = camera.matrices.view;
|
||||||
uboMatrices.model = glm::rotate(glm::mat4(), glm::radians(-90.0f + (models.objectIndex == 1 ? 45.0f : 0.0f)), glm::vec3(0.0f, 1.0f, 0.0f));
|
uboMatrices.model = glm::rotate(glm::mat4(1.0f), glm::radians(-90.0f + (models.objectIndex == 1 ? 45.0f : 0.0f)), glm::vec3(0.0f, 1.0f, 0.0f));
|
||||||
uboMatrices.camPos = camera.position * -1.0f;
|
uboMatrices.camPos = camera.position * -1.0f;
|
||||||
memcpy(uniformBuffers.object.mapped, &uboMatrices, sizeof(uboMatrices));
|
memcpy(uniformBuffers.object.mapped, &uboMatrices, sizeof(uboMatrices));
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -873,17 +873,17 @@ public:
|
||||||
|
|
||||||
std::vector<glm::mat4> matrices = {
|
std::vector<glm::mat4> matrices = {
|
||||||
// POSITIVE_X
|
// POSITIVE_X
|
||||||
glm::rotate(glm::rotate(glm::mat4(), glm::radians(90.0f), glm::vec3(0.0f, 1.0f, 0.0f)), glm::radians(180.0f), glm::vec3(1.0f, 0.0f, 0.0f)),
|
glm::rotate(glm::rotate(glm::mat4(1.0f), glm::radians(90.0f), glm::vec3(0.0f, 1.0f, 0.0f)), glm::radians(180.0f), glm::vec3(1.0f, 0.0f, 0.0f)),
|
||||||
// NEGATIVE_X
|
// NEGATIVE_X
|
||||||
glm::rotate(glm::rotate(glm::mat4(), glm::radians(-90.0f), glm::vec3(0.0f, 1.0f, 0.0f)), glm::radians(180.0f), glm::vec3(1.0f, 0.0f, 0.0f)),
|
glm::rotate(glm::rotate(glm::mat4(1.0f), glm::radians(-90.0f), glm::vec3(0.0f, 1.0f, 0.0f)), glm::radians(180.0f), glm::vec3(1.0f, 0.0f, 0.0f)),
|
||||||
// POSITIVE_Y
|
// POSITIVE_Y
|
||||||
glm::rotate(glm::mat4(), glm::radians(-90.0f), glm::vec3(1.0f, 0.0f, 0.0f)),
|
glm::rotate(glm::mat4(1.0f), glm::radians(-90.0f), glm::vec3(1.0f, 0.0f, 0.0f)),
|
||||||
// NEGATIVE_Y
|
// NEGATIVE_Y
|
||||||
glm::rotate(glm::mat4(), glm::radians(90.0f), glm::vec3(1.0f, 0.0f, 0.0f)),
|
glm::rotate(glm::mat4(1.0f), glm::radians(90.0f), glm::vec3(1.0f, 0.0f, 0.0f)),
|
||||||
// POSITIVE_Z
|
// POSITIVE_Z
|
||||||
glm::rotate(glm::mat4(), glm::radians(180.0f), glm::vec3(1.0f, 0.0f, 0.0f)),
|
glm::rotate(glm::mat4(1.0f), glm::radians(180.0f), glm::vec3(1.0f, 0.0f, 0.0f)),
|
||||||
// NEGATIVE_Z
|
// NEGATIVE_Z
|
||||||
glm::rotate(glm::mat4(), glm::radians(180.0f), glm::vec3(0.0f, 0.0f, 1.0f)),
|
glm::rotate(glm::mat4(1.0f), glm::radians(180.0f), glm::vec3(0.0f, 0.0f, 1.0f)),
|
||||||
};
|
};
|
||||||
|
|
||||||
VkCommandBuffer cmdBuf = vulkanDevice->createCommandBuffer(VK_COMMAND_BUFFER_LEVEL_PRIMARY, true);
|
VkCommandBuffer cmdBuf = vulkanDevice->createCommandBuffer(VK_COMMAND_BUFFER_LEVEL_PRIMARY, true);
|
||||||
|
|
@ -1267,17 +1267,17 @@ public:
|
||||||
|
|
||||||
std::vector<glm::mat4> matrices = {
|
std::vector<glm::mat4> matrices = {
|
||||||
// POSITIVE_X
|
// POSITIVE_X
|
||||||
glm::rotate(glm::rotate(glm::mat4(), glm::radians(90.0f), glm::vec3(0.0f, 1.0f, 0.0f)), glm::radians(180.0f), glm::vec3(1.0f, 0.0f, 0.0f)),
|
glm::rotate(glm::rotate(glm::mat4(1.0f), glm::radians(90.0f), glm::vec3(0.0f, 1.0f, 0.0f)), glm::radians(180.0f), glm::vec3(1.0f, 0.0f, 0.0f)),
|
||||||
// NEGATIVE_X
|
// NEGATIVE_X
|
||||||
glm::rotate(glm::rotate(glm::mat4(), glm::radians(-90.0f), glm::vec3(0.0f, 1.0f, 0.0f)), glm::radians(180.0f), glm::vec3(1.0f, 0.0f, 0.0f)),
|
glm::rotate(glm::rotate(glm::mat4(1.0f), glm::radians(-90.0f), glm::vec3(0.0f, 1.0f, 0.0f)), glm::radians(180.0f), glm::vec3(1.0f, 0.0f, 0.0f)),
|
||||||
// POSITIVE_Y
|
// POSITIVE_Y
|
||||||
glm::rotate(glm::mat4(), glm::radians(-90.0f), glm::vec3(1.0f, 0.0f, 0.0f)),
|
glm::rotate(glm::mat4(1.0f), glm::radians(-90.0f), glm::vec3(1.0f, 0.0f, 0.0f)),
|
||||||
// NEGATIVE_Y
|
// NEGATIVE_Y
|
||||||
glm::rotate(glm::mat4(), glm::radians(90.0f), glm::vec3(1.0f, 0.0f, 0.0f)),
|
glm::rotate(glm::mat4(1.0f), glm::radians(90.0f), glm::vec3(1.0f, 0.0f, 0.0f)),
|
||||||
// POSITIVE_Z
|
// POSITIVE_Z
|
||||||
glm::rotate(glm::mat4(), glm::radians(180.0f), glm::vec3(1.0f, 0.0f, 0.0f)),
|
glm::rotate(glm::mat4(1.0f), glm::radians(180.0f), glm::vec3(1.0f, 0.0f, 0.0f)),
|
||||||
// NEGATIVE_Z
|
// NEGATIVE_Z
|
||||||
glm::rotate(glm::mat4(), glm::radians(180.0f), glm::vec3(0.0f, 0.0f, 1.0f)),
|
glm::rotate(glm::mat4(1.0f), glm::radians(180.0f), glm::vec3(0.0f, 0.0f, 1.0f)),
|
||||||
};
|
};
|
||||||
|
|
||||||
VkCommandBuffer cmdBuf = vulkanDevice->createCommandBuffer(VK_COMMAND_BUFFER_LEVEL_PRIMARY, true);
|
VkCommandBuffer cmdBuf = vulkanDevice->createCommandBuffer(VK_COMMAND_BUFFER_LEVEL_PRIMARY, true);
|
||||||
|
|
@ -1436,7 +1436,7 @@ public:
|
||||||
// 3D object
|
// 3D object
|
||||||
uboMatrices.projection = camera.matrices.perspective;
|
uboMatrices.projection = camera.matrices.perspective;
|
||||||
uboMatrices.view = camera.matrices.view;
|
uboMatrices.view = camera.matrices.view;
|
||||||
uboMatrices.model = glm::rotate(glm::mat4(), glm::radians(90.0f + (models.objectIndex == 1 ? 45.0f : 0.0f)), glm::vec3(0.0f, 1.0f, 0.0f));
|
uboMatrices.model = glm::rotate(glm::mat4(1.0f), glm::radians(90.0f + (models.objectIndex == 1 ? 45.0f : 0.0f)), glm::vec3(0.0f, 1.0f, 0.0f));
|
||||||
uboMatrices.camPos = camera.position * -1.0f;
|
uboMatrices.camPos = camera.position * -1.0f;
|
||||||
memcpy(uniformBuffers.object.mapped, &uboMatrices, sizeof(uboMatrices));
|
memcpy(uniformBuffers.object.mapped, &uboMatrices, sizeof(uboMatrices));
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -822,17 +822,17 @@ public:
|
||||||
|
|
||||||
std::vector<glm::mat4> matrices = {
|
std::vector<glm::mat4> matrices = {
|
||||||
// POSITIVE_X
|
// POSITIVE_X
|
||||||
glm::rotate(glm::rotate(glm::mat4(), glm::radians(90.0f), glm::vec3(0.0f, 1.0f, 0.0f)), glm::radians(180.0f), glm::vec3(1.0f, 0.0f, 0.0f)),
|
glm::rotate(glm::rotate(glm::mat4(1.0f), glm::radians(90.0f), glm::vec3(0.0f, 1.0f, 0.0f)), glm::radians(180.0f), glm::vec3(1.0f, 0.0f, 0.0f)),
|
||||||
// NEGATIVE_X
|
// NEGATIVE_X
|
||||||
glm::rotate(glm::rotate(glm::mat4(), glm::radians(-90.0f), glm::vec3(0.0f, 1.0f, 0.0f)), glm::radians(180.0f), glm::vec3(1.0f, 0.0f, 0.0f)),
|
glm::rotate(glm::rotate(glm::mat4(1.0f), glm::radians(-90.0f), glm::vec3(0.0f, 1.0f, 0.0f)), glm::radians(180.0f), glm::vec3(1.0f, 0.0f, 0.0f)),
|
||||||
// POSITIVE_Y
|
// POSITIVE_Y
|
||||||
glm::rotate(glm::mat4(), glm::radians(-90.0f), glm::vec3(1.0f, 0.0f, 0.0f)),
|
glm::rotate(glm::mat4(1.0f), glm::radians(-90.0f), glm::vec3(1.0f, 0.0f, 0.0f)),
|
||||||
// NEGATIVE_Y
|
// NEGATIVE_Y
|
||||||
glm::rotate(glm::mat4(), glm::radians(90.0f), glm::vec3(1.0f, 0.0f, 0.0f)),
|
glm::rotate(glm::mat4(1.0f), glm::radians(90.0f), glm::vec3(1.0f, 0.0f, 0.0f)),
|
||||||
// POSITIVE_Z
|
// POSITIVE_Z
|
||||||
glm::rotate(glm::mat4(), glm::radians(180.0f), glm::vec3(1.0f, 0.0f, 0.0f)),
|
glm::rotate(glm::mat4(1.0f), glm::radians(180.0f), glm::vec3(1.0f, 0.0f, 0.0f)),
|
||||||
// NEGATIVE_Z
|
// NEGATIVE_Z
|
||||||
glm::rotate(glm::mat4(), glm::radians(180.0f), glm::vec3(0.0f, 0.0f, 1.0f)),
|
glm::rotate(glm::mat4(1.0f), glm::radians(180.0f), glm::vec3(0.0f, 0.0f, 1.0f)),
|
||||||
};
|
};
|
||||||
|
|
||||||
VkCommandBuffer cmdBuf = vulkanDevice->createCommandBuffer(VK_COMMAND_BUFFER_LEVEL_PRIMARY, true);
|
VkCommandBuffer cmdBuf = vulkanDevice->createCommandBuffer(VK_COMMAND_BUFFER_LEVEL_PRIMARY, true);
|
||||||
|
|
@ -1216,17 +1216,17 @@ public:
|
||||||
|
|
||||||
std::vector<glm::mat4> matrices = {
|
std::vector<glm::mat4> matrices = {
|
||||||
// POSITIVE_X
|
// POSITIVE_X
|
||||||
glm::rotate(glm::rotate(glm::mat4(), glm::radians(90.0f), glm::vec3(0.0f, 1.0f, 0.0f)), glm::radians(180.0f), glm::vec3(1.0f, 0.0f, 0.0f)),
|
glm::rotate(glm::rotate(glm::mat4(1.0f), glm::radians(90.0f), glm::vec3(0.0f, 1.0f, 0.0f)), glm::radians(180.0f), glm::vec3(1.0f, 0.0f, 0.0f)),
|
||||||
// NEGATIVE_X
|
// NEGATIVE_X
|
||||||
glm::rotate(glm::rotate(glm::mat4(), glm::radians(-90.0f), glm::vec3(0.0f, 1.0f, 0.0f)), glm::radians(180.0f), glm::vec3(1.0f, 0.0f, 0.0f)),
|
glm::rotate(glm::rotate(glm::mat4(1.0f), glm::radians(-90.0f), glm::vec3(0.0f, 1.0f, 0.0f)), glm::radians(180.0f), glm::vec3(1.0f, 0.0f, 0.0f)),
|
||||||
// POSITIVE_Y
|
// POSITIVE_Y
|
||||||
glm::rotate(glm::mat4(), glm::radians(-90.0f), glm::vec3(1.0f, 0.0f, 0.0f)),
|
glm::rotate(glm::mat4(1.0f), glm::radians(-90.0f), glm::vec3(1.0f, 0.0f, 0.0f)),
|
||||||
// NEGATIVE_Y
|
// NEGATIVE_Y
|
||||||
glm::rotate(glm::mat4(), glm::radians(90.0f), glm::vec3(1.0f, 0.0f, 0.0f)),
|
glm::rotate(glm::mat4(1.0f), glm::radians(90.0f), glm::vec3(1.0f, 0.0f, 0.0f)),
|
||||||
// POSITIVE_Z
|
// POSITIVE_Z
|
||||||
glm::rotate(glm::mat4(), glm::radians(180.0f), glm::vec3(1.0f, 0.0f, 0.0f)),
|
glm::rotate(glm::mat4(1.0f), glm::radians(180.0f), glm::vec3(1.0f, 0.0f, 0.0f)),
|
||||||
// NEGATIVE_Z
|
// NEGATIVE_Z
|
||||||
glm::rotate(glm::mat4(), glm::radians(180.0f), glm::vec3(0.0f, 0.0f, 1.0f)),
|
glm::rotate(glm::mat4(1.0f), glm::radians(180.0f), glm::vec3(0.0f, 0.0f, 1.0f)),
|
||||||
};
|
};
|
||||||
|
|
||||||
VkCommandBuffer cmdBuf = vulkanDevice->createCommandBuffer(VK_COMMAND_BUFFER_LEVEL_PRIMARY, true);
|
VkCommandBuffer cmdBuf = vulkanDevice->createCommandBuffer(VK_COMMAND_BUFFER_LEVEL_PRIMARY, true);
|
||||||
|
|
@ -1385,7 +1385,7 @@ public:
|
||||||
// 3D object
|
// 3D object
|
||||||
uboMatrices.projection = camera.matrices.perspective;
|
uboMatrices.projection = camera.matrices.perspective;
|
||||||
uboMatrices.view = camera.matrices.view;
|
uboMatrices.view = camera.matrices.view;
|
||||||
uboMatrices.model = glm::rotate(glm::mat4(), glm::radians(-90.0f), glm::vec3(0.0f, 1.0f, 0.0f));
|
uboMatrices.model = glm::rotate(glm::mat4(1.0f), glm::radians(-90.0f), glm::vec3(0.0f, 1.0f, 0.0f));
|
||||||
uboMatrices.camPos = camera.position * -1.0f;
|
uboMatrices.camPos = camera.position * -1.0f;
|
||||||
memcpy(uniformBuffers.object.mapped, &uboMatrices, sizeof(uboMatrices));
|
memcpy(uniformBuffers.object.mapped, &uboMatrices, sizeof(uboMatrices));
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -379,9 +379,9 @@ public:
|
||||||
{
|
{
|
||||||
uboVS.projection = glm::perspective(glm::radians(60.0f), (float)(width / 3.0f) / (float)height, 0.1f, 256.0f);
|
uboVS.projection = glm::perspective(glm::radians(60.0f), (float)(width / 3.0f) / (float)height, 0.1f, 256.0f);
|
||||||
|
|
||||||
glm::mat4 viewMatrix = glm::translate(glm::mat4(), glm::vec3(0.0f, 0.0f, zoom));
|
glm::mat4 viewMatrix = glm::translate(glm::mat4(1.0f), glm::vec3(0.0f, 0.0f, zoom));
|
||||||
|
|
||||||
uboVS.modelView = viewMatrix * glm::translate(glm::mat4(), cameraPos);
|
uboVS.modelView = viewMatrix * glm::translate(glm::mat4(1.0f), cameraPos);
|
||||||
uboVS.modelView = glm::rotate(uboVS.modelView, glm::radians(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f));
|
uboVS.modelView = glm::rotate(uboVS.modelView, glm::radians(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f));
|
||||||
uboVS.modelView = glm::rotate(uboVS.modelView, glm::radians(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f));
|
uboVS.modelView = glm::rotate(uboVS.modelView, glm::radians(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f));
|
||||||
uboVS.modelView = glm::rotate(uboVS.modelView, glm::radians(rotation.z), glm::vec3(0.0f, 0.0f, 1.0f));
|
uboVS.modelView = glm::rotate(uboVS.modelView, glm::radians(rotation.z), glm::vec3(0.0f, 0.0f, 1.0f));
|
||||||
|
|
|
||||||
|
|
@ -403,11 +403,11 @@ public:
|
||||||
void updateUniformBuffers()
|
void updateUniformBuffers()
|
||||||
{
|
{
|
||||||
// Vertex shader
|
// Vertex shader
|
||||||
glm::mat4 viewMatrix = glm::mat4();
|
glm::mat4 viewMatrix = glm::mat4(1.0f);
|
||||||
uboVS.projection = glm::perspective(glm::radians(60.0f), (float)width / (float)height, 0.001f, 256.0f);
|
uboVS.projection = glm::perspective(glm::radians(60.0f), (float)width / (float)height, 0.001f, 256.0f);
|
||||||
viewMatrix = glm::translate(viewMatrix, glm::vec3(0.0f, 2.0f, zoom));
|
viewMatrix = glm::translate(viewMatrix, glm::vec3(0.0f, 2.0f, zoom));
|
||||||
|
|
||||||
uboVS.model = viewMatrix * glm::translate(glm::mat4(), glm::vec3(0, 0, 0));
|
uboVS.model = viewMatrix * glm::translate(glm::mat4(1.0f), glm::vec3(0, 0, 0));
|
||||||
uboVS.model = glm::rotate(uboVS.model, glm::radians(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f));
|
uboVS.model = glm::rotate(uboVS.model, glm::radians(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f));
|
||||||
uboVS.model = glm::rotate(uboVS.model, glm::radians(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f));
|
uboVS.model = glm::rotate(uboVS.model, glm::radians(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f));
|
||||||
uboVS.model = glm::rotate(uboVS.model, glm::radians(rotation.z), glm::vec3(0.0f, 0.0f, 1.0f));
|
uboVS.model = glm::rotate(uboVS.model, glm::radians(rotation.z), glm::vec3(0.0f, 0.0f, 1.0f));
|
||||||
|
|
|
||||||
|
|
@ -756,9 +756,9 @@ public:
|
||||||
void updateUniformBuffersScene()
|
void updateUniformBuffersScene()
|
||||||
{
|
{
|
||||||
uboScene.projection = glm::perspective(glm::radians(45.0f), (float)width / (float)height, 1.0f, 256.0f);
|
uboScene.projection = glm::perspective(glm::radians(45.0f), (float)width / (float)height, 1.0f, 256.0f);
|
||||||
glm::mat4 viewMatrix = glm::translate(glm::mat4(), glm::vec3(0.0f, 0.0f, zoom));
|
glm::mat4 viewMatrix = glm::translate(glm::mat4(1.0f), glm::vec3(0.0f, 0.0f, zoom));
|
||||||
|
|
||||||
uboScene.model = glm::mat4();
|
uboScene.model = glm::mat4(1.0f);
|
||||||
uboScene.model = viewMatrix * glm::translate(uboScene.model, cameraPos);
|
uboScene.model = viewMatrix * glm::translate(uboScene.model, cameraPos);
|
||||||
uboScene.model = glm::rotate(uboScene.model, glm::radians(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f));
|
uboScene.model = glm::rotate(uboScene.model, glm::radians(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f));
|
||||||
uboScene.model = glm::rotate(uboScene.model, glm::radians(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f));
|
uboScene.model = glm::rotate(uboScene.model, glm::radians(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f));
|
||||||
|
|
|
||||||
|
|
@ -637,7 +637,7 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
for (auto v : pos) {
|
for (auto v : pos) {
|
||||||
glm::mat4 mvpMatrix = glm::perspective(glm::radians(60.0f), (float)width / (float)height, 0.1f, 256.0f) * glm::translate(glm::mat4(), v);
|
glm::mat4 mvpMatrix = glm::perspective(glm::radians(60.0f), (float)width / (float)height, 0.1f, 256.0f) * glm::translate(glm::mat4(1.0f), v);
|
||||||
vkCmdPushConstants(commandBuffer, pipelineLayout, VK_SHADER_STAGE_VERTEX_BIT, 0, sizeof(mvpMatrix), &mvpMatrix);
|
vkCmdPushConstants(commandBuffer, pipelineLayout, VK_SHADER_STAGE_VERTEX_BIT, 0, sizeof(mvpMatrix), &mvpMatrix);
|
||||||
vkCmdDrawIndexed(commandBuffer, 3, 1, 0, 0, 0);
|
vkCmdDrawIndexed(commandBuffer, 3, 1, 0, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -808,7 +808,7 @@ public:
|
||||||
|
|
||||||
scene->uniformData.projection = camera.matrices.perspective;
|
scene->uniformData.projection = camera.matrices.perspective;
|
||||||
scene->uniformData.view = camera.matrices.view;
|
scene->uniformData.view = camera.matrices.view;
|
||||||
scene->uniformData.model = glm::mat4();
|
scene->uniformData.model = glm::mat4(1.0f);
|
||||||
|
|
||||||
memcpy(scene->uniformBuffer.mapped, &scene->uniformData, sizeof(scene->uniformData));
|
memcpy(scene->uniformBuffer.mapped, &scene->uniformData, sizeof(scene->uniformData));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -292,7 +292,7 @@ public:
|
||||||
{
|
{
|
||||||
uboVS.projection = camera.matrices.perspective;
|
uboVS.projection = camera.matrices.perspective;
|
||||||
uboVS.view = camera.matrices.view;
|
uboVS.view = camera.matrices.view;
|
||||||
uboVS.model = glm::mat4();
|
uboVS.model = glm::mat4(1.0f);
|
||||||
|
|
||||||
VK_CHECK_RESULT(uniformBuffer.map());
|
VK_CHECK_RESULT(uniformBuffer.map());
|
||||||
uniformBuffer.copyTo(&uboVS, sizeof(uboVS));
|
uniformBuffer.copyTo(&uboVS, sizeof(uboVS));
|
||||||
|
|
|
||||||
|
|
@ -816,19 +816,19 @@ public:
|
||||||
float AR = (float)height / (float)width;
|
float AR = (float)height / (float)width;
|
||||||
|
|
||||||
uboVSquad.projection = glm::ortho(2.5f / AR, 0.0f, 0.0f, 2.5f, -1.0f, 1.0f);
|
uboVSquad.projection = glm::ortho(2.5f / AR, 0.0f, 0.0f, 2.5f, -1.0f, 1.0f);
|
||||||
uboVSquad.model = glm::mat4();
|
uboVSquad.model = glm::mat4(1.0f);
|
||||||
|
|
||||||
memcpy(uniformBuffers.debug.mapped, &uboVSquad, sizeof(uboVSquad));
|
memcpy(uniformBuffers.debug.mapped, &uboVSquad, sizeof(uboVSquad));
|
||||||
|
|
||||||
// 3D scene
|
// 3D scene
|
||||||
uboVSscene.projection = glm::perspective(glm::radians(45.0f), (float)width / (float)height, zNear, zFar);
|
uboVSscene.projection = glm::perspective(glm::radians(45.0f), (float)width / (float)height, zNear, zFar);
|
||||||
|
|
||||||
uboVSscene.view = glm::translate(glm::mat4(), glm::vec3(0.0f, 0.0f, zoom));
|
uboVSscene.view = glm::translate(glm::mat4(1.0f), glm::vec3(0.0f, 0.0f, zoom));
|
||||||
uboVSscene.view = glm::rotate(uboVSscene.view, glm::radians(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f));
|
uboVSscene.view = glm::rotate(uboVSscene.view, glm::radians(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f));
|
||||||
uboVSscene.view = glm::rotate(uboVSscene.view, glm::radians(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f));
|
uboVSscene.view = glm::rotate(uboVSscene.view, glm::radians(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f));
|
||||||
uboVSscene.view = glm::rotate(uboVSscene.view, glm::radians(rotation.z), glm::vec3(0.0f, 0.0f, 1.0f));
|
uboVSscene.view = glm::rotate(uboVSscene.view, glm::radians(rotation.z), glm::vec3(0.0f, 0.0f, 1.0f));
|
||||||
|
|
||||||
uboVSscene.model = glm::mat4();
|
uboVSscene.model = glm::mat4(1.0f);
|
||||||
|
|
||||||
uboVSscene.lightPos = lightPos;
|
uboVSscene.lightPos = lightPos;
|
||||||
|
|
||||||
|
|
@ -849,7 +849,7 @@ public:
|
||||||
// Matrix from light's point of view
|
// Matrix from light's point of view
|
||||||
glm::mat4 depthProjectionMatrix = glm::perspective(glm::radians(lightFOV), 1.0f, zNear, zFar);
|
glm::mat4 depthProjectionMatrix = glm::perspective(glm::radians(lightFOV), 1.0f, zNear, zFar);
|
||||||
glm::mat4 depthViewMatrix = glm::lookAt(lightPos, glm::vec3(0.0f), glm::vec3(0, 1, 0));
|
glm::mat4 depthViewMatrix = glm::lookAt(lightPos, glm::vec3(0.0f), glm::vec3(0, 1, 0));
|
||||||
glm::mat4 depthModelMatrix = glm::mat4();
|
glm::mat4 depthModelMatrix = glm::mat4(1.0f);
|
||||||
|
|
||||||
uboOffscreenVS.depthMVP = depthProjectionMatrix * depthViewMatrix * depthModelMatrix;
|
uboOffscreenVS.depthMVP = depthProjectionMatrix * depthViewMatrix * depthModelMatrix;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -392,7 +392,7 @@ public:
|
||||||
|
|
||||||
// Update view matrix via push constant
|
// Update view matrix via push constant
|
||||||
|
|
||||||
glm::mat4 viewMatrix = glm::mat4();
|
glm::mat4 viewMatrix = glm::mat4(1.0f);
|
||||||
switch (faceIndex)
|
switch (faceIndex)
|
||||||
{
|
{
|
||||||
case 0: // POSITIVE_X
|
case 0: // POSITIVE_X
|
||||||
|
|
@ -955,9 +955,9 @@ public:
|
||||||
void updateUniformBuffers()
|
void updateUniformBuffers()
|
||||||
{
|
{
|
||||||
uboVSscene.projection = glm::perspective(glm::radians(45.0f), (float)width / (float)height, zNear, zFar);
|
uboVSscene.projection = glm::perspective(glm::radians(45.0f), (float)width / (float)height, zNear, zFar);
|
||||||
uboVSscene.view = glm::translate(glm::mat4(), glm::vec3(0.0f, 0.0f, displayCubeMap ? 0.0f : zoom));
|
uboVSscene.view = glm::translate(glm::mat4(1.0f), glm::vec3(0.0f, 0.0f, displayCubeMap ? 0.0f : zoom));
|
||||||
|
|
||||||
uboVSscene.model = glm::mat4();
|
uboVSscene.model = glm::mat4(1.0f);
|
||||||
uboVSscene.model = glm::rotate(uboVSscene.model, glm::radians(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f));
|
uboVSscene.model = glm::rotate(uboVSscene.model, glm::radians(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f));
|
||||||
uboVSscene.model = glm::rotate(uboVSscene.model, glm::radians(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f));
|
uboVSscene.model = glm::rotate(uboVSscene.model, glm::radians(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f));
|
||||||
uboVSscene.model = glm::rotate(uboVSscene.model, glm::radians(rotation.z), glm::vec3(0.0f, 0.0f, 1.0f));
|
uboVSscene.model = glm::rotate(uboVSscene.model, glm::radians(rotation.z), glm::vec3(0.0f, 0.0f, 1.0f));
|
||||||
|
|
@ -974,8 +974,8 @@ public:
|
||||||
|
|
||||||
uboOffscreenVS.projection = glm::perspective((float)(M_PI / 2.0), 1.0f, zNear, zFar);
|
uboOffscreenVS.projection = glm::perspective((float)(M_PI / 2.0), 1.0f, zNear, zFar);
|
||||||
|
|
||||||
uboOffscreenVS.view = glm::mat4();
|
uboOffscreenVS.view = glm::mat4(1.0f);
|
||||||
uboOffscreenVS.model = glm::translate(glm::mat4(), glm::vec3(-lightPos.x, -lightPos.y, -lightPos.z));
|
uboOffscreenVS.model = glm::translate(glm::mat4(1.0f), glm::vec3(-lightPos.x, -lightPos.y, -lightPos.z));
|
||||||
|
|
||||||
uboOffscreenVS.lightPos = lightPos;
|
uboOffscreenVS.lightPos = lightPos;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -933,11 +933,11 @@ public:
|
||||||
{
|
{
|
||||||
uboVS.projection = glm::perspective(glm::radians(60.0f), (float)width / (float)height, 0.1f, 1024.0f);
|
uboVS.projection = glm::perspective(glm::radians(60.0f), (float)width / (float)height, 0.1f, 1024.0f);
|
||||||
|
|
||||||
glm::mat4 viewMatrix = glm::translate(glm::mat4(), glm::vec3(0.0f, 0.0f, zoom));
|
glm::mat4 viewMatrix = glm::translate(glm::mat4(1.0f), glm::vec3(0.0f, 0.0f, zoom));
|
||||||
viewMatrix = glm::rotate(viewMatrix, glm::radians(90.0f), glm::vec3(1.0f, 0.0f, 0.0f));
|
viewMatrix = glm::rotate(viewMatrix, glm::radians(90.0f), glm::vec3(1.0f, 0.0f, 0.0f));
|
||||||
viewMatrix = glm::scale(viewMatrix, glm::vec3(0.025f));
|
viewMatrix = glm::scale(viewMatrix, glm::vec3(0.025f));
|
||||||
|
|
||||||
uboVS.view = viewMatrix * glm::translate(glm::mat4(), glm::vec3(cameraPos.x, -cameraPos.z, cameraPos.y) * 100.0f);
|
uboVS.view = viewMatrix * glm::translate(glm::mat4(1.0f), glm::vec3(cameraPos.x, -cameraPos.z, cameraPos.y) * 100.0f);
|
||||||
uboVS.view = glm::rotate(uboVS.view, glm::radians(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f));
|
uboVS.view = glm::rotate(uboVS.view, glm::radians(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f));
|
||||||
uboVS.view = glm::rotate(uboVS.view, glm::radians(rotation.z), glm::vec3(0.0f, 1.0f, 0.0f));
|
uboVS.view = glm::rotate(uboVS.view, glm::radians(rotation.z), glm::vec3(0.0f, 1.0f, 0.0f));
|
||||||
uboVS.view = glm::rotate(uboVS.view, glm::radians(-rotation.y), glm::vec3(0.0f, 0.0f, 1.0f));
|
uboVS.view = glm::rotate(uboVS.view, glm::radians(-rotation.y), glm::vec3(0.0f, 0.0f, 1.0f));
|
||||||
|
|
@ -946,7 +946,7 @@ public:
|
||||||
|
|
||||||
uboFloor.projection = uboVS.projection;
|
uboFloor.projection = uboVS.projection;
|
||||||
uboFloor.view = viewMatrix;
|
uboFloor.view = viewMatrix;
|
||||||
uboFloor.model = glm::translate(glm::mat4(), glm::vec3(cameraPos.x, -cameraPos.z, cameraPos.y) * 100.0f);
|
uboFloor.model = glm::translate(glm::mat4(1.0f), glm::vec3(cameraPos.x, -cameraPos.z, cameraPos.y) * 100.0f);
|
||||||
uboFloor.model = glm::rotate(uboFloor.model, glm::radians(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f));
|
uboFloor.model = glm::rotate(uboFloor.model, glm::radians(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f));
|
||||||
uboFloor.model = glm::rotate(uboFloor.model, glm::radians(rotation.z), glm::vec3(0.0f, 1.0f, 0.0f));
|
uboFloor.model = glm::rotate(uboFloor.model, glm::radians(rotation.z), glm::vec3(0.0f, 1.0f, 0.0f));
|
||||||
uboFloor.model = glm::rotate(uboFloor.model, glm::radians(-rotation.y), glm::vec3(0.0f, 0.0f, 1.0f));
|
uboFloor.model = glm::rotate(uboFloor.model, glm::radians(-rotation.y), glm::vec3(0.0f, 0.0f, 1.0f));
|
||||||
|
|
|
||||||
|
|
@ -377,7 +377,7 @@ public:
|
||||||
glm::vec3(0, 1, 0)
|
glm::vec3(0, 1, 0)
|
||||||
);
|
);
|
||||||
|
|
||||||
uboVS.model = glm::mat4();
|
uboVS.model = glm::mat4(1.0f);
|
||||||
uboVS.model = glm::rotate(uboVS.model, glm::radians(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f));
|
uboVS.model = glm::rotate(uboVS.model, glm::radians(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f));
|
||||||
uboVS.model = glm::rotate(uboVS.model, glm::radians(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f));
|
uboVS.model = glm::rotate(uboVS.model, glm::radians(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f));
|
||||||
uboVS.model = glm::rotate(uboVS.model, glm::radians(rotation.z), glm::vec3(0.0f, 0.0f, 1.0f));
|
uboVS.model = glm::rotate(uboVS.model, glm::radians(rotation.z), glm::vec3(0.0f, 0.0f, 1.0f));
|
||||||
|
|
|
||||||
|
|
@ -1047,7 +1047,7 @@ public:
|
||||||
{
|
{
|
||||||
uboSceneMatrices.projection = camera.matrices.perspective;
|
uboSceneMatrices.projection = camera.matrices.perspective;
|
||||||
uboSceneMatrices.view = camera.matrices.view;
|
uboSceneMatrices.view = camera.matrices.view;
|
||||||
uboSceneMatrices.model = glm::mat4();
|
uboSceneMatrices.model = glm::mat4(1.0f);
|
||||||
|
|
||||||
VK_CHECK_RESULT(uniformBuffers.sceneMatrices.map());
|
VK_CHECK_RESULT(uniformBuffers.sceneMatrices.map());
|
||||||
uniformBuffers.sceneMatrices.copyTo(&uboSceneMatrices, sizeof(uboSceneMatrices));
|
uniformBuffers.sceneMatrices.copyTo(&uboSceneMatrices, sizeof(uboSceneMatrices));
|
||||||
|
|
|
||||||
|
|
@ -958,7 +958,7 @@ public:
|
||||||
{
|
{
|
||||||
uboGBuffer.projection = camera.matrices.perspective;
|
uboGBuffer.projection = camera.matrices.perspective;
|
||||||
uboGBuffer.view = camera.matrices.view;
|
uboGBuffer.view = camera.matrices.view;
|
||||||
uboGBuffer.model = glm::mat4();
|
uboGBuffer.model = glm::mat4(1.0f);
|
||||||
|
|
||||||
VK_CHECK_RESULT(uniformBuffers.GBuffer.map());
|
VK_CHECK_RESULT(uniformBuffers.GBuffer.map());
|
||||||
memcpy(uniformBuffers.GBuffer.mapped, &uboGBuffer, sizeof(uboGBuffer));
|
memcpy(uniformBuffers.GBuffer.mapped, &uboGBuffer, sizeof(uboGBuffer));
|
||||||
|
|
|
||||||
|
|
@ -877,7 +877,7 @@ public:
|
||||||
// Tessellation
|
// Tessellation
|
||||||
|
|
||||||
uboTess.projection = camera.matrices.perspective;
|
uboTess.projection = camera.matrices.perspective;
|
||||||
uboTess.modelview = camera.matrices.view * glm::mat4();
|
uboTess.modelview = camera.matrices.view * glm::mat4(1.0f);
|
||||||
uboTess.lightPos.y = -0.5f - uboTess.displacementFactor; // todo: Not uesed yet
|
uboTess.lightPos.y = -0.5f - uboTess.displacementFactor; // todo: Not uesed yet
|
||||||
uboTess.viewportDim = glm::vec2((float)width, (float)height);
|
uboTess.viewportDim = glm::vec2((float)width, (float)height);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -491,11 +491,11 @@ public:
|
||||||
void updateUniformBuffers()
|
void updateUniformBuffers()
|
||||||
{
|
{
|
||||||
// Tessellation eval
|
// Tessellation eval
|
||||||
glm::mat4 viewMatrix = glm::mat4();
|
glm::mat4 viewMatrix = glm::mat4(1.0f);
|
||||||
uboTessEval.projection = glm::perspective(glm::radians(45.0f), (float)(width* ((splitScreen) ? 0.5f : 1.0f)) / (float)height, 0.1f, 256.0f);
|
uboTessEval.projection = glm::perspective(glm::radians(45.0f), (float)(width* ((splitScreen) ? 0.5f : 1.0f)) / (float)height, 0.1f, 256.0f);
|
||||||
viewMatrix = glm::translate(viewMatrix, glm::vec3(0.0f, 0.0f, zoom));
|
viewMatrix = glm::translate(viewMatrix, glm::vec3(0.0f, 0.0f, zoom));
|
||||||
|
|
||||||
uboTessEval.model = glm::mat4();
|
uboTessEval.model = glm::mat4(1.0f);
|
||||||
uboTessEval.model = viewMatrix * glm::translate(uboTessEval.model, cameraPos);
|
uboTessEval.model = viewMatrix * glm::translate(uboTessEval.model, cameraPos);
|
||||||
uboTessEval.model = glm::rotate(uboTessEval.model, glm::radians(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f));
|
uboTessEval.model = glm::rotate(uboTessEval.model, glm::radians(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f));
|
||||||
uboTessEval.model = glm::rotate(uboTessEval.model, glm::radians(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f));
|
uboTessEval.model = glm::rotate(uboTessEval.model, glm::radians(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f));
|
||||||
|
|
|
||||||
|
|
@ -1141,9 +1141,9 @@ public:
|
||||||
// Vertex shader
|
// Vertex shader
|
||||||
uboVS.projection = glm::perspective(glm::radians(60.0f), (float)width / (float)height, 0.1f, 256.0f);
|
uboVS.projection = glm::perspective(glm::radians(60.0f), (float)width / (float)height, 0.1f, 256.0f);
|
||||||
|
|
||||||
glm::mat4 viewMatrix = glm::translate(glm::mat4(), glm::vec3(0.0f, 0.0f, zoom));
|
glm::mat4 viewMatrix = glm::translate(glm::mat4(1.0f), glm::vec3(0.0f, 0.0f, zoom));
|
||||||
|
|
||||||
uboVS.model = viewMatrix * glm::translate(glm::mat4(), cameraPos);
|
uboVS.model = viewMatrix * glm::translate(glm::mat4(1.0f), cameraPos);
|
||||||
uboVS.model = glm::rotate(uboVS.model, glm::radians(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f));
|
uboVS.model = glm::rotate(uboVS.model, glm::radians(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f));
|
||||||
uboVS.model = glm::rotate(uboVS.model, glm::radians(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f));
|
uboVS.model = glm::rotate(uboVS.model, glm::radians(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f));
|
||||||
uboVS.model = glm::rotate(uboVS.model, glm::radians(rotation.z), glm::vec3(0.0f, 0.0f, 1.0f));
|
uboVS.model = glm::rotate(uboVS.model, glm::radians(rotation.z), glm::vec3(0.0f, 0.0f, 1.0f));
|
||||||
|
|
|
||||||
|
|
@ -821,9 +821,9 @@ public:
|
||||||
{
|
{
|
||||||
// Vertex shader
|
// Vertex shader
|
||||||
uboVS.projection = glm::perspective(glm::radians(60.0f), (float)width / (float)height, 0.001f, 256.0f);
|
uboVS.projection = glm::perspective(glm::radians(60.0f), (float)width / (float)height, 0.001f, 256.0f);
|
||||||
glm::mat4 viewMatrix = glm::translate(glm::mat4(), glm::vec3(0.0f, 0.0f, zoom));
|
glm::mat4 viewMatrix = glm::translate(glm::mat4(1.0f), glm::vec3(0.0f, 0.0f, zoom));
|
||||||
|
|
||||||
uboVS.model = viewMatrix * glm::translate(glm::mat4(), cameraPos);
|
uboVS.model = viewMatrix * glm::translate(glm::mat4(1.0f), cameraPos);
|
||||||
uboVS.model = glm::rotate(uboVS.model, glm::radians(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f));
|
uboVS.model = glm::rotate(uboVS.model, glm::radians(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f));
|
||||||
uboVS.model = glm::rotate(uboVS.model, glm::radians(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f));
|
uboVS.model = glm::rotate(uboVS.model, glm::radians(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f));
|
||||||
uboVS.model = glm::rotate(uboVS.model, glm::radians(rotation.z), glm::vec3(0.0f, 0.0f, 1.0f));
|
uboVS.model = glm::rotate(uboVS.model, glm::radians(rotation.z), glm::vec3(0.0f, 0.0f, 1.0f));
|
||||||
|
|
|
||||||
|
|
@ -762,9 +762,9 @@ public:
|
||||||
if (viewchanged)
|
if (viewchanged)
|
||||||
{
|
{
|
||||||
uboVS.projection = glm::perspective(glm::radians(60.0f), (float)width / (float)height, 0.001f, 256.0f);
|
uboVS.projection = glm::perspective(glm::radians(60.0f), (float)width / (float)height, 0.001f, 256.0f);
|
||||||
glm::mat4 viewMatrix = glm::translate(glm::mat4(), glm::vec3(0.0f, 0.0f, zoom));
|
glm::mat4 viewMatrix = glm::translate(glm::mat4(1.0f), glm::vec3(0.0f, 0.0f, zoom));
|
||||||
|
|
||||||
uboVS.model = viewMatrix * glm::translate(glm::mat4(), cameraPos);
|
uboVS.model = viewMatrix * glm::translate(glm::mat4(1.0f), cameraPos);
|
||||||
uboVS.model = glm::rotate(uboVS.model, glm::radians(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f));
|
uboVS.model = glm::rotate(uboVS.model, glm::radians(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f));
|
||||||
uboVS.model = glm::rotate(uboVS.model, glm::radians(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f));
|
uboVS.model = glm::rotate(uboVS.model, glm::radians(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f));
|
||||||
uboVS.model = glm::rotate(uboVS.model, glm::radians(rotation.z), glm::vec3(0.0f, 0.0f, 1.0f));
|
uboVS.model = glm::rotate(uboVS.model, glm::radians(rotation.z), glm::vec3(0.0f, 0.0f, 1.0f));
|
||||||
|
|
|
||||||
|
|
@ -599,7 +599,7 @@ public:
|
||||||
for (int32_t i = 0; i < layerCount; i++)
|
for (int32_t i = 0; i < layerCount; i++)
|
||||||
{
|
{
|
||||||
// Instance model matrix
|
// Instance model matrix
|
||||||
uboVS.instance[i].model = glm::translate(glm::mat4(), glm::vec3(0.0f, i * offset - center, 0.0f));
|
uboVS.instance[i].model = glm::translate(glm::mat4(1.0f), glm::vec3(0.0f, i * offset - center, 0.0f));
|
||||||
uboVS.instance[i].model = glm::rotate(uboVS.instance[i].model, glm::radians(60.0f), glm::vec3(1.0f, 0.0f, 0.0f));
|
uboVS.instance[i].model = glm::rotate(uboVS.instance[i].model, glm::radians(60.0f), glm::vec3(1.0f, 0.0f, 0.0f));
|
||||||
// Instance texture array index
|
// Instance texture array index
|
||||||
uboVS.instance[i].arrayIndex.x = i;
|
uboVS.instance[i].arrayIndex.x = i;
|
||||||
|
|
@ -627,7 +627,7 @@ public:
|
||||||
uboVS.matrices.projection = glm::perspective(glm::radians(60.0f), (float)width / (float)height, 0.001f, 256.0f);
|
uboVS.matrices.projection = glm::perspective(glm::radians(60.0f), (float)width / (float)height, 0.001f, 256.0f);
|
||||||
|
|
||||||
// View
|
// View
|
||||||
uboVS.matrices.view = glm::translate(glm::mat4(), glm::vec3(0.0f, -1.0f, zoom));
|
uboVS.matrices.view = glm::translate(glm::mat4(1.0f), glm::vec3(0.0f, -1.0f, zoom));
|
||||||
uboVS.matrices.view = glm::rotate(uboVS.matrices.view, glm::radians(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f));
|
uboVS.matrices.view = glm::rotate(uboVS.matrices.view, glm::radians(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f));
|
||||||
uboVS.matrices.view = glm::rotate(uboVS.matrices.view, glm::radians(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f));
|
uboVS.matrices.view = glm::rotate(uboVS.matrices.view, glm::radians(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f));
|
||||||
uboVS.matrices.view = glm::rotate(uboVS.matrices.view, glm::radians(rotation.z), glm::vec3(0.0f, 0.0f, 1.0f));
|
uboVS.matrices.view = glm::rotate(uboVS.matrices.view, glm::radians(rotation.z), glm::vec3(0.0f, 0.0f, 1.0f));
|
||||||
|
|
|
||||||
|
|
@ -660,11 +660,11 @@ public:
|
||||||
void updateUniformBuffers()
|
void updateUniformBuffers()
|
||||||
{
|
{
|
||||||
// 3D object
|
// 3D object
|
||||||
glm::mat4 viewMatrix = glm::mat4();
|
glm::mat4 viewMatrix = glm::mat4(1.0f);
|
||||||
uboVS.projection = glm::perspective(glm::radians(60.0f), (float)width / (float)height, 0.001f, 256.0f);
|
uboVS.projection = glm::perspective(glm::radians(60.0f), (float)width / (float)height, 0.001f, 256.0f);
|
||||||
viewMatrix = glm::translate(viewMatrix, glm::vec3(0.0f, 0.0f, zoom));
|
viewMatrix = glm::translate(viewMatrix, glm::vec3(0.0f, 0.0f, zoom));
|
||||||
|
|
||||||
uboVS.model = glm::mat4();
|
uboVS.model = glm::mat4(1.0f);
|
||||||
uboVS.model = viewMatrix * glm::translate(uboVS.model, cameraPos);
|
uboVS.model = viewMatrix * glm::translate(uboVS.model, cameraPos);
|
||||||
uboVS.model = glm::rotate(uboVS.model, glm::radians(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f));
|
uboVS.model = glm::rotate(uboVS.model, glm::radians(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f));
|
||||||
uboVS.model = glm::rotate(uboVS.model, glm::radians(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f));
|
uboVS.model = glm::rotate(uboVS.model, glm::radians(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f));
|
||||||
|
|
@ -673,10 +673,10 @@ public:
|
||||||
memcpy(uniformBuffers.object.mapped, &uboVS, sizeof(uboVS));
|
memcpy(uniformBuffers.object.mapped, &uboVS, sizeof(uboVS));
|
||||||
|
|
||||||
// Skybox
|
// Skybox
|
||||||
viewMatrix = glm::mat4();
|
viewMatrix = glm::mat4(1.0f);
|
||||||
uboVS.projection = glm::perspective(glm::radians(60.0f), (float)width / (float)height, 0.001f, 256.0f);
|
uboVS.projection = glm::perspective(glm::radians(60.0f), (float)width / (float)height, 0.001f, 256.0f);
|
||||||
|
|
||||||
uboVS.model = glm::mat4();
|
uboVS.model = glm::mat4(1.0f);
|
||||||
uboVS.model = viewMatrix * glm::translate(uboVS.model, glm::vec3(0, 0, 0));
|
uboVS.model = viewMatrix * glm::translate(uboVS.model, glm::vec3(0, 0, 0));
|
||||||
uboVS.model = glm::rotate(uboVS.model, glm::radians(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f));
|
uboVS.model = glm::rotate(uboVS.model, glm::radians(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f));
|
||||||
uboVS.model = glm::rotate(uboVS.model, glm::radians(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f));
|
uboVS.model = glm::rotate(uboVS.model, glm::radians(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f));
|
||||||
|
|
|
||||||
|
|
@ -674,7 +674,7 @@ public:
|
||||||
{
|
{
|
||||||
uboVS.projection = camera.matrices.perspective;
|
uboVS.projection = camera.matrices.perspective;
|
||||||
uboVS.view = camera.matrices.view;
|
uboVS.view = camera.matrices.view;
|
||||||
uboVS.model = glm::rotate(glm::mat4(), glm::radians(timer * 360.0f), glm::vec3(1.0f, 0.0f, 0.0f));
|
uboVS.model = glm::rotate(glm::mat4(1.0f), glm::radians(timer * 360.0f), glm::vec3(1.0f, 0.0f, 0.0f));
|
||||||
uboVS.viewPos = glm::vec4(camera.position, 0.0f) * glm::vec4(-1.0f);
|
uboVS.viewPos = glm::vec4(camera.position, 0.0f) * glm::vec4(-1.0f);
|
||||||
VK_CHECK_RESULT(uniformBufferVS.map());
|
VK_CHECK_RESULT(uniformBufferVS.map());
|
||||||
memcpy(uniformBufferVS.mapped, &uboVS, sizeof(uboVS));
|
memcpy(uniformBufferVS.mapped, &uboVS, sizeof(uboVS));
|
||||||
|
|
|
||||||
|
|
@ -892,16 +892,16 @@ public:
|
||||||
{
|
{
|
||||||
// Vertex shader
|
// Vertex shader
|
||||||
uboVS.projection = glm::perspective(glm::radians(60.0f), (float)width / (float)height, 0.001f, 256.0f);
|
uboVS.projection = glm::perspective(glm::radians(60.0f), (float)width / (float)height, 0.001f, 256.0f);
|
||||||
glm::mat4 viewMatrix = glm::translate(glm::mat4(), glm::vec3(0.0f, 0.0f, zoom));
|
glm::mat4 viewMatrix = glm::translate(glm::mat4(1.0f), glm::vec3(0.0f, 0.0f, zoom));
|
||||||
|
|
||||||
uboVS.model = viewMatrix * glm::translate(glm::mat4(), cameraPos);
|
uboVS.model = viewMatrix * glm::translate(glm::mat4(1.0f), cameraPos);
|
||||||
uboVS.model = glm::rotate(uboVS.model, glm::radians(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f));
|
uboVS.model = glm::rotate(uboVS.model, glm::radians(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f));
|
||||||
uboVS.model = glm::rotate(uboVS.model, glm::radians(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f));
|
uboVS.model = glm::rotate(uboVS.model, glm::radians(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f));
|
||||||
uboVS.model = glm::rotate(uboVS.model, glm::radians(rotation.z), glm::vec3(0.0f, 0.0f, 1.0f));
|
uboVS.model = glm::rotate(uboVS.model, glm::radians(rotation.z), glm::vec3(0.0f, 0.0f, 1.0f));
|
||||||
|
|
||||||
uboVS.projection = camera.matrices.perspective;
|
uboVS.projection = camera.matrices.perspective;
|
||||||
uboVS.model = camera.matrices.view;
|
uboVS.model = camera.matrices.view;
|
||||||
//uboVS.model = glm::mat4();
|
//uboVS.model = glm::mat4(1.0f);
|
||||||
|
|
||||||
uboVS.viewPos = glm::vec4(0.0f, 0.0f, -zoom, 0.0f);
|
uboVS.viewPos = glm::vec4(0.0f, 0.0f, -zoom, 0.0f);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1051,9 +1051,9 @@ public:
|
||||||
// Update matrices
|
// Update matrices
|
||||||
uboVS.projectionMatrix = glm::perspective(glm::radians(60.0f), (float)width / (float)height, 0.1f, 256.0f);
|
uboVS.projectionMatrix = glm::perspective(glm::radians(60.0f), (float)width / (float)height, 0.1f, 256.0f);
|
||||||
|
|
||||||
uboVS.viewMatrix = glm::translate(glm::mat4(), glm::vec3(0.0f, 0.0f, zoom));
|
uboVS.viewMatrix = glm::translate(glm::mat4(1.0f), glm::vec3(0.0f, 0.0f, zoom));
|
||||||
|
|
||||||
uboVS.modelMatrix = glm::mat4();
|
uboVS.modelMatrix = glm::mat4(1.0f);
|
||||||
uboVS.modelMatrix = glm::rotate(uboVS.modelMatrix, glm::radians(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f));
|
uboVS.modelMatrix = glm::rotate(uboVS.modelMatrix, glm::radians(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f));
|
||||||
uboVS.modelMatrix = glm::rotate(uboVS.modelMatrix, glm::radians(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f));
|
uboVS.modelMatrix = glm::rotate(uboVS.modelMatrix, glm::radians(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f));
|
||||||
uboVS.modelMatrix = glm::rotate(uboVS.modelMatrix, glm::radians(rotation.z), glm::vec3(0.0f, 0.0f, 1.0f));
|
uboVS.modelMatrix = glm::rotate(uboVS.modelMatrix, glm::radians(rotation.z), glm::vec3(0.0f, 0.0f, 1.0f));
|
||||||
|
|
|
||||||
|
|
@ -316,7 +316,7 @@ public:
|
||||||
camFront = glm::normalize(camFront);
|
camFront = glm::normalize(camFront);
|
||||||
glm::vec3 camRight = glm::normalize(glm::cross(camFront, glm::vec3(0.0f, 1.0f, 0.0f)));
|
glm::vec3 camRight = glm::normalize(glm::cross(camFront, glm::vec3(0.0f, 1.0f, 0.0f)));
|
||||||
|
|
||||||
glm::mat4 rotM = glm::mat4();
|
glm::mat4 rotM = glm::mat4(1.0f);
|
||||||
glm::mat4 transM;
|
glm::mat4 transM;
|
||||||
|
|
||||||
rotM = glm::rotate(rotM, glm::radians(camera.rotation.x), glm::vec3(1.0f, 0.0f, 0.0f));
|
rotM = glm::rotate(rotM, glm::radians(camera.rotation.x), glm::vec3(1.0f, 0.0f, 0.0f));
|
||||||
|
|
@ -327,7 +327,7 @@ public:
|
||||||
left = -aspectRatio * wd2 + 0.5f * eyeSeparation * ndfl;
|
left = -aspectRatio * wd2 + 0.5f * eyeSeparation * ndfl;
|
||||||
right = aspectRatio * wd2 + 0.5f * eyeSeparation * ndfl;
|
right = aspectRatio * wd2 + 0.5f * eyeSeparation * ndfl;
|
||||||
|
|
||||||
transM = glm::translate(glm::mat4(), camera.position - camRight * (eyeSeparation / 2.0f));
|
transM = glm::translate(glm::mat4(1.0f), camera.position - camRight * (eyeSeparation / 2.0f));
|
||||||
|
|
||||||
uboGS.projection[0] = glm::frustum(left, right, bottom, top, zNear, zFar);
|
uboGS.projection[0] = glm::frustum(left, right, bottom, top, zNear, zFar);
|
||||||
uboGS.modelview[0] = rotM * transM;
|
uboGS.modelview[0] = rotM * transM;
|
||||||
|
|
@ -336,7 +336,7 @@ public:
|
||||||
left = -aspectRatio * wd2 - 0.5f * eyeSeparation * ndfl;
|
left = -aspectRatio * wd2 - 0.5f * eyeSeparation * ndfl;
|
||||||
right = aspectRatio * wd2 - 0.5f * eyeSeparation * ndfl;
|
right = aspectRatio * wd2 - 0.5f * eyeSeparation * ndfl;
|
||||||
|
|
||||||
transM = glm::translate(glm::mat4(), camera.position + camRight * (eyeSeparation / 2.0f));
|
transM = glm::translate(glm::mat4(1.0f), camera.position + camRight * (eyeSeparation / 2.0f));
|
||||||
|
|
||||||
uboGS.projection[1] = glm::frustum(left, right, bottom, top, zNear, zFar);
|
uboGS.projection[1] = glm::frustum(left, right, bottom, top, zNear, zFar);
|
||||||
uboGS.modelview[1] = rotM * transM;
|
uboGS.modelview[1] = rotM * transM;
|
||||||
|
|
|
||||||
|
|
@ -394,7 +394,7 @@ public:
|
||||||
glm::vec3(0, 1, 0)
|
glm::vec3(0, 1, 0)
|
||||||
);
|
);
|
||||||
|
|
||||||
uboVS.model = glm::mat4();
|
uboVS.model = glm::mat4(1.0f);
|
||||||
uboVS.model = glm::rotate(uboVS.model, glm::radians(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f));
|
uboVS.model = glm::rotate(uboVS.model, glm::radians(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f));
|
||||||
uboVS.model = glm::rotate(uboVS.model, glm::radians(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f));
|
uboVS.model = glm::rotate(uboVS.model, glm::radians(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f));
|
||||||
uboVS.model = glm::rotate(uboVS.model, glm::radians(rotation.z), glm::vec3(0.0f, 0.0f, 1.0f));
|
uboVS.model = glm::rotate(uboVS.model, glm::radians(rotation.z), glm::vec3(0.0f, 0.0f, 1.0f));
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue