Compare commits

..

No commits in common. "86b0ae386bdfe95084e2a312e6de07a42aa3896d" and "e9ed42bfeb643aa14fcac8e43702e443d302b99b" have entirely different histories.

15 changed files with 22 additions and 35 deletions

View File

@ -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)); camera.translate(glm::vec3(-0.0f, 0.0f, dy * .005f * camera.movementSpeed));
} }
if (mouseButtons.middle) { 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); mousePos = glm::vec2((float)x, (float)y);
} }

View File

@ -124,7 +124,7 @@ public:
bool outputPNGimage = false; bool outputPNGimage = false;
uint32_t endFrameIndex = 75; uint32_t endFrameIndex = 75;
bool enableSaveToImageSequeue = true; // 图片序列开关(暂时弃用) bool enableSaveToImageSequeue = true; // 图片序列开关(暂时弃用)
uint32_t outputFrameCount = 100; // 图片序列结束帧 uint32_t outputFrameCount = 75; // 图片序列结束帧
bool takeScreenShot = false; // 截屏(暂时弃用) bool takeScreenShot = false; // 截屏(暂时弃用)
uint32_t startFrameCount = 1; // 图片序列开始帧 uint32_t startFrameCount = 1; // 图片序列开始帧

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -196,14 +196,13 @@ PlumageRender::PlumageRender()
{ {
std::cout << "Loading scene from " << filename << std::endl; std::cout << "Loading scene from " << filename << std::endl;
models.scene.destroy(device); models.scene.destroy(device);
animationIndex = 0; animationIndex = 0;
animationTimer = 0.0f; animationTimer = 0.0f;
auto tStart = std::chrono::high_resolution_clock::now(); auto tStart = std::chrono::high_resolution_clock::now();
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, -1.0f });
camera.setRotation({ 0.0f, 0.0f, 0.0f }); camera.setRotation({ 0.0f, 0.0f, 0.0f });
} }
@ -685,17 +684,17 @@ PlumageRender::PlumageRender()
switch (target) { switch (target) {
case IRRADIANCE: case IRRADIANCE:
format = VK_FORMAT_R32G32B32A32_SFLOAT; format = VK_FORMAT_R32G32B32A32_SFLOAT;
dim = 128; dim = 64;
break; break;
case PREFILTEREDENV: case PREFILTEREDENV:
format = VK_FORMAT_R16G16B16A16_SFLOAT; format = VK_FORMAT_R16G16B16A16_SFLOAT;
dim = 4096; dim = 512;
break; break;
}; };
const uint32_t numMips = static_cast<uint32_t>(floor(log2(dim))) + 1; const uint32_t numMips = static_cast<uint32_t>(floor(log2(dim))) + 1;
// Create target cubemap static_cast<uint32_t>(floor(log2(dim))) + // Create target cubemap
{ {
// Image // Image
VkImageCreateInfo imageCI{}; VkImageCreateInfo imageCI{};
@ -1085,7 +1084,7 @@ PlumageRender::PlumageRender()
break; break;
case PREFILTEREDENV: case PREFILTEREDENV:
prefilterPushBlock.mvp = glm::perspective((float)(M_PI / 2.0), 1.0f, 0.1f, 512.0f) * matrices[f]; prefilterPushBlock.mvp = glm::perspective((float)(M_PI / 2.0), 1.0f, 0.1f, 512.0f) * matrices[f];
prefilterPushBlock.roughness = 0.0;//(float)m / (float)(numMips - 1); prefilterPushBlock.roughness = (float)m / (float)(numMips - 1);
vkCmdPushConstants(cmdBuf, pipelinelayout, VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT, 0, sizeof(PrefilterPushBlock), &prefilterPushBlock); vkCmdPushConstants(cmdBuf, pipelinelayout, VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT, 0, sizeof(PrefilterPushBlock), &prefilterPushBlock);
break; break;
}; };
@ -1212,7 +1211,7 @@ PlumageRender::PlumageRender()
auto tStart = std::chrono::high_resolution_clock::now(); auto tStart = std::chrono::high_resolution_clock::now();
const VkFormat format = VK_FORMAT_R16G16_SFLOAT; const VkFormat format = VK_FORMAT_R16G16_SFLOAT;
const int32_t dim = 2048; const int32_t dim = 512;
// Image // Image
VkImageCreateInfo imageCI{}; VkImageCreateInfo imageCI{};
@ -1481,35 +1480,23 @@ PlumageRender::PlumageRender()
shaderDataScene.projection = camera.matrices.perspective; shaderDataScene.projection = camera.matrices.perspective;
shaderDataScene.view = camera.matrices.view; 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 // Center and scale model
float scale = (1.0f / modelSize ) * 0.5f; 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;
glm::vec3 translate = -glm::vec3(models.scene.aabb[3][0], models.scene.aabb[3][1], models.scene.aabb[3][2]); 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]); 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 = glm::mat4(1.0f);
shaderDataScene.model[0][0] = scale; shaderDataScene.model[0][0] = scale;
shaderDataScene.model[1][1] = scale; shaderDataScene.model[1][1] = scale;
shaderDataScene.model[2][2] = scale; shaderDataScene.model[2][2] = scale;
shaderDataScene.model = glm::translate(shaderDataScene.model, translate); 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( 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.y)) * cos(glm::radians(camera.rotation.x)),
-camera.position.z * sin(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)) camera.position.z * cos(glm::radians(camera.rotation.y)) * cos(glm::radians(camera.rotation.x))
); );
// Skybox // Skybox
shaderDataSkybox.projection = camera.matrices.perspective; shaderDataSkybox.projection = camera.matrices.perspective;
shaderDataSkybox.view = camera.matrices.view; shaderDataSkybox.view = camera.matrices.view;
@ -1523,7 +1510,6 @@ PlumageRender::PlumageRender()
sin(glm::radians(lightSource.rotation.y)), sin(glm::radians(lightSource.rotation.y)),
cos(glm::radians(lightSource.rotation.x)) * cos(glm::radians(lightSource.rotation.y)), cos(glm::radians(lightSource.rotation.x)) * cos(glm::radians(lightSource.rotation.y)),
0.0f); 0.0f);
} }
void PlumageRender::windowResized() void PlumageRender::windowResized()
@ -1544,7 +1530,8 @@ PlumageRender::PlumageRender()
camera.setPerspective(45.0f, (float)width / (float)height, 0.1f, 256.0f); camera.setPerspective(45.0f, (float)width / (float)height, 0.1f, 256.0f);
camera.rotationSpeed = 0.25f; camera.rotationSpeed = 0.25f;
camera.movementSpeed = 0.1f; camera.movementSpeed = 0.1f;
camera.setPosition({ 0.0f, 0.0f, -1.0f });
camera.setRotation({ 0.0f, 0.0f, 0.0f });
waitFences.resize(renderAhead); waitFences.resize(renderAhead);
presentCompleteSemaphores.resize(renderAhead); presentCompleteSemaphores.resize(renderAhead);
@ -2022,11 +2009,11 @@ PlumageRender::PlumageRender()
frameIndex += 1; frameIndex += 1;
frameIndex %= renderAhead; frameIndex %= renderAhead;
if (!paused) {
if (settings.rotateModel) { if (settings.rotateModel) {
modelrot += frameTimer * 2.0f; modelrot.y += frameTimer * 35.0f;
if (modelrot > 360.0f) { if (modelrot.y > 360.0f) {
modelrot -= 360.0f; modelrot.y -= 360.0f;
} }
} }
if ((animate) && (models.scene.animations.size() > 0)) { if ((animate) && (models.scene.animations.size() > 0)) {
@ -2040,7 +2027,7 @@ PlumageRender::PlumageRender()
if (settings.rotateModel) { if (settings.rotateModel) {
updateUniformBuffers(); updateUniformBuffers();
} }
}
if (camera.updated) { if (camera.updated) {
updateUniformBuffers(); updateUniformBuffers();
} }

View File

@ -82,7 +82,7 @@ public:
float exposure = 4.5f; float exposure = 4.5f;
float gamma = 2.2f; float gamma = 2.2f;
float prefilteredCubeMipLevels; float prefilteredCubeMipLevels;
float scaleIBLAmbient = 2.0f; float scaleIBLAmbient = 1.0f;
float debugViewInputs = 0; float debugViewInputs = 0;
float debugViewEquation = 0; float debugViewEquation = 0;
} shaderData; } shaderData;
@ -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/papermill.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";
@ -197,7 +197,7 @@ public:
} filePath; } filePath;
float modelrot = 0.0f; glm::vec3 modelrot = glm::vec3(0.0f);
glm::vec3 modelPos = glm::vec3(0.0f); glm::vec3 modelPos = glm::vec3(0.0f);