reconsruct file path to flex

pull/2/head
ink-soul 2023-06-01 15:32:08 +08:00
parent e308f2ac18
commit 59c4d750a3
2 changed files with 35 additions and 38 deletions

View File

@ -333,12 +333,12 @@
vkDestroyBuffer(device, indexStaging.buffer, nullptr); vkDestroyBuffer(device, indexStaging.buffer, nullptr);
vkFreeMemory(device, indexStaging.memory, nullptr); vkFreeMemory(device, indexStaging.memory, nullptr);
} }
// TO DO:reconstruct with getting file path through struct
void VulkanExample::loadAssets() void VulkanExample::loadAssets()
{ {
loadglTFFile(getAssetPath() + "buster_drone/busterDrone.gltf", glTFModel); loadglTFFile(filePath.glTFModelFilePath, glTFModel);
loadglTFFile(getAssetPath() + "models/cube.gltf", skyboxModel, true); loadglTFFile(filePath.skyboxModleFilePath, skyboxModel, true);
ibltextures.skyboxCube.loadFromFile(getAssetPath() + "textures/hdr/pisa_cube.ktx", VK_FORMAT_R16G16B16A16_SFLOAT, vulkanDevice, queue); ibltextures.skyboxCube.loadFromFile(filePath.iblTexturesFilePath, VK_FORMAT_R16G16B16A16_SFLOAT, vulkanDevice, queue);
} }
void VulkanExample::setupDescriptors() void VulkanExample::setupDescriptors()
@ -477,8 +477,8 @@
vertexInputStateCI.pVertexAttributeDescriptions = vertexInputAttributes.data(); vertexInputStateCI.pVertexAttributeDescriptions = vertexInputAttributes.data();
std::array<VkPipelineShaderStageCreateInfo, 2> shaderStages = { std::array<VkPipelineShaderStageCreateInfo, 2> shaderStages = {
loadShader(getHomeworkShadersPath() + "homework1/mesh.vert.spv", VK_SHADER_STAGE_VERTEX_BIT), loadShader(filePath.modelVertShaderPath, VK_SHADER_STAGE_VERTEX_BIT),
loadShader(getHomeworkShadersPath() + "homework1/mesh.frag.spv", VK_SHADER_STAGE_FRAGMENT_BIT) loadShader(filePath.modelFragShaderPath, VK_SHADER_STAGE_FRAGMENT_BIT)
}; };
VkGraphicsPipelineCreateInfo pipelineCI = vks::initializers::pipelineCreateInfo(pipelineLayouts.pbrLayout, pbrFrameBuffer.fbo.renderPass, 0); VkGraphicsPipelineCreateInfo pipelineCI = vks::initializers::pipelineCreateInfo(pipelineLayouts.pbrLayout, pbrFrameBuffer.fbo.renderPass, 0);
@ -525,10 +525,10 @@
VkPipelineVertexInputStateCreateInfo emptyInputState = vks::initializers::pipelineVertexInputStateCreateInfo(); VkPipelineVertexInputStateCreateInfo emptyInputState = vks::initializers::pipelineVertexInputStateCreateInfo();
const std::string fragPath = ToneMapping ? "homework1/tonemapping_enable.frag.spv" : "homework1/tonemapping_disable.frag.spv"; const std::string fragPath = ToneMapping ? filePath.tonemappingEnableFragShaderPath : filePath.tonemappingDisableFragShaderPath;
std::array<VkPipelineShaderStageCreateInfo, 2> shaderStages = { std::array<VkPipelineShaderStageCreateInfo, 2> shaderStages = {
loadShader(getHomeworkShadersPath() + "homework1/genbrdflut.vert.spv", VK_SHADER_STAGE_VERTEX_BIT), loadShader(filePath.tonemappingVertShaderPath, VK_SHADER_STAGE_VERTEX_BIT),
loadShader(getHomeworkShadersPath() + fragPath, VK_SHADER_STAGE_FRAGMENT_BIT) loadShader(fragPath, VK_SHADER_STAGE_FRAGMENT_BIT)
}; };
VkGraphicsPipelineCreateInfo pipelineCI = vks::initializers::pipelineCreateInfo(pipelineLayouts.tonemappingLayout, renderPass, 0); VkGraphicsPipelineCreateInfo pipelineCI = vks::initializers::pipelineCreateInfo(pipelineLayouts.tonemappingLayout, renderPass, 0);
@ -776,8 +776,8 @@
pipelineCI.renderPass = renderpass; pipelineCI.renderPass = renderpass;
pipelineCI.pVertexInputState = &vertexInputStateCI; pipelineCI.pVertexInputState = &vertexInputStateCI;
shaderStages[0] = loadShader(getHomeworkShadersPath() + "homework1/filtercube.vert.spv", VK_SHADER_STAGE_VERTEX_BIT); shaderStages[0] = loadShader(filePath.irradianceVertShaderPath, VK_SHADER_STAGE_VERTEX_BIT);
shaderStages[1] = loadShader(getHomeworkShadersPath() + "homework1/irradiancecube.frag.spv", VK_SHADER_STAGE_FRAGMENT_BIT); shaderStages[1] = loadShader(filePath.irradianceFragShaderPath, VK_SHADER_STAGE_FRAGMENT_BIT);
VkPipeline pipeline; VkPipeline pipeline;
VK_CHECK_RESULT(vkCreateGraphicsPipelines(device, pipelineCache, 1, &pipelineCI, nullptr, &pipeline)); VK_CHECK_RESULT(vkCreateGraphicsPipelines(device, pipelineCache, 1, &pipelineCI, nullptr, &pipeline));
@ -1147,8 +1147,8 @@
pipelineCI.renderPass = renderpass; pipelineCI.renderPass = renderpass;
pipelineCI.pVertexInputState = &vertexInputStateCI; pipelineCI.pVertexInputState = &vertexInputStateCI;
shaderStages[0] = loadShader(getHomeworkShadersPath() + "homework1/filtercube.vert.spv", VK_SHADER_STAGE_VERTEX_BIT); shaderStages[0] = loadShader(filePath.prefilterVertShaderPath, VK_SHADER_STAGE_VERTEX_BIT);
shaderStages[1] = loadShader(getHomeworkShadersPath() + "homework1/prefilterenvmap.frag.spv", VK_SHADER_STAGE_FRAGMENT_BIT); shaderStages[1] = loadShader(filePath.prefilterFragShaderPath, VK_SHADER_STAGE_FRAGMENT_BIT);
VkPipeline pipeline; VkPipeline pipeline;
VK_CHECK_RESULT(vkCreateGraphicsPipelines(device, pipelineCache, 1, &pipelineCI, nullptr, &pipeline)); VK_CHECK_RESULT(vkCreateGraphicsPipelines(device, pipelineCache, 1, &pipelineCI, nullptr, &pipeline));
@ -1453,8 +1453,8 @@
pipelineCI.pVertexInputState = &emptyInputState; pipelineCI.pVertexInputState = &emptyInputState;
// Look-up-table (from BRDF) pipeline // Look-up-table (from BRDF) pipeline
shaderStages[0] = loadShader(getHomeworkShadersPath() + "homework1/genbrdflut.vert.spv", VK_SHADER_STAGE_VERTEX_BIT); shaderStages[0] = loadShader(filePath.brdfVertShaderPath, VK_SHADER_STAGE_VERTEX_BIT);
shaderStages[1] = loadShader(getHomeworkShadersPath() + "homework1/genbrdflut.frag.spv", VK_SHADER_STAGE_FRAGMENT_BIT); shaderStages[1] = loadShader(filePath.brdfFragShaderPath, VK_SHADER_STAGE_FRAGMENT_BIT);
VkPipeline pipeline; VkPipeline pipeline;
VK_CHECK_RESULT(vkCreateGraphicsPipelines(device, pipelineCache, 1, &pipelineCI, nullptr, &pipeline)); VK_CHECK_RESULT(vkCreateGraphicsPipelines(device, pipelineCache, 1, &pipelineCI, nullptr, &pipeline));

View File

@ -1,28 +1,5 @@
#pragma once #pragma once
/*
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <vector>
#define GLM_FORCE_RADIANS
#define GLM_FORCE_DEPTH_ZERO_TO_ONE
#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include <glm/gtc/type_ptr.hpp>
#ifdef VK_USE_PLATFORM_ANDROID_KHR
#define TINYGLTF_ANDROID_LOAD_FROM_ASSETS
#endif
#define TINYGLTF_IMPLEMENTATION
#define STB_IMAGE_IMPLEMENTATION
#define TINYGLTF_NO_STB_IMAGE_WRITE
#include "tiny_gltf.h"
*/
#include "vulkanexamplebase.h" #include "vulkanexamplebase.h"
#include "glTFModel.h" #include "glTFModel.h"
@ -54,6 +31,26 @@ public:
vks::Buffer skinSSBO; vks::Buffer skinSSBO;
} shaderData; } shaderData;
struct FilePath
{
std::string glTFModelFilePath = getAssetPath() + "buster_drone/busterDrone.gltf";
std::string skyboxModleFilePath = getAssetPath() + "models/cube.gltf";
std::string iblTexturesFilePath = getAssetPath() + "textures/hdr/pisa_cube.ktx";
std::string modelVertShaderPath = getAssetPath() + "buster_drone/shaders/glsl/mesh.vert.spv";
std::string modelFragShaderPath = getAssetPath() + "buster_drone/shaders/glsl/mesh.frag.spv";
std::string tonemappingVertShaderPath = getAssetPath() + "buster_drone/shaders/glsl/genbrdflut.vert.spv";
std::string tonemappingEnableFragShaderPath = getAssetPath() + "buster_drone/shaders/glsl/tonemapping_enable.frag.spv";
std::string tonemappingDisableFragShaderPath = getAssetPath() + "buster_drone/shaders/glsl/tonemapping_disable.frag.spv";
std::string irradianceVertShaderPath = getAssetPath() + "buster_drone/shaders/glsl/filtercube.vert.spv";
std::string irradianceFragShaderPath = getAssetPath() + "buster_drone/shaders/glsl/irradiancecube.frag.spv";
std::string prefilterVertShaderPath = getAssetPath() + "buster_drone/shaders/glsl/filtercube.vert.spv";
std::string prefilterFragShaderPath = getAssetPath() + "buster_drone/shaders/glsl/prefilterenvmap.frag.spv";
std::string brdfVertShaderPath = getAssetPath() + "buster_drone/shaders/glsl/genbrdflut.vert.spv";
std::string brdfFragShaderPath = getAssetPath() + "buster_drone/shaders/glsl/genbrdflut.frag.spv";
} filePath;
struct StagingBuffer { struct StagingBuffer {
VkBuffer buffer; VkBuffer buffer;
VkDeviceMemory memory; VkDeviceMemory memory;