diff --git a/base/vulkanexamplebase.cpp b/base/vulkanexamplebase.cpp index 9ae42b0..fa069f9 100644 --- a/base/vulkanexamplebase.cpp +++ b/base/vulkanexamplebase.cpp @@ -2196,7 +2196,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 b948368..1655f47 100644 --- a/base/vulkanexamplebase.h +++ b/base/vulkanexamplebase.h @@ -124,7 +124,7 @@ public: bool outputPNGimage = false; uint32_t endFrameIndex = 75; bool enableSaveToImageSequeue = true; // 图片序列开关(暂时弃用) - uint32_t outputFrameCount = 75; // 图片序列结束帧 + uint32_t outputFrameCount = 100; // 图片序列结束帧 bool takeScreenShot = false; // 截屏(暂时弃用) uint32_t startFrameCount = 1; // 图片序列开始帧 diff --git a/data/environments/1.ktx b/data/environments/1.ktx deleted file mode 100644 index 12adba1..0000000 Binary files a/data/environments/1.ktx and /dev/null 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/industrial_sunset_puresky_4k_hdr16f_cube.ktx b/data/environments/industrial_sunset_puresky_4k_hdr16f_cube.ktx new file mode 100644 index 0000000..e616535 Binary files /dev/null and b/data/environments/industrial_sunset_puresky_4k_hdr16f_cube.ktx differ diff --git a/data/environments/kloofendal_43d_clear_puresky_hdr16f_cube.ktx b/data/environments/kloofendal_43d_clear_puresky_hdr16f_cube.ktx new file mode 100644 index 0000000..8cd3998 Binary files /dev/null and b/data/environments/kloofendal_43d_clear_puresky_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/product_cosmetics.glb b/data/models/product_cosmetics.glb new file mode 100644 index 0000000..6db67b0 Binary files /dev/null and b/data/models/product_cosmetics.glb differ diff --git a/data/models/sauvage_perfume.glb b/data/models/sauvage_perfume.glb new file mode 100644 index 0000000..c1610b3 Binary files /dev/null and b/data/models/sauvage_perfume.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..6927580 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..37b8227 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..8de5dc1 100644 --- a/src/render/render.h +++ b/src/render/render.h @@ -82,7 +82,7 @@ public: float exposure = 4.5f; float gamma = 2.2f; float prefilteredCubeMipLevels; - float scaleIBLAmbient = 1.0f; + float scaleIBLAmbient = 2.0f; float debugViewInputs = 0; float debugViewEquation = 0; } shaderData; @@ -144,10 +144,10 @@ public: struct FilePath { //model path - std::string glTFModelFilePath = getAssetPath() + "models/DamagedHelmet/DamagedHelmet.gltf"; + std::string glTFModelFilePath = getAssetPath() + "models/sauvage_perfume.glb"; 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"; @@ -174,7 +174,7 @@ public: std::string brdfVertShaderPath = getAssetPath() + "shaders/genbrdflut.vert.spv"; std::string brdfFragShaderPath = getAssetPath() + "shaders/genbrdflut.frag.spv"; // environment map texture - std::string envMapFilePath = getAssetPath() + "environments/papermill.ktx"; + std::string envMapFilePath = getAssetPath() + "environments/kloofendal_43d_clear_puresky_hdr16f_cube.ktx"; std::string emptyEnvmapFilePath = getAssetPath() + "textures/empty.ktx"; // pbr shader std::string pbrVertShaderPath = getAssetPath() + "shaders/pbr.vert.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);