Use glm::radians instead of deg_to_rad (Fixes #37)
This commit is contained in:
parent
575cbdc341
commit
e77884d5bb
25 changed files with 129 additions and 131 deletions
|
|
@ -35,8 +35,6 @@
|
|||
#include "vulkanTextureLoader.hpp"
|
||||
#include "vulkanMeshLoader.hpp"
|
||||
|
||||
#define deg_to_rad(deg) deg * float(M_PI / 180)
|
||||
|
||||
class VulkanExampleBase
|
||||
{
|
||||
private:
|
||||
|
|
|
|||
|
|
@ -1185,17 +1185,17 @@ public:
|
|||
void updateUniformBuffersScene()
|
||||
{
|
||||
// UFO
|
||||
ubos.fullscreen.projection = glm::perspective(deg_to_rad(45.0f), (float)width / (float)height, 0.1f, 256.0f);
|
||||
ubos.fullscreen.projection = glm::perspective(glm::radians(45.0f), (float)width / (float)height, 0.1f, 256.0f);
|
||||
glm::mat4 viewMatrix = glm::translate(glm::mat4(), glm::vec3(0.0f, -1.0f, zoom));
|
||||
|
||||
ubos.fullscreen.model = viewMatrix *
|
||||
glm::translate(glm::mat4(), glm::vec3(sin(deg_to_rad(timer * 360.0f)) * 0.25f, 0.0f, cos(deg_to_rad(timer * 360.0f)) * 0.25f));
|
||||
glm::translate(glm::mat4(), glm::vec3(sin(glm::radians(timer * 360.0f)) * 0.25f, 0.0f, cos(glm::radians(timer * 360.0f)) * 0.25f));
|
||||
|
||||
ubos.fullscreen.model = glm::rotate(ubos.fullscreen.model, deg_to_rad(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f));
|
||||
ubos.fullscreen.model = glm::rotate(ubos.fullscreen.model, -sinf(deg_to_rad(timer * 360.0f)) * 0.15f, glm::vec3(1.0f, 0.0f, 0.0f));
|
||||
ubos.fullscreen.model = glm::rotate(ubos.fullscreen.model, deg_to_rad(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f));
|
||||
ubos.fullscreen.model = glm::rotate(ubos.fullscreen.model, deg_to_rad(timer * 360.0f), glm::vec3(0.0f, 1.0f, 0.0f));
|
||||
ubos.fullscreen.model = glm::rotate(ubos.fullscreen.model, deg_to_rad(rotation.z), glm::vec3(0.0f, 0.0f, 1.0f));
|
||||
ubos.fullscreen.model = glm::rotate(ubos.fullscreen.model, glm::radians(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f));
|
||||
ubos.fullscreen.model = glm::rotate(ubos.fullscreen.model, -sinf(glm::radians(timer * 360.0f)) * 0.15f, glm::vec3(1.0f, 0.0f, 0.0f));
|
||||
ubos.fullscreen.model = glm::rotate(ubos.fullscreen.model, glm::radians(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f));
|
||||
ubos.fullscreen.model = glm::rotate(ubos.fullscreen.model, glm::radians(timer * 360.0f), glm::vec3(0.0f, 1.0f, 0.0f));
|
||||
ubos.fullscreen.model = glm::rotate(ubos.fullscreen.model, glm::radians(rotation.z), glm::vec3(0.0f, 0.0f, 1.0f));
|
||||
|
||||
uint8_t *pData;
|
||||
VkResult err = vkMapMemory(device, uniformData.vsFullScreen.memory, 0, sizeof(ubos.fullscreen), 0, (void **)&pData);
|
||||
|
|
@ -1204,12 +1204,12 @@ public:
|
|||
vkUnmapMemory(device, uniformData.vsFullScreen.memory);
|
||||
|
||||
// Skybox
|
||||
ubos.skyBox.projection = glm::perspective(deg_to_rad(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.model = glm::mat4();
|
||||
ubos.skyBox.model = glm::rotate(ubos.skyBox.model, deg_to_rad(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f));
|
||||
ubos.skyBox.model = glm::rotate(ubos.skyBox.model, deg_to_rad(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f));
|
||||
ubos.skyBox.model = glm::rotate(ubos.skyBox.model, deg_to_rad(rotation.z), glm::vec3(0.0f, 0.0f, 1.0f));
|
||||
ubos.skyBox.model = glm::rotate(ubos.skyBox.model, glm::radians(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f));
|
||||
ubos.skyBox.model = glm::rotate(ubos.skyBox.model, glm::radians(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f));
|
||||
ubos.skyBox.model = glm::rotate(ubos.skyBox.model, glm::radians(rotation.z), glm::vec3(0.0f, 0.0f, 1.0f));
|
||||
|
||||
err = vkMapMemory(device, uniformData.vsSkyBox.memory, 0, sizeof(ubos.skyBox), 0, (void **)&pData);
|
||||
assert(!err);
|
||||
|
|
|
|||
|
|
@ -635,7 +635,7 @@ public:
|
|||
void updateUniformBuffers()
|
||||
{
|
||||
computeUbo.deltaT = frameTimer * 5.0f;
|
||||
computeUbo.destX = sin(deg_to_rad(timer*360.0)) * 0.75f;
|
||||
computeUbo.destX = sin(glm::radians(timer*360.0)) * 0.75f;
|
||||
computeUbo.destY = 0;
|
||||
uint8_t *pData;
|
||||
VkResult err = vkMapMemory(device, uniformData.computeShader.ubo.memory, 0, sizeof(computeUbo), 0, (void **)&pData);
|
||||
|
|
|
|||
|
|
@ -743,14 +743,14 @@ public:
|
|||
{
|
||||
// Vertex shader
|
||||
glm::mat4 viewMatrix = glm::mat4();
|
||||
uboVS.projection = glm::perspective(deg_to_rad(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);
|
||||
viewMatrix = glm::translate(viewMatrix, glm::vec3(0.0f, 0.0f, zoom));
|
||||
|
||||
uboVS.model = glm::mat4();
|
||||
uboVS.model = viewMatrix * glm::translate(uboVS.model, glm::vec3(0, 0, 0));
|
||||
uboVS.model = glm::rotate(uboVS.model, deg_to_rad(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f));
|
||||
uboVS.model = glm::rotate(uboVS.model, deg_to_rad(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f));
|
||||
uboVS.model = glm::rotate(uboVS.model, deg_to_rad(rotation.z), glm::vec3(0.0f, 0.0f, 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.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));
|
||||
|
||||
uint8_t *pData;
|
||||
VkResult err = vkMapMemory(device, uniformDataVS.memory, 0, sizeof(uboVS), 0, (void **)&pData);
|
||||
|
|
|
|||
|
|
@ -1193,11 +1193,11 @@ public:
|
|||
|
||||
void updateUniformBufferDeferredMatrices()
|
||||
{
|
||||
uboOffscreenVS.projection = glm::perspective(deg_to_rad(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::rotate(uboOffscreenVS.view, deg_to_rad(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f));
|
||||
uboOffscreenVS.view = glm::rotate(uboOffscreenVS.view, deg_to_rad(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f));
|
||||
uboOffscreenVS.view = glm::rotate(uboOffscreenVS.view, deg_to_rad(rotation.z), glm::vec3(0.0f, 0.0f, 1.0f));
|
||||
uboOffscreenVS.view = glm::rotate(uboOffscreenVS.view, glm::radians(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f));
|
||||
uboOffscreenVS.view = glm::rotate(uboOffscreenVS.view, glm::radians(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f));
|
||||
uboOffscreenVS.view = glm::rotate(uboOffscreenVS.view, glm::radians(rotation.z), glm::vec3(0.0f, 0.0f, 1.0f));
|
||||
|
||||
uboOffscreenVS.model = glm::mat4();
|
||||
uboOffscreenVS.model = glm::translate(glm::mat4(), glm::vec3(0.0f, 0.25f, 0.0f));
|
||||
|
|
|
|||
|
|
@ -530,16 +530,16 @@ public:
|
|||
{
|
||||
// Tessellation eval
|
||||
glm::mat4 viewMatrix = glm::mat4();
|
||||
uboTE.projection = glm::perspective(deg_to_rad(45.0f), (float)(width* ((splitScreen) ? 0.5f : 1.0f)) / (float)height, 0.1f, 256.0f);
|
||||
uboTE.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));
|
||||
|
||||
float offset = 0.5f;
|
||||
int uboIndex = 1;
|
||||
uboTE.model = glm::mat4();
|
||||
uboTE.model = viewMatrix * glm::translate(uboTE.model, glm::vec3(0, 0, 0));
|
||||
uboTE.model = glm::rotate(uboTE.model, deg_to_rad(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f));
|
||||
uboTE.model = glm::rotate(uboTE.model, deg_to_rad(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f));
|
||||
uboTE.model = glm::rotate(uboTE.model, deg_to_rad(rotation.z), glm::vec3(0.0f, 0.0f, 1.0f));
|
||||
uboTE.model = glm::rotate(uboTE.model, glm::radians(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f));
|
||||
uboTE.model = glm::rotate(uboTE.model, glm::radians(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f));
|
||||
uboTE.model = glm::rotate(uboTE.model, glm::radians(rotation.z), glm::vec3(0.0f, 0.0f, 1.0f));
|
||||
|
||||
uint8_t *pData;
|
||||
VkResult err = vkMapMemory(device, uniformDataTE.memory, 0, sizeof(uboTE), 0, (void **)&pData);
|
||||
|
|
|
|||
|
|
@ -688,14 +688,14 @@ public:
|
|||
{
|
||||
// Vertex shader
|
||||
glm::mat4 viewMatrix = glm::mat4();
|
||||
uboVS.projection = glm::perspective(deg_to_rad(splitScreen ? 45.0f : 60.0f), (float)width / (float)(height * ((splitScreen) ? 0.5f : 1.0f)), 0.001f, 256.0f);
|
||||
uboVS.projection = glm::perspective(glm::radians(splitScreen ? 45.0f : 60.0f), (float)width / (float)(height * ((splitScreen) ? 0.5f : 1.0f)), 0.001f, 256.0f);
|
||||
viewMatrix = glm::translate(viewMatrix, glm::vec3(0.0f, 0.0f, zoom));
|
||||
|
||||
uboVS.model = glm::mat4();
|
||||
uboVS.model = viewMatrix * glm::translate(uboVS.model, glm::vec3(0, 0, 0));
|
||||
uboVS.model = glm::rotate(uboVS.model, deg_to_rad(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f));
|
||||
uboVS.model = glm::rotate(uboVS.model, deg_to_rad(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f));
|
||||
uboVS.model = glm::rotate(uboVS.model, deg_to_rad(rotation.z), glm::vec3(0.0f, 0.0f, 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.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));
|
||||
|
||||
uint8_t *pData;
|
||||
VkResult err = vkMapMemory(device, uniformData.vs.memory, 0, sizeof(uboVS), 0, (void **)&pData);
|
||||
|
|
|
|||
|
|
@ -359,7 +359,7 @@ public:
|
|||
|
||||
void updateUniformBuffers()
|
||||
{
|
||||
glm::mat4 perspective = glm::perspective(deg_to_rad(60.0f), (float)width / (float)height, 0.001f, 256.0f);
|
||||
glm::mat4 perspective = glm::perspective(glm::radians(60.0f), (float)width / (float)height, 0.001f, 256.0f);
|
||||
for (auto& gear : gears)
|
||||
{
|
||||
gear->updateUniformBuffer(perspective, rotation, zoom, timer * 360.0f);
|
||||
|
|
|
|||
|
|
@ -244,20 +244,20 @@ void VulkanGear::updateUniformBuffer(glm::mat4 perspective, glm::vec3 rotation,
|
|||
glm::vec3(-1.0, -1.5, 0),
|
||||
glm::vec3(0, 1, 0)
|
||||
);
|
||||
ubo.view = glm::rotate(ubo.view, deg_to_rad(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f));
|
||||
ubo.view = glm::rotate(ubo.view, deg_to_rad(rotation.y), glm::vec3(0.0f, 1.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.model = glm::mat4();
|
||||
ubo.model = glm::translate(ubo.model, pos);
|
||||
rotation.z = (rotSpeed * timer) + rotOffset;
|
||||
ubo.model = glm::rotate(ubo.model, deg_to_rad(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));
|
||||
|
||||
ubo.normal = glm::inverseTranspose(ubo.view * ubo.model);
|
||||
|
||||
//ubo.lightPos = lightPos;
|
||||
ubo.lightPos = glm::vec3(0.0f, 0.0f, 2.5f);
|
||||
ubo.lightPos.x = sin(deg_to_rad(timer)) * 8.0f;
|
||||
ubo.lightPos.z = cos(deg_to_rad(timer)) * 8.0f;
|
||||
ubo.lightPos.x = sin(glm::radians(timer)) * 8.0f;
|
||||
ubo.lightPos.z = cos(glm::radians(timer)) * 8.0f;
|
||||
|
||||
uint8_t *pData;
|
||||
VkResult err = vkMapMemory(device, uniformData.memory, 0, sizeof(ubo), 0, (void **)&pData);
|
||||
|
|
@ -265,7 +265,7 @@ void VulkanGear::updateUniformBuffer(glm::mat4 perspective, glm::vec3 rotation,
|
|||
memcpy(pData, &ubo, sizeof(ubo));
|
||||
vkUnmapMemory(device, uniformData.memory);
|
||||
|
||||
#undef deg_to_rad
|
||||
#undef glm::radians
|
||||
}
|
||||
|
||||
void VulkanGear::setupDescriptorSet(VkDescriptorPool pool, VkDescriptorSetLayout descriptorSetLayout)
|
||||
|
|
|
|||
|
|
@ -438,16 +438,16 @@ public:
|
|||
{
|
||||
// Vertex shader
|
||||
glm::mat4 viewMatrix = glm::mat4();
|
||||
uboVS.projection = glm::perspective(deg_to_rad(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));
|
||||
|
||||
float offset = 0.5f;
|
||||
int uboIndex = 1;
|
||||
uboVS.model = glm::mat4();
|
||||
uboVS.model = viewMatrix * glm::translate(uboVS.model, glm::vec3(0, 0, 0));
|
||||
uboVS.model = glm::rotate(uboVS.model, deg_to_rad(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f));
|
||||
uboVS.model = glm::rotate(uboVS.model, deg_to_rad(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f));
|
||||
uboVS.model = glm::rotate(uboVS.model, deg_to_rad(rotation.z), glm::vec3(0.0f, 0.0f, 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.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));
|
||||
|
||||
uint8_t *pData;
|
||||
VkResult err = vkMapMemory(device, uniformData.VS.memory, 0, sizeof(uboVS), 0, (void **)&pData);
|
||||
|
|
|
|||
|
|
@ -426,7 +426,7 @@ public:
|
|||
{
|
||||
// Instance model matrix
|
||||
uboVS.instance[index].model = glm::translate(glm::mat4(), glm::vec3(x * offset, y * offset, z * offset));
|
||||
uboVS.instance[index].model = glm::rotate(uboVS.instance[index].model, deg_to_rad(-45.0f), glm::vec3(0.0f, 1.0f, 0.0f));
|
||||
uboVS.instance[index].model = glm::rotate(uboVS.instance[index].model, glm::radians(-45.0f), glm::vec3(0.0f, 1.0f, 0.0f));
|
||||
// Instance color (randomized)
|
||||
uboVS.instance[index].color = glm::vec4((float)(rand() % 255) / 255.0f, (float)(rand() % 255) / 255.0f, (float)(rand() % 255) / 255.0f, 1.0);
|
||||
index++;
|
||||
|
|
@ -451,13 +451,13 @@ public:
|
|||
// Only updates the uniform buffer block part containing the global matrices
|
||||
|
||||
// Projection
|
||||
uboVS.matrices.projection = glm::perspective(deg_to_rad(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
|
||||
uboVS.matrices.view = glm::translate(glm::mat4(), glm::vec3(0.0f, 0.0f, zoom));
|
||||
uboVS.matrices.view = glm::rotate(uboVS.matrices.view, deg_to_rad(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f));
|
||||
uboVS.matrices.view = glm::rotate(uboVS.matrices.view, deg_to_rad(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f));
|
||||
uboVS.matrices.view = glm::rotate(uboVS.matrices.view, deg_to_rad(rotation.z), glm::vec3(0.0f, 0.0f, 1.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.z), glm::vec3(0.0f, 0.0f, 1.0f));
|
||||
|
||||
// Only update the matrices part of the uniform buffer
|
||||
uint8_t *pData;
|
||||
|
|
|
|||
|
|
@ -497,16 +497,16 @@ public:
|
|||
{
|
||||
// Vertex shader
|
||||
glm::mat4 viewMatrix = glm::mat4();
|
||||
uboVS.projection = glm::perspective(deg_to_rad(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));
|
||||
|
||||
float offset = 0.5f;
|
||||
int uboIndex = 1;
|
||||
uboVS.model = glm::mat4();
|
||||
uboVS.model = viewMatrix * glm::translate(uboVS.model, glm::vec3(0, 0, 0));
|
||||
uboVS.model = glm::rotate(uboVS.model, deg_to_rad(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f));
|
||||
uboVS.model = glm::rotate(uboVS.model, deg_to_rad(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f));
|
||||
uboVS.model = glm::rotate(uboVS.model, deg_to_rad(rotation.z), glm::vec3(0.0f, 0.0f, 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.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));
|
||||
|
||||
uint8_t *pData;
|
||||
VkResult err = vkMapMemory(device, uniformData.vsScene.memory, 0, sizeof(uboVS), 0, (void **)&pData);
|
||||
|
|
|
|||
|
|
@ -619,13 +619,13 @@ public:
|
|||
{
|
||||
// Vertex shader
|
||||
glm::mat4 viewMatrix = glm::mat4();
|
||||
uboVS.projection = glm::perspective(deg_to_rad(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));
|
||||
|
||||
glm::mat4 rotMatrix = glm::mat4();
|
||||
rotMatrix = glm::rotate(rotMatrix, deg_to_rad(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f));
|
||||
rotMatrix = glm::rotate(rotMatrix, deg_to_rad(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f));
|
||||
rotMatrix = glm::rotate(rotMatrix, deg_to_rad(rotation.z), glm::vec3(0.0f, 0.0f, 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.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));
|
||||
|
||||
uboVS.model = glm::mat4();
|
||||
uboVS.model = viewMatrix * rotMatrix;;
|
||||
|
|
|
|||
|
|
@ -1036,13 +1036,13 @@ public:
|
|||
void updateUniformBuffers()
|
||||
{
|
||||
// Mesh
|
||||
ubos.vsShared.projection = glm::perspective(deg_to_rad(60.0f), (float)width / (float)height, 0.1f, 256.0f);
|
||||
ubos.vsShared.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));
|
||||
|
||||
ubos.vsShared.model = viewMatrix * glm::translate(glm::mat4(), glm::vec3(0, 0, 0));
|
||||
ubos.vsShared.model = glm::rotate(ubos.vsShared.model, deg_to_rad(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f));
|
||||
ubos.vsShared.model = glm::rotate(ubos.vsShared.model, deg_to_rad(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f));
|
||||
ubos.vsShared.model = glm::rotate(ubos.vsShared.model, deg_to_rad(rotation.z), glm::vec3(0.0f, 0.0f, 1.0f));
|
||||
ubos.vsShared.model = glm::rotate(ubos.vsShared.model, glm::radians(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f));
|
||||
ubos.vsShared.model = glm::rotate(ubos.vsShared.model, glm::radians(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f));
|
||||
ubos.vsShared.model = glm::rotate(ubos.vsShared.model, glm::radians(rotation.z), glm::vec3(0.0f, 0.0f, 1.0f));
|
||||
|
||||
ubos.vsShared.model = glm::translate(ubos.vsShared.model, meshPos);
|
||||
|
||||
|
|
@ -1054,9 +1054,9 @@ public:
|
|||
|
||||
// Mirror
|
||||
ubos.vsShared.model = viewMatrix * glm::translate(glm::mat4(), glm::vec3(0, 0, 0));
|
||||
ubos.vsShared.model = glm::rotate(ubos.vsShared.model, deg_to_rad(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f));
|
||||
ubos.vsShared.model = glm::rotate(ubos.vsShared.model, deg_to_rad(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f));
|
||||
ubos.vsShared.model = glm::rotate(ubos.vsShared.model, deg_to_rad(rotation.z), glm::vec3(0.0f, 0.0f, 1.0f));
|
||||
ubos.vsShared.model = glm::rotate(ubos.vsShared.model, glm::radians(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f));
|
||||
ubos.vsShared.model = glm::rotate(ubos.vsShared.model, glm::radians(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f));
|
||||
ubos.vsShared.model = glm::rotate(ubos.vsShared.model, glm::radians(rotation.z), glm::vec3(0.0f, 0.0f, 1.0f));
|
||||
|
||||
err = vkMapMemory(device, uniformData.vsMirror.memory, 0, sizeof(ubos.vsShared), 0, (void **)&pData);
|
||||
assert(!err);
|
||||
|
|
@ -1075,13 +1075,13 @@ public:
|
|||
|
||||
void updateUniformBufferOffscreen()
|
||||
{
|
||||
ubos.vsShared.projection = glm::perspective(deg_to_rad(60.0f), (float)width / (float)height, 0.1f, 256.0f);
|
||||
ubos.vsShared.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));
|
||||
|
||||
ubos.vsShared.model = viewMatrix * glm::translate(glm::mat4(), glm::vec3(0, 0, 0));
|
||||
ubos.vsShared.model = glm::rotate(ubos.vsShared.model, deg_to_rad(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f));
|
||||
ubos.vsShared.model = glm::rotate(ubos.vsShared.model, deg_to_rad(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f));
|
||||
ubos.vsShared.model = glm::rotate(ubos.vsShared.model, deg_to_rad(rotation.z), glm::vec3(0.0f, 0.0f, 1.0f));
|
||||
ubos.vsShared.model = glm::rotate(ubos.vsShared.model, glm::radians(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f));
|
||||
ubos.vsShared.model = glm::rotate(ubos.vsShared.model, glm::radians(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f));
|
||||
ubos.vsShared.model = glm::rotate(ubos.vsShared.model, glm::radians(rotation.z), glm::vec3(0.0f, 0.0f, 1.0f));
|
||||
|
||||
ubos.vsShared.model = glm::scale(ubos.vsShared.model, glm::vec3(1.0f, -1.0f, 1.0f));
|
||||
ubos.vsShared.model = glm::translate(ubos.vsShared.model, meshPos);
|
||||
|
|
|
|||
|
|
@ -525,21 +525,21 @@ public:
|
|||
{
|
||||
// Vertex shader
|
||||
glm::mat4 viewMatrix = glm::mat4();
|
||||
ubos.vertexShader.projection = glm::perspective(deg_to_rad(45.0f), (float)(width* ((splitScreen) ? 0.5f : 1.0f)) / (float)height, 0.001f, 256.0f);
|
||||
ubos.vertexShader.projection = glm::perspective(glm::radians(45.0f), (float)(width* ((splitScreen) ? 0.5f : 1.0f)) / (float)height, 0.001f, 256.0f);
|
||||
viewMatrix = glm::translate(viewMatrix, glm::vec3(0.0f, 0.0f, zoom));
|
||||
|
||||
ubos.vertexShader.model = glm::mat4();
|
||||
ubos.vertexShader.model = viewMatrix * glm::translate(ubos.vertexShader.model, glm::vec3(0, 0, 0));
|
||||
ubos.vertexShader.model = glm::rotate(ubos.vertexShader.model, deg_to_rad(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f));
|
||||
ubos.vertexShader.model = glm::rotate(ubos.vertexShader.model, deg_to_rad(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f));
|
||||
ubos.vertexShader.model = glm::rotate(ubos.vertexShader.model, deg_to_rad(rotation.z), glm::vec3(0.0f, 0.0f, 1.0f));
|
||||
ubos.vertexShader.model = glm::rotate(ubos.vertexShader.model, glm::radians(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f));
|
||||
ubos.vertexShader.model = glm::rotate(ubos.vertexShader.model, glm::radians(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f));
|
||||
ubos.vertexShader.model = glm::rotate(ubos.vertexShader.model, glm::radians(rotation.z), glm::vec3(0.0f, 0.0f, 1.0f));
|
||||
|
||||
ubos.vertexShader.normal = glm::inverseTranspose(ubos.vertexShader.model);
|
||||
|
||||
if (!paused)
|
||||
{
|
||||
ubos.vertexShader.lightPos.x = sin(deg_to_rad(timer * 360.0f)) * 0.5;
|
||||
ubos.vertexShader.lightPos.y = cos(deg_to_rad(timer * 360.0f)) * 0.5;
|
||||
ubos.vertexShader.lightPos.x = sin(glm::radians(timer * 360.0f)) * 0.5;
|
||||
ubos.vertexShader.lightPos.y = cos(glm::radians(timer * 360.0f)) * 0.5;
|
||||
}
|
||||
|
||||
ubos.vertexShader.cameraPos = glm::vec4(0.0, 0.0, zoom, 0.0);
|
||||
|
|
|
|||
|
|
@ -540,14 +540,14 @@ public:
|
|||
|
||||
void updateUniformBuffers()
|
||||
{
|
||||
uboVS.projectionMatrix = glm::perspective(deg_to_rad(60.0f), (float)(width / 3.0f) / (float)height, 0.1f, 256.0f);
|
||||
uboVS.projectionMatrix = glm::perspective(glm::radians(60.0f), (float)(width / 3.0f) / (float)height, 0.1f, 256.0f);
|
||||
|
||||
uboVS.viewMatrix = glm::translate(glm::mat4(), glm::vec3(0.0f, 0.0f, zoom));
|
||||
|
||||
uboVS.modelMatrix = glm::mat4();
|
||||
uboVS.modelMatrix = glm::rotate(uboVS.modelMatrix, deg_to_rad(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f));
|
||||
uboVS.modelMatrix = glm::rotate(uboVS.modelMatrix, deg_to_rad(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f));
|
||||
uboVS.modelMatrix = glm::rotate(uboVS.modelMatrix, deg_to_rad(rotation.z), glm::vec3(0.0f, 0.0f, 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.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));
|
||||
|
||||
uint8_t *pData;
|
||||
VkResult err = vkMapMemory(device, uniformDataVS.memory, 0, sizeof(uboVS), 0, (void **)&pData);
|
||||
|
|
|
|||
|
|
@ -157,15 +157,15 @@ public:
|
|||
// Update light positions
|
||||
// w component = light radius scale
|
||||
#define r 7.5f
|
||||
#define sin_t sin(deg_to_rad(timer * 360))
|
||||
#define cos_t cos(deg_to_rad(timer * 360))
|
||||
#define sin_t sin(glm::radians(timer * 360))
|
||||
#define cos_t cos(glm::radians(timer * 360))
|
||||
#define y -4.0f
|
||||
pushConstants[0] = glm::vec4(r * 1.1 * sin_t, y, r * 1.1 * cos_t, 1.0f);
|
||||
pushConstants[1] = glm::vec4(-r * sin_t, y, -r * cos_t, 1.0f);
|
||||
pushConstants[2] = glm::vec4(r * 0.85f * sin_t, y, -sin_t * 2.5f, 1.5f);
|
||||
pushConstants[3] = glm::vec4(0.0f, y, r * 1.25f * cos_t, 1.5f);
|
||||
pushConstants[4] = glm::vec4(r * 2.25f * cos_t, y, 0.0f, 1.25f);
|
||||
pushConstants[5] = glm::vec4(r * 2.5f * cos(deg_to_rad(timer * 360)), y, r * 2.5f * sin_t, 1.25f);
|
||||
pushConstants[5] = glm::vec4(r * 2.5f * cos(glm::radians(timer * 360)), y, r * 2.5f * sin_t, 1.25f);
|
||||
#undef r
|
||||
#undef y
|
||||
#undef sin_t
|
||||
|
|
@ -457,15 +457,15 @@ public:
|
|||
{
|
||||
// Vertex shader
|
||||
glm::mat4 viewMatrix = glm::mat4();
|
||||
uboVS.projection = glm::perspective(deg_to_rad(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));
|
||||
|
||||
float offset = 0.5f;
|
||||
int uboIndex = 1;
|
||||
uboVS.model = viewMatrix * glm::translate(glm::mat4(), glm::vec3(0, 0, 0));
|
||||
uboVS.model = glm::rotate(uboVS.model, deg_to_rad(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f));
|
||||
uboVS.model = glm::rotate(uboVS.model, deg_to_rad(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f));
|
||||
uboVS.model = glm::rotate(uboVS.model, deg_to_rad(rotation.z), glm::vec3(0.0f, 0.0f, 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.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));
|
||||
|
||||
uint8_t *pData;
|
||||
VkResult err = vkMapMemory(device, uniformData.vertexShader.memory, 0, sizeof(uboVS), 0, (void **)&pData);
|
||||
|
|
|
|||
|
|
@ -980,15 +980,15 @@ public:
|
|||
// Update uniform buffers for rendering the 3D scene
|
||||
void updateUniformBuffersScene()
|
||||
{
|
||||
uboQuadVS.projection = glm::perspective(deg_to_rad(45.0f), (float)width / (float)height, 1.0f, 256.0f);
|
||||
uboQuadVS.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));
|
||||
|
||||
uboQuadVS.model = glm::mat4();
|
||||
uboQuadVS.model = viewMatrix * glm::translate(uboQuadVS.model, glm::vec3(0, 0, 0));
|
||||
uboQuadVS.model = glm::rotate(uboQuadVS.model, deg_to_rad(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f));
|
||||
uboQuadVS.model = glm::rotate(uboQuadVS.model, deg_to_rad(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f));
|
||||
uboQuadVS.model = glm::rotate(uboQuadVS.model, deg_to_rad(timer * 360.0f), glm::vec3(0.0f, 1.0f, 0.0f));
|
||||
uboQuadVS.model = glm::rotate(uboQuadVS.model, deg_to_rad(rotation.z), glm::vec3(0.0f, 0.0f, 1.0f));
|
||||
uboQuadVS.model = glm::rotate(uboQuadVS.model, glm::radians(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f));
|
||||
uboQuadVS.model = glm::rotate(uboQuadVS.model, glm::radians(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f));
|
||||
uboQuadVS.model = glm::rotate(uboQuadVS.model, glm::radians(timer * 360.0f), glm::vec3(0.0f, 1.0f, 0.0f));
|
||||
uboQuadVS.model = glm::rotate(uboQuadVS.model, glm::radians(rotation.z), glm::vec3(0.0f, 0.0f, 1.0f));
|
||||
|
||||
uint8_t *pData;
|
||||
VkResult err = vkMapMemory(device, uniformData.vsQuad.memory, 0, sizeof(uboQuadVS), 0, (void **)&pData);
|
||||
|
|
|
|||
|
|
@ -437,24 +437,24 @@ public:
|
|||
switch (faceIndex)
|
||||
{
|
||||
case 0: // POSITIVE_X
|
||||
viewMatrix = glm::rotate(viewMatrix, deg_to_rad(90.0f), glm::vec3(0.0f, 1.0f, 0.0f));
|
||||
viewMatrix = glm::rotate(viewMatrix, deg_to_rad(180.0f), glm::vec3(1.0f, 0.0f, 0.0f));
|
||||
viewMatrix = glm::rotate(viewMatrix, glm::radians(90.0f), glm::vec3(0.0f, 1.0f, 0.0f));
|
||||
viewMatrix = glm::rotate(viewMatrix, glm::radians(180.0f), glm::vec3(1.0f, 0.0f, 0.0f));
|
||||
break;
|
||||
case 1: // NEGATIVE_X
|
||||
viewMatrix = glm::rotate(viewMatrix, deg_to_rad(-90), glm::vec3(0.0f, 1.0f, 0.0f));
|
||||
viewMatrix = glm::rotate(viewMatrix, deg_to_rad(180.0f), glm::vec3(1.0f, 0.0f, 0.0f));
|
||||
viewMatrix = glm::rotate(viewMatrix, glm::radians(-90.0f), glm::vec3(0.0f, 1.0f, 0.0f));
|
||||
viewMatrix = glm::rotate(viewMatrix, glm::radians(180.0f), glm::vec3(1.0f, 0.0f, 0.0f));
|
||||
break;
|
||||
case 2: // POSITIVE_Y
|
||||
viewMatrix = glm::rotate(viewMatrix, deg_to_rad(-90), glm::vec3(1.0f, 0.0f, 0.0f));
|
||||
viewMatrix = glm::rotate(viewMatrix, glm::radians(-90.0f), glm::vec3(1.0f, 0.0f, 0.0f));
|
||||
break;
|
||||
case 3: // NEGATIVE_Y
|
||||
viewMatrix = glm::rotate(viewMatrix, deg_to_rad(90), glm::vec3(1.0f, 0.0f, 0.0f));
|
||||
viewMatrix = glm::rotate(viewMatrix, glm::radians(90.0f), glm::vec3(1.0f, 0.0f, 0.0f));
|
||||
break;
|
||||
case 4: // POSITIVE_Z
|
||||
viewMatrix = glm::rotate(viewMatrix, deg_to_rad(180), glm::vec3(1.0f, 0.0f, 0.0f));
|
||||
viewMatrix = glm::rotate(viewMatrix, glm::radians(180.0f), glm::vec3(1.0f, 0.0f, 0.0f));
|
||||
break;
|
||||
case 5: // NEGATIVE_Z
|
||||
viewMatrix = glm::rotate(viewMatrix, deg_to_rad(180), glm::vec3(0.0f, 0.0f, 1.0f));
|
||||
viewMatrix = glm::rotate(viewMatrix, glm::radians(180.0f), glm::vec3(0.0f, 0.0f, 1.0f));
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
@ -986,13 +986,13 @@ public:
|
|||
void updateUniformBuffers()
|
||||
{
|
||||
// 3D scene
|
||||
uboVSscene.projection = glm::perspective(deg_to_rad(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.model = glm::mat4();
|
||||
uboVSscene.model = glm::rotate(uboVSscene.model, deg_to_rad(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f));
|
||||
uboVSscene.model = glm::rotate(uboVSscene.model, deg_to_rad(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f));
|
||||
uboVSscene.model = glm::rotate(uboVSscene.model, deg_to_rad(rotation.z), glm::vec3(0.0f, 0.0f, 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.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.lightPos = lightPos;
|
||||
|
||||
|
|
@ -1005,8 +1005,8 @@ public:
|
|||
|
||||
void updateUniformBufferOffscreen()
|
||||
{
|
||||
lightPos.x = sin(deg_to_rad(timer * 360.0f)) * 1.0f;
|
||||
lightPos.z = cos(deg_to_rad(timer * 360.0f)) * 1.0f;
|
||||
lightPos.x = sin(glm::radians(timer * 360.0f)) * 1.0f;
|
||||
lightPos.z = cos(glm::radians(timer * 360.0f)) * 1.0f;
|
||||
|
||||
uboOffscreenVS.projection = glm::perspective((float)(M_PI / 2.0), 1.0f, zNear, zFar);
|
||||
|
||||
|
|
|
|||
|
|
@ -796,16 +796,16 @@ public:
|
|||
void updateUniformBuffers()
|
||||
{
|
||||
// Vertex shader
|
||||
uboVS.projection = glm::perspective(deg_to_rad(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));
|
||||
viewMatrix = glm::rotate(viewMatrix, deg_to_rad(90), glm::vec3(1.0f, 0.0f, 0.0f));
|
||||
viewMatrix = glm::rotate(viewMatrix, glm::radians(90.0f), glm::vec3(1.0f, 0.0f, 0.0f));
|
||||
|
||||
uboVS.model = glm::mat4();
|
||||
uboVS.model = viewMatrix * glm::translate(uboVS.model, glm::vec3(0.0f, 0.0f, -3.5f));
|
||||
uboVS.model = glm::rotate(uboVS.model, deg_to_rad(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f));
|
||||
uboVS.model = glm::rotate(uboVS.model, deg_to_rad(rotation.z), glm::vec3(0.0f, 1.0f, 0.0f));
|
||||
uboVS.model = glm::rotate(uboVS.model, deg_to_rad(-rotation.y), glm::vec3(0.0f, 0.0f, 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.z), glm::vec3(0.0f, 1.0f, 0.0f));
|
||||
uboVS.model = glm::rotate(uboVS.model, glm::radians(-rotation.y), glm::vec3(0.0f, 0.0f, 1.0f));
|
||||
|
||||
// Update bones
|
||||
std::vector<aiMatrix4x4> boneTransforms;
|
||||
|
|
|
|||
|
|
@ -508,16 +508,16 @@ public:
|
|||
{
|
||||
// Tessellation eval
|
||||
glm::mat4 viewMatrix = glm::mat4();
|
||||
uboTE.projection = glm::perspective(deg_to_rad(45.0f), (float)(width* ((splitScreen) ? 0.5f : 1.0f)) / (float)height, 0.1f, 256.0f);
|
||||
uboTE.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));
|
||||
|
||||
float offset = 0.5f;
|
||||
int uboIndex = 1;
|
||||
uboTE.model = glm::mat4();
|
||||
uboTE.model = viewMatrix * glm::translate(uboTE.model, glm::vec3(0, 0, 0));
|
||||
uboTE.model = glm::rotate(uboTE.model, deg_to_rad(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f));
|
||||
uboTE.model = glm::rotate(uboTE.model, deg_to_rad(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f));
|
||||
uboTE.model = glm::rotate(uboTE.model, deg_to_rad(rotation.z), glm::vec3(0.0f, 0.0f, 1.0f));
|
||||
uboTE.model = glm::rotate(uboTE.model, glm::radians(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f));
|
||||
uboTE.model = glm::rotate(uboTE.model, glm::radians(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f));
|
||||
uboTE.model = glm::rotate(uboTE.model, glm::radians(rotation.z), glm::vec3(0.0f, 0.0f, 1.0f));
|
||||
|
||||
uint8_t *pData;
|
||||
VkResult err = vkMapMemory(device, uniformDataTE.memory, 0, sizeof(uboTE), 0, (void **)&pData);
|
||||
|
|
|
|||
|
|
@ -790,14 +790,14 @@ public:
|
|||
{
|
||||
// Vertex shader
|
||||
glm::mat4 viewMatrix = glm::mat4();
|
||||
uboVS.projection = glm::perspective(deg_to_rad(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));
|
||||
|
||||
uboVS.model = glm::mat4();
|
||||
uboVS.model = viewMatrix * glm::translate(uboVS.model, glm::vec3(0, 0, 0));
|
||||
uboVS.model = glm::rotate(uboVS.model, deg_to_rad(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f));
|
||||
uboVS.model = glm::rotate(uboVS.model, deg_to_rad(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f));
|
||||
uboVS.model = glm::rotate(uboVS.model, deg_to_rad(rotation.z), glm::vec3(0.0f, 0.0f, 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.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));
|
||||
|
||||
uint8_t *pData;
|
||||
VkResult err = vkMapMemory(device, uniformDataVS.memory, 0, sizeof(uboVS), 0, (void **)&pData);
|
||||
|
|
|
|||
|
|
@ -667,7 +667,7 @@ public:
|
|||
{
|
||||
// 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::rotate(uboVS.instance[i].model, deg_to_rad(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
|
||||
uboVS.instance[i].arrayIndex.x = i;
|
||||
}
|
||||
|
|
@ -689,13 +689,13 @@ public:
|
|||
// Only updates the uniform buffer block part containing the global matrices
|
||||
|
||||
// Projection
|
||||
uboVS.matrices.projection = glm::perspective(deg_to_rad(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
|
||||
uboVS.matrices.view = glm::translate(glm::mat4(), glm::vec3(0.0f, -1.0f, zoom));
|
||||
uboVS.matrices.view = glm::rotate(uboVS.matrices.view, deg_to_rad(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f));
|
||||
uboVS.matrices.view = glm::rotate(uboVS.matrices.view, deg_to_rad(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f));
|
||||
uboVS.matrices.view = glm::rotate(uboVS.matrices.view, deg_to_rad(rotation.z), glm::vec3(0.0f, 0.0f, 1.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.z), glm::vec3(0.0f, 0.0f, 1.0f));
|
||||
|
||||
// Only update the matrices part of the uniform buffer
|
||||
uint8_t *pData;
|
||||
|
|
|
|||
|
|
@ -670,14 +670,14 @@ public:
|
|||
{
|
||||
// 3D object
|
||||
glm::mat4 viewMatrix = glm::mat4();
|
||||
uboVS.projection = glm::perspective(deg_to_rad(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));
|
||||
|
||||
uboVS.model = glm::mat4();
|
||||
uboVS.model = viewMatrix * glm::translate(uboVS.model, glm::vec3(0, 0, 0));
|
||||
uboVS.model = glm::rotate(uboVS.model, deg_to_rad(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f));
|
||||
uboVS.model = glm::rotate(uboVS.model, deg_to_rad(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f));
|
||||
uboVS.model = glm::rotate(uboVS.model, deg_to_rad(rotation.z), glm::vec3(0.0f, 0.0f, 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.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));
|
||||
|
||||
uint8_t *pData;
|
||||
VkResult err = vkMapMemory(device, uniformData.objectVS.memory, 0, sizeof(uboVS), 0, (void **)&pData);
|
||||
|
|
@ -687,13 +687,13 @@ public:
|
|||
|
||||
// Skysphere
|
||||
viewMatrix = glm::mat4();
|
||||
uboVS.projection = glm::perspective(deg_to_rad(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 = viewMatrix * glm::translate(uboVS.model, glm::vec3(0, 0, 0));
|
||||
uboVS.model = glm::rotate(uboVS.model, deg_to_rad(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f));
|
||||
uboVS.model = glm::rotate(uboVS.model, deg_to_rad(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f));
|
||||
uboVS.model = glm::rotate(uboVS.model, deg_to_rad(rotation.z), glm::vec3(0.0f, 0.0f, 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.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));
|
||||
|
||||
err = vkMapMemory(device, uniformData.skyboxVS.memory, 0, sizeof(uboVS), 0, (void **)&pData);
|
||||
assert(!err);
|
||||
|
|
|
|||
|
|
@ -538,7 +538,7 @@ public:
|
|||
|
||||
void updateUniformBuffers()
|
||||
{
|
||||
uboVS.projection = glm::perspective(deg_to_rad(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::lookAt(
|
||||
glm::vec3(0, 0, -zoom),
|
||||
|
|
@ -547,9 +547,9 @@ public:
|
|||
);
|
||||
|
||||
uboVS.model = glm::mat4();
|
||||
uboVS.model = glm::rotate(uboVS.model, deg_to_rad(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f));
|
||||
uboVS.model = glm::rotate(uboVS.model, deg_to_rad(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f));
|
||||
uboVS.model = glm::rotate(uboVS.model, deg_to_rad(rotation.z), glm::vec3(0.0f, 0.0f, 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.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.normal = glm::inverseTranspose(uboVS.view * uboVS.model);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue