Compare commits

...

4 Commits

Author SHA1 Message Date
InkSoul 1a54e75ea2 update RM 2024-05-20 23:20:36 +08:00
ink-soul b37eee6c18 Update ReadMe.md 2024-05-13 11:27:25 +08:00
ink-soul 3600a1f4b7 Update .gitignore 2024-05-13 11:04:45 +08:00
ink-soul 61c501adcb fix envMapRotate 2024-05-13 11:04:28 +08:00
6 changed files with 42 additions and 32 deletions

4
.gitignore vendored
View File

@ -51,3 +51,7 @@ build/
*.mp4 *.mp4
/data/output /data/output
*.glb
*.ktx
data/output/video/device0/result.mp4

View File

@ -9,16 +9,7 @@
2. 支持gltf动画 2. 支持gltf动画
3. 支持模型的PBR材质渲染 3. 支持模型的PBR材质渲染
4. 使用基于IBL的环境光照 4. 使用基于IBL的环境光照
5. 支持渲染结果输出为图片序列通过ffmpeg转为视频main分支上该功能暂时屏蔽
#### 分支add image output ToDo list
1. 添加ppm格式图片序列输出
2. 单帧输出,预览效果
3. 接入ffmpeg将图片序列转图片
#### todo list
1. 参数化模板选择:维护一个模板数组,前端发送一个数组索引
#### 展示 #### 展示
@ -36,16 +27,22 @@
![](https://lychee.inksoul.top/uploads/original/39/56/ec512b70f1da4cf0771bcc38a6b9.webp) ![](https://lychee.inksoul.top/uploads/original/39/56/ec512b70f1da4cf0771bcc38a6b9.webp)
#### 下一步计划(等待研究生考试结束) #### 下一步计划
1. 引入spdlog日志库细化日志正在做 - [ ] 引入spdlog日志库细化日志正在做
2. 重置CMakeLists.txt添加Xmake 的lua脚本 - [ ] 重置CMakeLists.txt添加Xmake 的lua脚本
3. 二次封装vulkan API提供统一的渲染接口 - [ ] 二次封装vulkan API提供统一的渲染接口
4. 更换imgui的分支允许dock UI - [ ] 更换imgui的分支允许dock UI
5. 添加启动UI避免对默认模型的依赖 - [ ] 添加启动UI避免对默认模型的依赖
6. 添加obj格式支持 - [ ] 添加obj格式支持
7. 添加PMX格式支持 - [ ] 添加PMX格式支持
8. 引入USD格式支持 - [ ] 引入USD格式支持
#### 重构
暂定层级:
![](doc/层级.png)
#### 使用开源库 #### 使用开源库

View File

@ -113,11 +113,11 @@ public:
uint32_t lastFPS = 0; uint32_t lastFPS = 0;
struct Settings { struct Settings {
bool validation = true; // 校验层开关 bool validation = false; // 校验层开关
bool fullscreen = false; // 全屏开关 bool fullscreen = false; // 全屏开关
bool vsync = false; // 垂直同步开关 bool vsync = false; // 垂直同步开关
bool multiSampling = true; // 多重采样 bool multiSampling = true; // 多重采样
bool rotateModel = true; // 模型自旋转(暂时失效) bool rotateModel = false; // 模型自旋转(暂时失效)
bool headless = false; // 无头开关 bool headless = false; // 无头开关
bool outputPNGimage = false; bool outputPNGimage = false;
bool enableSaveToImageSequeue = true; // 图片序列开关(暂时弃用) bool enableSaveToImageSequeue = true; // 图片序列开关(暂时弃用)

BIN
doc/层级.png 100644

Binary file not shown.

After

Width:  |  Height:  |  Size: 263 KiB

View File

@ -203,7 +203,7 @@ PlumageRender::PlumageRender()
models.scene.loadFromFile(filename, vulkanDevice, queue); models.scene.loadFromFile(filename, vulkanDevice, queue);
auto tFileLoad = std::chrono::duration<double, std::milli>(std::chrono::high_resolution_clock::now() - tStart).count(); auto tFileLoad = std::chrono::duration<double, std::milli>(std::chrono::high_resolution_clock::now() - tStart).count();
std::cout << "Loading took " << tFileLoad << " ms" << std::endl; std::cout << "Loading took " << tFileLoad << " ms" << std::endl;
camera.setPosition({ 0.0f, 0.0f, -6.0f }); camera.setPosition({ 0.0f, 0.0f, -2.0f });
camera.setRotation({ 0.0f, 0.0f, 0.0f }); camera.setRotation({ 0.0f, 0.0f, 0.0f });
} }
@ -1025,8 +1025,8 @@ PlumageRender::PlumageRender()
std::vector<glm::mat4> matrices = { std::vector<glm::mat4> matrices = {
glm::rotate(glm::rotate(glm::mat4(1.0f), glm::radians(90.0f), glm::vec3(0.0f, 1.0f, 0.0f)), glm::radians(180.0f), glm::vec3(1.0f, 0.0f, 0.0f)), glm::rotate(glm::rotate(glm::mat4(1.0f), glm::radians(90.0f), glm::vec3(0.0f, 1.0f, 0.0f)), glm::radians(180.0f), glm::vec3(1.0f, 0.0f, 0.0f)),
glm::rotate(glm::rotate(glm::mat4(1.0f), glm::radians(-90.0f), glm::vec3(0.0f, 1.0f, 0.0f)), glm::radians(180.0f), glm::vec3(1.0f, 0.0f, 0.0f)), glm::rotate(glm::rotate(glm::mat4(1.0f), glm::radians(-90.0f), glm::vec3(0.0f, 1.0f, 0.0f)), glm::radians(180.0f), glm::vec3(1.0f, 0.0f, 0.0f)),
glm::rotate(glm::mat4(1.0f), glm::radians(-90.0f), glm::vec3(1.0f, 0.0f, 0.0f)),
glm::rotate(glm::mat4(1.0f), glm::radians(90.0f), glm::vec3(1.0f, 0.0f, 0.0f)), glm::rotate(glm::mat4(1.0f), glm::radians(90.0f), glm::vec3(1.0f, 0.0f, 0.0f)),
glm::rotate(glm::mat4(1.0f), glm::radians(-90.0f), glm::vec3(1.0f, 0.0f, 0.0f)),
glm::rotate(glm::mat4(1.0f), glm::radians(180.0f), glm::vec3(1.0f, 0.0f, 0.0f)), glm::rotate(glm::mat4(1.0f), glm::radians(180.0f), glm::vec3(1.0f, 0.0f, 0.0f)),
glm::rotate(glm::mat4(1.0f), glm::radians(180.0f), glm::vec3(0.0f, 0.0f, 1.0f)), glm::rotate(glm::mat4(1.0f), glm::radians(180.0f), glm::vec3(0.0f, 0.0f, 1.0f)),
}; };
@ -1035,9 +1035,11 @@ PlumageRender::PlumageRender()
VkViewport viewport{}; VkViewport viewport{};
viewport.width = (float)dim; viewport.width = (float)dim;
viewport.height = (float)dim; viewport.height = -(float)dim;
viewport.minDepth = 0.0f; viewport.minDepth = 0.0f;
viewport.maxDepth = 1.0f; viewport.maxDepth = 1.0f;
viewport.x = 0;
viewport.y = -viewport.height;
VkRect2D scissor{}; VkRect2D scissor{};
scissor.extent.width = dim; scissor.extent.width = dim;
@ -1070,7 +1072,9 @@ PlumageRender::PlumageRender()
vulkanDevice->beginCommandBuffer(cmdBuf); vulkanDevice->beginCommandBuffer(cmdBuf);
viewport.width = static_cast<float>(dim * std::pow(0.5f, m)); viewport.width = static_cast<float>(dim * std::pow(0.5f, m));
viewport.height = static_cast<float>(dim * std::pow(0.5f, m)); viewport.height = -static_cast<float>(dim * std::pow(0.5f, m));
viewport.x = 0;
viewport.y = -viewport.height;
vkCmdSetViewport(cmdBuf, 0, 1, &viewport); vkCmdSetViewport(cmdBuf, 0, 1, &viewport);
vkCmdSetScissor(cmdBuf, 0, 1, &scissor); vkCmdSetScissor(cmdBuf, 0, 1, &scissor);
@ -1133,7 +1137,7 @@ PlumageRender::PlumageRender()
copyRegion.dstOffset = { 0, 0, 0 }; copyRegion.dstOffset = { 0, 0, 0 };
copyRegion.extent.width = static_cast<uint32_t>(viewport.width); copyRegion.extent.width = static_cast<uint32_t>(viewport.width);
copyRegion.extent.height = static_cast<uint32_t>(viewport.height); copyRegion.extent.height = -static_cast<uint32_t>(viewport.height);
copyRegion.extent.depth = 1; copyRegion.extent.depth = 1;
vkCmdCopyImage( vkCmdCopyImage(
@ -1434,6 +1438,8 @@ PlumageRender::PlumageRender()
viewport.height = (float)dim; viewport.height = (float)dim;
viewport.minDepth = 0.0f; viewport.minDepth = 0.0f;
viewport.maxDepth = 1.0f; viewport.maxDepth = 1.0f;
//viewport.x = 0;
//viewport.y = -viewport.height;
VkRect2D scissor{}; VkRect2D scissor{};
scissor.extent.width = dim; scissor.extent.width = dim;
@ -1497,7 +1503,7 @@ PlumageRender::PlumageRender()
if (settings.rotateModel) if (settings.rotateModel)
{ {
shaderDataScene.model = glm::mat4(1.0f); //shaderDataScene.model = glm::mat4(1.0f);
shaderDataScene.model = glm::rotate(shaderDataScene.model, glm::radians(modelrot), glm::vec3(0, 1, 0)); shaderDataScene.model = glm::rotate(shaderDataScene.model, glm::radians(modelrot), glm::vec3(0, 1, 0));
} }
@ -1971,11 +1977,11 @@ PlumageRender::PlumageRender()
//outputImageSequeue(swapChainImage,filePath.imageSequenceFilePath); //outputImageSequeue(swapChainImage,filePath.imageSequenceFilePath);
outputImageSequence(); //outputImageSequence();
VK_CHECK_RESULT(vkWaitForFences(device, 1, &waitFences[frameIndex], VK_TRUE, UINT64_MAX)); VK_CHECK_RESULT(vkWaitForFences(device, 1, &waitFences[frameIndex], VK_TRUE, UINT64_MAX));
imageSequenceToVideo(); //imageSequenceToVideo();
VK_CHECK_RESULT(vkResetFences(device, 1, &waitFences[frameIndex])); VK_CHECK_RESULT(vkResetFences(device, 1, &waitFences[frameIndex]));
VkResult acquire = swapChain.acquireNextImage(presentCompleteSemaphores[frameIndex], &currentBuffer); VkResult acquire = swapChain.acquireNextImage(presentCompleteSemaphores[frameIndex], &currentBuffer);
@ -2131,6 +2137,9 @@ PlumageRender::PlumageRender()
setupDescriptors(); setupDescriptors();
updateCBs = true; updateCBs = true;
} }
if (gui->checkbox("模型自转", &settings.rotateModel)) {
updateShaderParams = true;
}
if (gui->checkbox(chineseUI.environmentBackGround, &displayBackground)) { if (gui->checkbox(chineseUI.environmentBackGround, &displayBackground)) {
updateShaderParams = true; updateShaderParams = true;
} }

View File

@ -144,7 +144,7 @@ public:
struct FilePath struct FilePath
{ //model path { //model path
std::string glTFModelFilePath = getAssetPath() + "models/sauvage_perfume.glb"; std::string glTFModelFilePath = getAssetPath() + "models/DamagedHelmet/DamagedHelmet.gltf";
std::string modelVertShaderPath = getAssetPath() + "buster_drone/shaders/glsl/mesh.vert.spv"; std::string modelVertShaderPath = getAssetPath() + "buster_drone/shaders/glsl/mesh.vert.spv";
std::string modelFragShaderPath = getAssetPath() + "buster_drone/shaders/glsl/mesh.frag.spv"; std::string modelFragShaderPath = getAssetPath() + "buster_drone/shaders/glsl/mesh.frag.spv";
@ -174,7 +174,7 @@ public:
std::string brdfVertShaderPath = getAssetPath() + "shaders/genbrdflut.vert.spv"; std::string brdfVertShaderPath = getAssetPath() + "shaders/genbrdflut.vert.spv";
std::string brdfFragShaderPath = getAssetPath() + "shaders/genbrdflut.frag.spv"; std::string brdfFragShaderPath = getAssetPath() + "shaders/genbrdflut.frag.spv";
// environment map texture // environment map texture
std::string envMapFilePath = getAssetPath() + "environments/kloofendal_43d_clear_puresky_hdr16f_cube.ktx"; std::string envMapFilePath = getAssetPath() + "environments/brown_photostudio_02_4k_hdr16f_cube.ktx";
std::string emptyEnvmapFilePath = getAssetPath() + "textures/empty.ktx"; std::string emptyEnvmapFilePath = getAssetPath() + "textures/empty.ktx";
// pbr shader // pbr shader
std::string pbrVertShaderPath = getAssetPath() + "shaders/pbr.vert.spv"; std::string pbrVertShaderPath = getAssetPath() + "shaders/pbr.vert.spv";