void updateUniformBuffers(bool viewchanged = true) { if (viewchanged) { 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)); uboVS.model = viewMatrix * glm::translate(glm::mat4(), 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.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.viewPos = glm::vec4(0.0f, 0.0f, -zoom, 0.0f); } else { uboVS.depth += frameTimer * 0.15f; if (uboVS.depth > 1.0f) uboVS.depth = uboVS.depth - 1.0f; } VK_CHECK_RESULT(uniformBufferVS.map()); memcpy(uniformBufferVS.mapped, &uboVS, sizeof(uboVS)); uniformBufferVS.unmap(); }
void updateUniformBuffers() { uboVS.projection = camera.matrices.perspective; 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.viewPos = glm::vec4(camera.position, 0.0f) * glm::vec4(-1.0f); VK_CHECK_RESULT(uniformBufferVS.map()); memcpy(uniformBufferVS.mapped, &uboVS, sizeof(uboVS)); uniformBufferVS.unmap(); }