fix envMapRotate

main
ink-soul 2024-05-13 11:04:28 +08:00
parent d4beea0076
commit 61c501adcb
4 changed files with 25 additions and 13 deletions

3
.gitignore vendored
View File

@ -51,3 +51,6 @@ build/
*.mp4
/data/output
*.glb
*.ktx

View File

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

View File

@ -203,7 +203,7 @@ PlumageRender::PlumageRender()
models.scene.loadFromFile(filename, vulkanDevice, queue);
auto tFileLoad = std::chrono::duration<double, std::milli>(std::chrono::high_resolution_clock::now() - tStart).count();
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 });
}
@ -1025,8 +1025,8 @@ PlumageRender::PlumageRender()
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::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(0.0f, 0.0f, 1.0f)),
};
@ -1035,10 +1035,12 @@ PlumageRender::PlumageRender()
VkViewport viewport{};
viewport.width = (float)dim;
viewport.height = (float)dim;
viewport.height = -(float)dim;
viewport.minDepth = 0.0f;
viewport.maxDepth = 1.0f;
viewport.x = 0;
viewport.y = -viewport.height;
VkRect2D scissor{};
scissor.extent.width = dim;
scissor.extent.height = dim;
@ -1070,7 +1072,9 @@ PlumageRender::PlumageRender()
vulkanDevice->beginCommandBuffer(cmdBuf);
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);
vkCmdSetScissor(cmdBuf, 0, 1, &scissor);
@ -1133,7 +1137,7 @@ PlumageRender::PlumageRender()
copyRegion.dstOffset = { 0, 0, 0 };
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;
vkCmdCopyImage(
@ -1434,6 +1438,8 @@ PlumageRender::PlumageRender()
viewport.height = (float)dim;
viewport.minDepth = 0.0f;
viewport.maxDepth = 1.0f;
//viewport.x = 0;
//viewport.y = -viewport.height;
VkRect2D scissor{};
scissor.extent.width = dim;
@ -1497,7 +1503,7 @@ PlumageRender::PlumageRender()
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));
}
@ -1971,11 +1977,11 @@ PlumageRender::PlumageRender()
//outputImageSequeue(swapChainImage,filePath.imageSequenceFilePath);
outputImageSequence();
//outputImageSequence();
VK_CHECK_RESULT(vkWaitForFences(device, 1, &waitFences[frameIndex], VK_TRUE, UINT64_MAX));
imageSequenceToVideo();
//imageSequenceToVideo();
VK_CHECK_RESULT(vkResetFences(device, 1, &waitFences[frameIndex]));
VkResult acquire = swapChain.acquireNextImage(presentCompleteSemaphores[frameIndex], &currentBuffer);
@ -2131,6 +2137,9 @@ PlumageRender::PlumageRender()
setupDescriptors();
updateCBs = true;
}
if (gui->checkbox("模型自转", &settings.rotateModel)) {
updateShaderParams = true;
}
if (gui->checkbox(chineseUI.environmentBackGround, &displayBackground)) {
updateShaderParams = true;
}

View File

@ -144,7 +144,7 @@ public:
struct FilePath
{ //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 modelFragShaderPath = getAssetPath() + "buster_drone/shaders/glsl/mesh.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/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";
// pbr shader
std::string pbrVertShaderPath = getAssetPath() + "shaders/pbr.vert.spv";