diff --git a/.gitignore b/.gitignore index 6864f8a..00eb5a3 100644 --- a/.gitignore +++ b/.gitignore @@ -44,4 +44,10 @@ vulkan_asset_pack_gltf.zip build/ # output ppm image sequence -*.ppm \ No newline at end of file +*.ppm + +# video +*.mp4 + +*.mp4 +/data/output diff --git a/base/vulkanexamplebase.h b/base/vulkanexamplebase.h index 7019d63..255625b 100644 --- a/base/vulkanexamplebase.h +++ b/base/vulkanexamplebase.h @@ -121,7 +121,7 @@ public: bool headless = false; // 无头开关 bool enableSaveToImageSequeue = false; // 图片序列开关(暂时弃用) - uint32_t outputFrameCount = 10; // 图片序列结束帧 + uint32_t outputFrameCount = 75; // 图片序列结束帧 bool takeScreenShot = false; // 截屏(暂时弃用) uint32_t startFrameCount = 1; // 图片序列开始帧 diff --git a/data/models/kettle.glb b/data/models/kettle.glb new file mode 100644 index 0000000..1ac9d73 Binary files /dev/null and b/data/models/kettle.glb differ diff --git a/data/models/toy.glb b/data/models/toy.glb new file mode 100644 index 0000000..22377a8 Binary files /dev/null and b/data/models/toy.glb differ diff --git a/data/output/video/device0/result.mp4 b/data/output/video/device0/result.mp4 index 27d645e..6b042b8 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 7bf4695..2a2c924 100644 --- a/src/render/render.cpp +++ b/src/render/render.cpp @@ -1806,7 +1806,13 @@ PlumageRender::PlumageRender() void PlumageRender::outputImageSequence() { - std::string deviceFilePath = filePath.imageOutputPath + "/device" + std::to_string(selectedPhysicalDeviceIndex); + if (savedFrameCounter == settings.startFrameCount) + { + std::cout << "clean up directory for image sequence generation" << std::endl; + removeImageSequence(); + } + + filePath.deviceSpecFilePath = filePath.imageOutputPath + "/device" + std::to_string(selectedPhysicalDeviceIndex); if (savedFrameCounter > settings.outputFrameCount) { @@ -1816,15 +1822,15 @@ PlumageRender::PlumageRender() } signal.imageSequenceOutputComplete = true; std::string fileName = "/%dresult.ppm"; - filePath.totalImageOutputPath = deviceFilePath + fileName; + filePath.totalImageOutputPath = filePath.deviceSpecFilePath + fileName; return; } - if (_access(deviceFilePath.c_str(), 0) == -1) + if (_access(filePath.deviceSpecFilePath.c_str(), 0) == -1) { - std::filesystem::create_directories(deviceFilePath.c_str()); + std::filesystem::create_directories(filePath.deviceSpecFilePath.c_str()); } - std::string fileName = "/" + std::to_string(savedFrameCounter) + "result.ppm"; - filePath.totalImageOutputPath = deviceFilePath + fileName; + std::string fileName ="/" + std::to_string(savedFrameCounter) + "result.ppm"; + filePath.totalImageOutputPath = filePath.deviceSpecFilePath + fileName; //std::cout << outputPath << std::endl; writeImageToFile(filePath.totalImageOutputPath.c_str()); savedFrameCounter++; @@ -1861,6 +1867,38 @@ PlumageRender::PlumageRender() signal.imageSequenceToVideoComplete = true; std::cout << "vidoe codec complete,saved in:" << resultVideoPath << std::endl; + std::cout << "star to clean up image sequence" << std::endl; + removeImageSequence(); + } + + void PlumageRender::removeImageSequence() + { + if (savedFrameCounter != settings.startFrameCount) + { + if (!signal.imageSequenceToVideoComplete) + { + return; + } + + } + if (std::filesystem::exists(filePath.deviceSpecFilePath)) + { + for (const auto& entry : std::filesystem::directory_iterator(filePath.deviceSpecFilePath)) + { + if (std::filesystem::is_directory(entry.path())) + { + std::filesystem::remove_all(entry.path()); + } + else + { + std::filesystem::remove(entry.path()); + } + } + std::filesystem::remove(filePath.deviceSpecFilePath); + std::cout << "clean up complete" << std::endl; + } + return; + } uint32_t PlumageRender::getMemoryTypeIndex(uint32_t typeBits, VkMemoryPropertyFlags properties) @@ -1974,6 +2012,7 @@ PlumageRender::PlumageRender() loadScene(filename); setupDescriptors(); buildCommandBuffers(); + } void PlumageRender::updateUIOverlay() @@ -2034,6 +2073,9 @@ PlumageRender::PlumageRender() loadScene(stringFilename); setupDescriptors(); updateCBs = true; + signal.imageSequenceOutputComplete = false; + signal.imageSequenceToVideoComplete = false; + savedFrameCounter = 1; } } gui->endMenu(); diff --git a/src/render/render.h b/src/render/render.h index 20dd7f3..41e336d 100644 --- a/src/render/render.h +++ b/src/render/render.h @@ -13,6 +13,7 @@ #include #include +#include #include #include #include @@ -153,7 +154,7 @@ public: std::string skyboxVertShaderPath = getAssetPath() + "shaders/skybox.vert.spv"; std::string skyboxFragShaderPath = getAssetPath() + "shaders/skybox.frag.spv"; - std::string iblTexturesFilePath = getAssetPath() + "textures/hdr/pisa_cube.ktx"; + std::string iblTexturesFilePath = getAssetPath() + "textures/hdr/gcanyon_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"; @@ -184,6 +185,7 @@ public: std::string imageOutputPath = getAssetPath() + "output/imageSequence"; std::string videoOutputPath = getAssetPath() + "output/video"; std::string totalImageOutputPath; + std::string deviceSpecFilePath; // script file path std::string image2videoBatFilePath = getAssetPath() + "script/image2video.bat"; @@ -365,6 +367,7 @@ public: void writeImageToFile(std::string filePath); void outputImageSequence(); void imageSequenceToVideo(); + void removeImageSequence(); //void outputScreenShot(); uint32_t getMemoryTypeIndex(uint32_t typeBits, VkMemoryPropertyFlags properties); virtual void render();