diff --git a/base/vulkanexamplebase.cpp b/base/vulkanexamplebase.cpp index 50d896b..4e83331 100644 --- a/base/vulkanexamplebase.cpp +++ b/base/vulkanexamplebase.cpp @@ -2049,7 +2049,7 @@ void VulkanExampleBase::handleMouseMove(int32_t x, int32_t y) camera.translate(glm::vec3(-0.0f, 0.0f, dy * .005f * camera.movementSpeed)); } if (mouseButtons.middle) { - camera.translate(glm::vec3(-dx * 0.01f, -dy * 0.01f, 0.0f)); + camera.translate(glm::vec3(-dx * 0.01f, dy * 0.01f, 0.0f)); } mousePos = glm::vec2((float)x, (float)y); } diff --git a/base/vulkanexamplebase.h b/base/vulkanexamplebase.h index 226146f..5d4c66d 100644 --- a/base/vulkanexamplebase.h +++ b/base/vulkanexamplebase.h @@ -113,7 +113,7 @@ public: uint32_t lastFPS = 0; struct Settings { - bool validation = false; // 校验层开关 + bool validation = true; // 校验层开关 bool fullscreen = false; // 全屏开关 bool vsync = false; // 垂直同步开关 bool multiSampling = true; // 多重采样 @@ -121,7 +121,7 @@ public: bool headless = false; // 无头开关 bool outputPNGimage = false; bool enableSaveToImageSequeue = true; // 图片序列开关(暂时弃用) - uint32_t outputFrameCount = 75; // 图片序列结束帧 + uint32_t outputFrameCount = 500; // 图片序列结束帧 bool takeScreenShot = false; // 截屏(暂时弃用) uint32_t startFrameCount = 1; // 图片序列开始帧 diff --git a/data/environments/bridge.hdr b/data/environments/bridge.hdr new file mode 100644 index 0000000..8bbd727 Binary files /dev/null and b/data/environments/bridge.hdr differ diff --git a/data/environments/bridge_hdr16f_cube.ktx b/data/environments/bridge_hdr16f_cube.ktx new file mode 100644 index 0000000..bdcd4ad Binary files /dev/null and b/data/environments/bridge_hdr16f_cube.ktx differ diff --git a/data/environments/brown_photostudio_02_4k_hdr16f_cube.ktx b/data/environments/brown_photostudio_02_4k_hdr16f_cube.ktx new file mode 100644 index 0000000..33a6b1e Binary files /dev/null and b/data/environments/brown_photostudio_02_4k_hdr16f_cube.ktx differ diff --git a/data/environments/metro_noord_4k_hdr16f_cube.ktx b/data/environments/metro_noord_4k_hdr16f_cube.ktx new file mode 100644 index 0000000..f62890e Binary files /dev/null and b/data/environments/metro_noord_4k_hdr16f_cube.ktx differ diff --git a/data/models/actually_shampoo_bottles_v2.glb b/data/models/actually_shampoo_bottles_v2.glb new file mode 100644 index 0000000..38117c6 Binary files /dev/null and b/data/models/actually_shampoo_bottles_v2.glb differ diff --git a/data/models/set_avacado_face_cream.glb b/data/models/set_avacado_face_cream.glb new file mode 100644 index 0000000..731f697 Binary files /dev/null and b/data/models/set_avacado_face_cream.glb differ diff --git a/data/output/video/device0/result.mp4 b/data/output/video/device0/result.mp4 index 2fa2cd1..b6fa27f 100644 Binary files a/data/output/video/device0/result.mp4 and b/data/output/video/device0/result.mp4 differ diff --git a/src/render/render.cpp b/src/render/render.cpp index 0855b24..821d28d 100644 --- a/src/render/render.cpp +++ b/src/render/render.cpp @@ -196,13 +196,14 @@ PlumageRender::PlumageRender() { std::cout << "Loading scene from " << filename << std::endl; models.scene.destroy(device); + animationIndex = 0; animationTimer = 0.0f; auto tStart = std::chrono::high_resolution_clock::now(); models.scene.loadFromFile(filename, vulkanDevice, queue); auto tFileLoad = std::chrono::duration(std::chrono::high_resolution_clock::now() - tStart).count(); std::cout << "Loading took " << tFileLoad << " ms" << std::endl; - camera.setPosition({ 0.0f, 0.0f, -1.0f }); + camera.setPosition({ 0.0f, 0.0f, -6.0f }); camera.setRotation({ 0.0f, 0.0f, 0.0f }); } @@ -262,7 +263,7 @@ PlumageRender::PlumageRender() loadScene(sceneFile.c_str()); models.skybox.loadFromFile(PlumageRender::filePath.skyboxModleFilePath, vulkanDevice, queue); - + loadEnvironment(envMapFile.c_str()); } @@ -684,17 +685,17 @@ PlumageRender::PlumageRender() switch (target) { case IRRADIANCE: format = VK_FORMAT_R32G32B32A32_SFLOAT; - dim = 64; + dim = 128; break; case PREFILTEREDENV: format = VK_FORMAT_R16G16B16A16_SFLOAT; - dim = 512; + dim = 4096; break; }; const uint32_t numMips = static_cast(floor(log2(dim))) + 1; - // Create target cubemap + // Create target cubemap static_cast(floor(log2(dim))) + { // Image VkImageCreateInfo imageCI{}; @@ -1084,7 +1085,7 @@ PlumageRender::PlumageRender() break; case PREFILTEREDENV: prefilterPushBlock.mvp = glm::perspective((float)(M_PI / 2.0), 1.0f, 0.1f, 512.0f) * matrices[f]; - prefilterPushBlock.roughness = (float)m / (float)(numMips - 1); + prefilterPushBlock.roughness = 0.0;//(float)m / (float)(numMips - 1); vkCmdPushConstants(cmdBuf, pipelinelayout, VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT, 0, sizeof(PrefilterPushBlock), &prefilterPushBlock); break; }; @@ -1211,7 +1212,7 @@ PlumageRender::PlumageRender() auto tStart = std::chrono::high_resolution_clock::now(); const VkFormat format = VK_FORMAT_R16G16_SFLOAT; - const int32_t dim = 512; + const int32_t dim = 2048; // Image VkImageCreateInfo imageCI{}; @@ -1480,23 +1481,35 @@ PlumageRender::PlumageRender() shaderDataScene.projection = camera.matrices.perspective; shaderDataScene.view = camera.matrices.view; + float modelSize = std::max(models.scene.aabb[0][0], std::max(models.scene.aabb[1][1], models.scene.aabb[2][2])); // Center and scale model - float scale = (1.0f / std::max(models.scene.aabb[0][0], std::max(models.scene.aabb[1][1], models.scene.aabb[2][2]))) * 0.5f; + float scale = (1.0f / modelSize ) * 0.5f; glm::vec3 translate = -glm::vec3(models.scene.aabb[3][0], models.scene.aabb[3][1], models.scene.aabb[3][2]); translate += -0.5f * glm::vec3(models.scene.aabb[0][0], models.scene.aabb[1][1], models.scene.aabb[2][2]); + camera.setPosition(glm::vec3(0, 0, -modelSize - 2)); + shaderDataScene.model = glm::mat4(1.0f); shaderDataScene.model[0][0] = scale; shaderDataScene.model[1][1] = scale; shaderDataScene.model[2][2] = scale; shaderDataScene.model = glm::translate(shaderDataScene.model, translate); + if (settings.rotateModel) + { + shaderDataScene.model = glm::mat4(1.0f); + shaderDataScene.model = glm::rotate(shaderDataScene.model, glm::radians(modelrot), glm::vec3(0, 1, 0)); + } + + shaderDataScene.camPos = glm::vec3( -camera.position.z * sin(glm::radians(camera.rotation.y)) * cos(glm::radians(camera.rotation.x)), -camera.position.z * sin(glm::radians(camera.rotation.x)), camera.position.z * cos(glm::radians(camera.rotation.y)) * cos(glm::radians(camera.rotation.x)) ); + + // Skybox shaderDataSkybox.projection = camera.matrices.perspective; shaderDataSkybox.view = camera.matrices.view; @@ -1510,6 +1523,7 @@ PlumageRender::PlumageRender() sin(glm::radians(lightSource.rotation.y)), cos(glm::radians(lightSource.rotation.x)) * cos(glm::radians(lightSource.rotation.y)), 0.0f); + } void PlumageRender::windowResized() @@ -1530,8 +1544,7 @@ PlumageRender::PlumageRender() camera.setPerspective(45.0f, (float)width / (float)height, 0.1f, 256.0f); camera.rotationSpeed = 0.25f; camera.movementSpeed = 0.1f; - camera.setPosition({ 0.0f, 0.0f, -1.0f }); - camera.setRotation({ 0.0f, 0.0f, 0.0f }); + waitFences.resize(renderAhead); presentCompleteSemaphores.resize(renderAhead); @@ -2009,11 +2022,11 @@ PlumageRender::PlumageRender() frameIndex += 1; frameIndex %= renderAhead; - if (!paused) { + if (settings.rotateModel) { - modelrot.y += frameTimer * 35.0f; - if (modelrot.y > 360.0f) { - modelrot.y -= 360.0f; + modelrot += frameTimer * 2.0f; + if (modelrot > 360.0f) { + modelrot -= 360.0f; } } if ((animate) && (models.scene.animations.size() > 0)) { @@ -2027,7 +2040,7 @@ PlumageRender::PlumageRender() if (settings.rotateModel) { updateUniformBuffers(); } - } + if (camera.updated) { updateUniformBuffers(); } diff --git a/src/render/render.h b/src/render/render.h index 62eafed..812c6fc 100644 --- a/src/render/render.h +++ b/src/render/render.h @@ -147,7 +147,7 @@ public: std::string glTFModelFilePath = getAssetPath() + "models/DamagedHelmet/DamagedHelmet.gltf"; std::string modelVertShaderPath = getAssetPath() + "buster_drone/shaders/glsl/mesh.vert.spv"; std::string modelFragShaderPath = getAssetPath() + "buster_drone/shaders/glsl/mesh.frag.spv"; - + //ui std::string uiVertShaderPath = getAssetPath() + "shaders/ui.vert.spv"; std::string uiFragShaderPath = getAssetPath() + "shaders/ui.frag.spv"; @@ -157,7 +157,7 @@ public: std::string skyboxVertShaderPath = getAssetPath() + "shaders/skybox.vert.spv"; std::string skyboxFragShaderPath = getAssetPath() + "shaders/skybox.frag.spv"; - std::string iblTexturesFilePath = getAssetPath() + "textures/hdr/gcanyon_cube.ktx"; + std::string iblTexturesFilePath = getAssetPath() + "textures/hdr/pisa_cube.ktx"; //tonemapping std::string tonemappingVertShaderPath = getAssetPath() + "buster_drone/shaders/glsl/genbrdflut.vert.spv"; std::string tonemappingEnableFragShaderPath = getAssetPath() + "buster_drone/shaders/glsl/tonemapping_enable.frag.spv"; @@ -197,7 +197,7 @@ public: } filePath; - glm::vec3 modelrot = glm::vec3(0.0f); + float modelrot = 0.0f; glm::vec3 modelPos = glm::vec3(0.0f);