Compare commits
3 Commits
e9ed42bfeb
...
86b0ae386b
Author | SHA1 | Date |
---|---|---|
|
86b0ae386b | |
|
d4beea0076 | |
|
02d6974134 |
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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; // 图片序列开始帧
|
||||
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -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<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, -1.0f });
|
||||
camera.setPosition({ 0.0f, 0.0f, -6.0f });
|
||||
camera.setRotation({ 0.0f, 0.0f, 0.0f });
|
||||
}
|
||||
|
||||
|
@ -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<uint32_t>(floor(log2(dim))) + 1;
|
||||
|
||||
// Create target cubemap
|
||||
// Create target cubemap static_cast<uint32_t>(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();
|
||||
}
|
||||
|
|
|
@ -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,7 +144,7 @@ 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";
|
||||
|
||||
|
@ -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);
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue