diff --git a/pbrbasic/pbrbasic.cpp b/pbrbasic/pbrbasic.cpp index 8d009d48..f851b4e6 100644 --- a/pbrbasic/pbrbasic.cpp +++ b/pbrbasic/pbrbasic.cpp @@ -96,8 +96,8 @@ public: title = "Vulkan Example - Physical based shading basics"; enableTextOverlay = true; camera.type = Camera::CameraType::firstperson; - camera.setPosition(glm::vec3(13.0f, 8.0f, -10.0f)); - camera.setRotation(glm::vec3(-31.75f, 45.0f, 0.0f)); + camera.setPosition(glm::vec3(10.0f, 13.0f, 1.8f)); + camera.setRotation(glm::vec3(-62.5f, 90.0f, 0.0f)); camera.movementSpeed = 4.0f; camera.setPerspective(60.0f, (float)width / (float)height, 0.1f, 256.0f); camera.rotationSpeed = 0.25f; @@ -118,7 +118,7 @@ public: materials.push_back(Material("Blue", glm::vec3(0.0f, 0.0f, 1.0f), 0.1f, 1.0f)); materials.push_back(Material("Black", glm::vec3(0.0f), 0.1f, 1.0f)); - materialIndex = 8; + materialIndex = 0; } ~VulkanExample() @@ -138,22 +138,12 @@ public: uniformBuffers.params.destroy(); } - void reBuildCommandBuffers() - { - if (!checkCommandBuffers()) - { - destroyCommandBuffers(); - createCommandBuffers(); - } - buildCommandBuffers(); - } - void buildCommandBuffers() { VkCommandBufferBeginInfo cmdBufInfo = vks::initializers::commandBufferBeginInfo(); VkClearValue clearValues[2]; - clearValues[0].color = { { 0.1f, 0.1f, 0.1f, 1.0f } }; + clearValues[0].color = defaultClearColor; clearValues[1].depthStencil = { 1.0f, 0 }; VkRenderPassBeginInfo renderPassBeginInfo = vks::initializers::renderPassBeginInfo(); @@ -207,7 +197,7 @@ public: for (uint32_t x = 0; x < GRID_DIM; x++) { glm::vec3 pos = glm::vec3(float(x - (GRID_DIM / 2.0f)) * 2.5f, 0.0f, float(y - (GRID_DIM / 2.0f)) * 2.5f); vkCmdPushConstants(drawCmdBuffers[i], pipelineLayout, VK_SHADER_STAGE_VERTEX_BIT, 0, sizeof(glm::vec3), &pos); - mat.params.metallic = (float)x / (float)(GRID_DIM - 1); + mat.params.metallic = glm::clamp((float)x / (float)(GRID_DIM - 1), 0.1f, 1.0f); mat.params.roughness = glm::clamp((float)y / (float)(GRID_DIM - 1), 0.05f, 1.0f); vkCmdPushConstants(drawCmdBuffers[i], pipelineLayout, VK_SHADER_STAGE_FRAGMENT_BIT, sizeof(glm::vec3), sizeof(Material::PushBlock), &mat); vkCmdDrawIndexed(drawCmdBuffers[i], models.objects[models.objectIndex].indexCount, 1, 0, 0, 0); @@ -475,7 +465,7 @@ public: models.objectIndex = 0; } updateUniformBuffers(); - reBuildCommandBuffers(); + buildCommandBuffers(); } void toggleMaterial(int32_t dir) @@ -487,7 +477,7 @@ public: if (materialIndex > static_cast(materials.size()) - 1) { materialIndex = 0; } - reBuildCommandBuffers(); + buildCommandBuffers(); updateTextOverlay(); } diff --git a/pbribl/pbribl.cpp b/pbribl/pbribl.cpp index 59cb3717..14f76467 100644 --- a/pbribl/pbribl.cpp +++ b/pbribl/pbribl.cpp @@ -91,7 +91,7 @@ public: struct UBOParams { glm::vec4 lights[4]; - float exposure = 2.0f; + float exposure = 4.5f; float gamma = 2.2f; } uboParams; @@ -114,7 +114,7 @@ public: VulkanExample() : VulkanExampleBase(ENABLE_VALIDATION) { - title = "VK PBR IBL"; + title = "Vulkan Example - PBR with image based lighting"; enableTextOverlay = true; camera.type = Camera::CameraType::firstperson; @@ -227,13 +227,11 @@ public: #define SINGLE_ROW 1 #ifdef SINGLE_ROW - mat.params.metallic = 1.0; - uint32_t objcount = 10; for (uint32_t x = 0; x < objcount; x++) { glm::vec3 pos = glm::vec3(float(x - (objcount / 2.0f)) * 2.15f, 0.0f, 0.0f); - mat.params.roughness = glm::clamp((float)x / (float)objcount, 0.005f, 1.0f); - mat.params.metallic = 1.0f - glm::clamp((float)x / (float)objcount, 0.005f, 1.0f); + mat.params.roughness = 1.0f-glm::clamp((float)x / (float)objcount, 0.005f, 1.0f); + mat.params.metallic = glm::clamp((float)x / (float)objcount, 0.005f, 1.0f); vkCmdPushConstants(drawCmdBuffers[i], pipelineLayout, VK_SHADER_STAGE_VERTEX_BIT, 0, sizeof(glm::vec3), &pos); vkCmdPushConstants(drawCmdBuffers[i], pipelineLayout, VK_SHADER_STAGE_FRAGMENT_BIT, sizeof(glm::vec3), sizeof(Material::PushBlock), &mat); vkCmdDrawIndexed(drawCmdBuffers[i], models.objects[models.objectIndex].indexCount, 1, 0, 0, 0); @@ -1438,7 +1436,7 @@ public: // 3D object uboMatrices.projection = camera.matrices.perspective; 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(), 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; memcpy(uniformBuffers.object.mapped, &uboMatrices, sizeof(uboMatrices)); diff --git a/pbrtexture/main.cpp b/pbrtexture/main.cpp index affdb47c..4d6b6870 100644 --- a/pbrtexture/main.cpp +++ b/pbrtexture/main.cpp @@ -97,7 +97,7 @@ public: VulkanExample() : VulkanExampleBase(ENABLE_VALIDATION) { - title = "Vulkan textured PBR using IBL"; + title = "Vulkan Example - Textured PBR with IBL"; enableTextOverlay = true; camera.type = Camera::CameraType::firstperson; @@ -1385,7 +1385,7 @@ public: // 3D object uboMatrices.projection = camera.matrices.perspective; 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(), glm::radians(-90.0f), glm::vec3(0.0f, 1.0f, 0.0f)); uboMatrices.camPos = camera.position * -1.0f; memcpy(uniformBuffers.object.mapped, &uboMatrices, sizeof(uboMatrices)); diff --git a/screenshots/pbrbasic.jpg b/screenshots/pbrbasic.jpg index 7397c563..2d354a51 100644 Binary files a/screenshots/pbrbasic.jpg and b/screenshots/pbrbasic.jpg differ diff --git a/screenshots/pbribl.jpg b/screenshots/pbribl.jpg index e3f2544b..3c33b345 100644 Binary files a/screenshots/pbribl.jpg and b/screenshots/pbribl.jpg differ diff --git a/screenshots/pbrtexture.jpg b/screenshots/pbrtexture.jpg new file mode 100644 index 00000000..61c4b2b4 Binary files /dev/null and b/screenshots/pbrtexture.jpg differ