完成大部分结构体向类的重构

reconstruct-gltfLoader
InkSoul 2025-11-16 22:57:18 +08:00
parent 5198ffbe88
commit d915ac5dd2
58 changed files with 2234 additions and 347 deletions

8
.clang-format 100644
View File

@ -0,0 +1,8 @@
BasedOnStyle: Microsoft
AccessModifierOffset: -4
AlignConsecutiveMacros: true
AlignTrailingComments: true
AllowShortFunctionsOnASingleLine: Inline
AllowShortIfStatementsOnASingleLine: false
BreakBeforeBraces: Allman
ColumnLimit: 0

5
.gitignore vendored
View File

@ -39,7 +39,8 @@ out/
.vs/ .vs/
vulkan_asset_pack_gltf.zip vulkan_asset_pack_gltf.zip
*.zip *.zip
.cache/
/.cache
# vscode build file # vscode build file
build/ build/
@ -55,3 +56,5 @@ build/
*.ktx *.ktx
data/output/video/device0/result.mp4 data/output/video/device0/result.mp4
*.idx

View File

@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 3.5 FATAL_ERROR) cmake_minimum_required(VERSION 3.10)
cmake_policy(VERSION 3.5) cmake_policy(SET CMP0077 NEW)
set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake") set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake")

View File

@ -1,4 +1,4 @@

SET(PLUMAGE_RENDER "${CMAKE_CURRENT_SOURCE_DIR}/render") SET(PLUMAGE_RENDER "${CMAKE_CURRENT_SOURCE_DIR}/render")
message("working path ${PLUMAGE_RENDER}") message("working path ${PLUMAGE_RENDER}")
@ -15,8 +15,8 @@ set(GLTF_MODEL_LOADER
"gltf/glTFBoundingBox.cpp" "gltf/glTFBoundingBox.cpp"
"gltf/glTFTexture.h" "gltf/glTFTexture.h"
"gltf/glTFTexture.cpp" "gltf/glTFTexture.cpp"
"gltf/glTFModel.h" #"gltf/glTFModel.h"
"gltf/glTFModel.cpp" #"gltf/glTFModel.cpp"
"gltf/glTFMaterial.h" "gltf/glTFMaterial.h"
"gltf/glTFMaterial.cpp" "gltf/glTFMaterial.cpp"
"gltf/glTFPrimitive.h" "gltf/glTFPrimitive.h"
@ -36,39 +36,12 @@ set(GLTF_MODEL_LOADER
"gltf/glTFMainModel.h" "gltf/glTFMainModel.h"
"gltf/glTFMainModel.cpp" "gltf/glTFMainModel.cpp"
) )
set(VULKAN_BASE
"${PLUMAGE_RENDER}/VulkanBase_Marco.h"
"render/VulkanBase_Common.h"
"${PLUMAGE_RENDER}/VulkanDevice.h"
"${PLUMAGE_RENDER}/VulkanDevice.cpp"
"${PLUMAGE_RENDER}/VulkanTextureSampler.h"
"${PLUMAGE_RENDER}/VulkanTextureSampler.cpp"
"pbr/PbrTextureExtension.h"
"pbr/PbrTextureExtension.cpp"
"pbr/PbrBaseTexture.h"
"pbr/PbrBaseTexture.cpp"
"pbr/PbrTextureCoordSet.h"
"pbr/PbrTextureCoordSet.cpp"
"pbr/PbrWorkFlow.h" "pbr/PbrWorkFlow.cpp")
# wayland requires additional source files
IF(USE_WAYLAND_WSI)
SET(SOURCE ${SOURCE} ${CMAKE_BINARY_DIR}/xdg-shell-client-protocol.h ${CMAKE_BINARY_DIR}/xdg-shell-protocol.c )
ENDIF()
# Add shaders
#set(SHADER_DIR_GLSL "../data/buster_drone/shaders/glsl")
#file(GLOB SHADERS_GLSL "${SHADER_DIR_GLSL}/*.vert" "${SHADER_DIR_GLSL}/*.frag" "${SHADER_DIR_GLSL}/*.comp" "${SHADER_DIR_GLSL}/*.geom" "${SHADER_DIR_GLSL}/*.tesc" "${SHADER_DIR_GLSL}/*.tese" "${SHADER_DIR_GLSL}/*.mesh" "${SHADER_DIR_GLSL}/*.task" "${SHADER_DIR_GLSL}/*.rgen" "${SHADER_DIR_GLSL}/*.rchit" "${SHADER_DIR_GLSL}/*.rmiss" "${SHADER_DIR_GLSL}/*.rcall")
#set(SHADER_DIR_HLSL "../data/buster_drone/shaders/hlsl")
#file(GLOB SHADERS_HLSL "${SHADER_DIR_HLSL}/*.vert" "${SHADER_DIR_HLSL}/*.frag" "${SHADER_DIR_HLSL}/*.comp" "${SHADER_DIR_HLSL}/*.geom" "${SHADER_DIR_HLSL}/*.tesc" "${SHADER_DIR_HLSL}/*.tese" "${SHADER_DIR_HLSL}/*.mesh" "${SHADER_DIR_HLSL}/*.task" "${SHADER_DIR_HLSL}/*.rgen" "${SHADER_DIR_HLSL}/*.rchit" "${SHADER_DIR_HLSL}/*.rmiss" "${SHADER_DIR_HLSL}/*.rcall")
#source_group("Shaders\\GLSL" FILES ${SHADERS_GLSL})
#source_group("Shaders\\HLSL" FILES ${SHADERS_HLSL})
# Add optional readme / tutorial
#file(GLOB README_FILES "${HOMEWORK_FOLDER}/*.md")
aux_source_directory(${PROJECT_SOURCE_DIR}/src/render VULKAN_BASE)
include_directories(${3rdParty_gli_path}) include_directories(${3rdParty_gli_path})
include_directories(${3rdParty_glm_path}) include_directories(${3rdParty_glm_path})
include_directories(${3rdParty_imgui_path}) include_directories(${3rdParty_imgui_path})

View File

@ -1,4 +1,4 @@
file(GLOB BASE_SRC "*.cpp" "*.h" "${3rdParty_imgui_path}/*.cpp" ) file(GLOB BASE_SRC "*.cpp" "*.h" "${3rdParty_imgui_path}/*.cpp" )
include_directories(${3rdParty_ktx_path}) include_directories(${3rdParty_ktx_path})

View File

@ -1,4 +1,4 @@
#ifndef GLTFANIMATION_H #ifndef GLTFANIMATION_H
#define GLTFANIMATION_H #define GLTFANIMATION_H
#include "glTFModel_Marco.h" #include "glTFModel_Marco.h"
@ -27,7 +27,6 @@ public:
std::vector<glTFAnimationSampler> getSampler(); std::vector<glTFAnimationSampler> getSampler();
void pushSamplersBack(glTFAnimationSampler value); void pushSamplersBack(glTFAnimationSampler value);
void setName(std::string name); void setName(std::string name);
std::string getName(); std::string getName();

View File

@ -1,7 +1,7 @@
#include "TextureCoordSet.h" #include "PbrTextureCoordSet.h"
VULKANBASE_NAMESPACE_BEGIN GLTFLOADER_NAMESPACE_BEGIN
TextureCoordSet::TextureCoordSet() TextureCoordSet::TextureCoordSet()
{ {
@ -71,4 +71,4 @@ unsigned char TextureCoordSet::getEmissive()
return m_emissive; return m_emissive;
} }
VULKANBASE_NAMESPACE_END GLTFLOADER_NAMESPACE_END

View File

@ -0,0 +1,307 @@
#include "configFilePath.h"
#include <io.h>
std::string getAssetPath()
{
if (_access("./../data/", 0) != -1)
{
return "./../data/";
}
else if (_access("./data/", 0) != -1)
{
return "./data/";
}
else if (_access("./../../data/", 0) != -1)
{
return "../../data/";
}
else
{
return VK_EXAMPLE_DATA_DIR;
}
}
// Getter method definitions
const std::string &ConfigFilePath::getGlTFModelFilePath() const
{
return glTFModelFilePath;
}
const std::string &ConfigFilePath::getModelVertShaderPath() const
{
return modelVertShaderPath;
}
const std::string &ConfigFilePath::getModelFragShaderPath() const
{
return modelFragShaderPath;
}
const std::string &ConfigFilePath::getUiVertShaderPath() const
{
return uiVertShaderPath;
}
const std::string &ConfigFilePath::getUiFragShaderPath() const
{
return uiFragShaderPath;
}
const std::string &ConfigFilePath::getSkyboxModleFilePath() const
{
return skyboxModleFilePath;
}
const std::string &ConfigFilePath::getSkyboxVertShaderPath() const
{
return skyboxVertShaderPath;
}
const std::string &ConfigFilePath::getSkyboxFragShaderPath() const
{
return skyboxFragShaderPath;
}
const std::string &ConfigFilePath::getIblTexturesFilePath() const
{
return iblTexturesFilePath;
}
const std::string &ConfigFilePath::getTonemappingVertShaderPath() const
{
return tonemappingVertShaderPath;
}
const std::string &ConfigFilePath::getTonemappingEnableFragShaderPath() const
{
return tonemappingEnableFragShaderPath;
}
const std::string &ConfigFilePath::getTonemappingDisableFragShaderPath() const
{
return tonemappingDisableFragShaderPath;
}
const std::string &ConfigFilePath::getIrradianceFragShaderPath() const
{
return irradianceFragShaderPath;
}
const std::string &ConfigFilePath::getFilterVertShaderPath() const
{
return filterVertShaderPath;
}
const std::string &ConfigFilePath::getPrefilterEnvmapFragShaderPath() const
{
return prefilterEnvmapFragShaderPath;
}
const std::string &ConfigFilePath::getBrdfVertShaderPath() const
{
return brdfVertShaderPath;
}
const std::string &ConfigFilePath::getBrdfFragShaderPath() const
{
return brdfFragShaderPath;
}
const std::string &ConfigFilePath::getEnvMapFilePath() const
{
return envMapFilePath;
}
const std::string &ConfigFilePath::getEmptyEnvmapFilePath() const
{
return emptyEnvmapFilePath;
}
const std::string &ConfigFilePath::getPbrVertShaderPath() const
{
return pbrVertShaderPath;
}
const std::string &ConfigFilePath::getPbrFragShaderPath() const
{
return pbrFragShaderPath;
}
const std::string &ConfigFilePath::getTtfFilePath() const
{
return ttfFilePath;
}
const std::string &ConfigFilePath::getImageOutputPath() const
{
return imageOutputPath;
}
const std::string &ConfigFilePath::getVideoOutputPath() const
{
return videoOutputPath;
}
const std::string &ConfigFilePath::getTotalImageOutputPath() const
{
return totalImageOutputPath;
}
const std::string &ConfigFilePath::getDeviceSpecFilePath() const
{
return deviceSpecFilePath;
}
const std::string &ConfigFilePath::getImage2videoBatFilePath() const
{
return image2videoBatFilePath;
}
const std::string &ConfigFilePath::getImage2videoShFilePath() const
{
return image2videoShFilePath;
}
// Setter method definitions
void ConfigFilePath::setGlTFModelFilePath(const std::string &path)
{
glTFModelFilePath = path;
}
void ConfigFilePath::setModelVertShaderPath(const std::string &path)
{
modelVertShaderPath = path;
}
void ConfigFilePath::setModelFragShaderPath(const std::string &path)
{
modelFragShaderPath = path;
}
void ConfigFilePath::setUiVertShaderPath(const std::string &path)
{
uiVertShaderPath = path;
}
void ConfigFilePath::setUiFragShaderPath(const std::string &path)
{
uiFragShaderPath = path;
}
void ConfigFilePath::setSkyboxModleFilePath(const std::string &path)
{
skyboxModleFilePath = path;
}
void ConfigFilePath::setSkyboxVertShaderPath(const std::string &path)
{
skyboxVertShaderPath = path;
}
void ConfigFilePath::setSkyboxFragShaderPath(const std::string &path)
{
skyboxFragShaderPath = path;
}
void ConfigFilePath::setIblTexturesFilePath(const std::string &path)
{
iblTexturesFilePath = path;
}
void ConfigFilePath::setTonemappingVertShaderPath(const std::string &path)
{
tonemappingVertShaderPath = path;
}
void ConfigFilePath::setTonemappingEnableFragShaderPath(const std::string &path)
{
tonemappingEnableFragShaderPath = path;
}
void ConfigFilePath::setTonemappingDisableFragShaderPath(const std::string &path)
{
tonemappingDisableFragShaderPath = path;
}
void ConfigFilePath::setIrradianceFragShaderPath(const std::string &path)
{
irradianceFragShaderPath = path;
}
void ConfigFilePath::setFilterVertShaderPath(const std::string &path)
{
filterVertShaderPath = path;
}
void ConfigFilePath::setPrefilterEnvmapFragShaderPath(const std::string &path)
{
prefilterEnvmapFragShaderPath = path;
}
void ConfigFilePath::setBrdfVertShaderPath(const std::string &path)
{
brdfVertShaderPath = path;
}
void ConfigFilePath::setBrdfFragShaderPath(const std::string &path)
{
brdfFragShaderPath = path;
}
void ConfigFilePath::setEnvMapFilePath(const std::string &path)
{
envMapFilePath = path;
}
void ConfigFilePath::setEmptyEnvmapFilePath(const std::string &path)
{
emptyEnvmapFilePath = path;
}
void ConfigFilePath::setPbrVertShaderPath(const std::string &path)
{
pbrVertShaderPath = path;
}
void ConfigFilePath::setPbrFragShaderPath(const std::string &path)
{
pbrFragShaderPath = path;
}
void ConfigFilePath::setTtfFilePath(const std::string &path)
{
ttfFilePath = path;
}
void ConfigFilePath::setImageOutputPath(const std::string &path)
{
imageOutputPath = path;
}
void ConfigFilePath::setVideoOutputPath(const std::string &path)
{
videoOutputPath = path;
}
void ConfigFilePath::setTotalImageOutputPath(const std::string &path)
{
totalImageOutputPath = path;
}
void ConfigFilePath::setDeviceSpecFilePath(const std::string &path)
{
deviceSpecFilePath = path;
}
void ConfigFilePath::setImage2videoBatFilePath(const std::string &path)
{
image2videoBatFilePath = path;
}
void ConfigFilePath::setImage2videoShFilePath(const std::string &path)
{
image2videoShFilePath = path;
}

View File

@ -0,0 +1,98 @@
#pragma once
#include <string>
class ConfigFilePath
{
public:
std::string getAssetPath();
// Getter methods
const std::string &getGlTFModelFilePath() const;
const std::string &getModelVertShaderPath() const;
const std::string &getModelFragShaderPath() const;
const std::string &getUiVertShaderPath() const;
const std::string &getUiFragShaderPath() const;
const std::string &getSkyboxModleFilePath() const;
const std::string &getSkyboxVertShaderPath() const;
const std::string &getSkyboxFragShaderPath() const;
const std::string &getIblTexturesFilePath() const;
const std::string &getTonemappingVertShaderPath() const;
const std::string &getTonemappingEnableFragShaderPath() const;
const std::string &getTonemappingDisableFragShaderPath() const;
const std::string &getIrradianceFragShaderPath() const;
const std::string &getFilterVertShaderPath() const;
const std::string &getPrefilterEnvmapFragShaderPath() const;
const std::string &getBrdfVertShaderPath() const;
const std::string &getBrdfFragShaderPath() const;
const std::string &getEnvMapFilePath() const;
const std::string &getEmptyEnvmapFilePath() const;
const std::string &getPbrVertShaderPath() const;
const std::string &getPbrFragShaderPath() const;
const std::string &getTtfFilePath() const;
const std::string &getImageOutputPath() const;
const std::string &getVideoOutputPath() const;
const std::string &getTotalImageOutputPath() const;
const std::string &getDeviceSpecFilePath() const;
const std::string &getImage2videoBatFilePath() const;
const std::string &getImage2videoShFilePath() const;
// Setter methods
void setGlTFModelFilePath(const std::string &path);
void setModelVertShaderPath(const std::string &path);
void setModelFragShaderPath(const std::string &path);
void setUiVertShaderPath(const std::string &path);
void setUiFragShaderPath(const std::string &path);
void setSkyboxModleFilePath(const std::string &path);
void setSkyboxVertShaderPath(const std::string &path);
void setSkyboxFragShaderPath(const std::string &path);
void setIblTexturesFilePath(const std::string &path);
void setTonemappingVertShaderPath(const std::string &path);
void setTonemappingEnableFragShaderPath(const std::string &path);
void setTonemappingDisableFragShaderPath(const std::string &path);
void setIrradianceFragShaderPath(const std::string &path);
void setFilterVertShaderPath(const std::string &path);
void setPrefilterEnvmapFragShaderPath(const std::string &path);
void setBrdfVertShaderPath(const std::string &path);
void setBrdfFragShaderPath(const std::string &path);
void setEnvMapFilePath(const std::string &path);
void setEmptyEnvmapFilePath(const std::string &path);
void setPbrVertShaderPath(const std::string &path);
void setPbrFragShaderPath(const std::string &path);
void setTtfFilePath(const std::string &path);
void setImageOutputPath(const std::string &path);
void setVideoOutputPath(const std::string &path);
void setTotalImageOutputPath(const std::string &path);
void setDeviceSpecFilePath(const std::string &path);
void setImage2videoBatFilePath(const std::string &path);
void setImage2videoShFilePath(const std::string &path);
private:
std::string glTFModelFilePath = "models/DamagedHelmet/DamagedHelmet.gltf";
std::string modelVertShaderPath = "buster_drone/shaders/glsl/mesh.vert.spv";
std::string modelFragShaderPath = "buster_drone/shaders/glsl/mesh.frag.spv";
std::string uiVertShaderPath = "shaders/ui.vert.spv";
std::string uiFragShaderPath = "shaders/ui.frag.spv";
std::string skyboxModleFilePath = "models/cube.gltf";
std::string skyboxVertShaderPath = "shaders/skybox.vert.spv";
std::string skyboxFragShaderPath = "shaders/skybox.frag.spv";
std::string iblTexturesFilePath = "textures/hdr/gcanyon_cube.ktx";
std::string tonemappingVertShaderPath = "buster_drone/shaders/glsl/genbrdflut.vert.spv";
std::string tonemappingEnableFragShaderPath = "buster_drone/shaders/glsl/tonemapping_enable.frag.spv";
std::string tonemappingDisableFragShaderPath = "buster_drone/shaders/glsl/tonemapping_disable.frag.spv";
std::string irradianceFragShaderPath = "shaders/irradiancecube.frag.spv";
std::string filterVertShaderPath = "shaders/filtercube.vert.spv";
std::string prefilterEnvmapFragShaderPath = "shaders/prefilterenvmap.frag.spv";
std::string brdfVertShaderPath = "shaders/genbrdflut.vert.spv";
std::string brdfFragShaderPath = "shaders/genbrdflut.frag.spv";
std::string envMapFilePath = "environments/brown_photostudio_02_4k_hdr16f_cube.ktx";
std::string emptyEnvmapFilePath = "textures/empty.ktx";
std::string pbrVertShaderPath = "shaders/pbr.vert.spv";
std::string pbrFragShaderPath = "shaders/pbr_khr.frag.spv";
std::string ttfFilePath = "/data/Roboto-Medium.ttf";
std::string imageOutputPath = "output/imageSequence";
std::string videoOutputPath = "output/video";
std::string totalImageOutputPath;
std::string deviceSpecFilePath;
std::string image2videoBatFilePath = "script/image2video.bat";
std::string image2videoShFilePath = "script/image2video.sh";
};

View File

@ -0,0 +1,8 @@
#include "IndexStagingBuffer.h"
IndexStagingBuffer::IndexStagingBuffer()
{
}
IndexStagingBuffer::~IndexStagingBuffer()
{
}

View File

@ -0,0 +1,8 @@
#pragma once
#include "RenderStagingBuffer.h"
class IndexStagingBuffer : public RenderStagingBuffer
{
public:
IndexStagingBuffer();
~IndexStagingBuffer();
};

View File

@ -0,0 +1,23 @@
#include "IrradiancePushBlock.h"
// Getter method definitions
float IrradiancePushBlock::getDeltaPhi() const
{
return deltaPhi;
}
float IrradiancePushBlock::getDeltaTheta() const
{
return deltaTheta;
}
// Setter method definitions
void IrradiancePushBlock::setDeltaPhi(float value)
{
deltaPhi = value;
}
void IrradiancePushBlock::setDeltaTheta(float value)
{
deltaTheta = value;
}

View File

@ -0,0 +1,23 @@
#pragma once
#include "RenderPushBlock.h"
#include <math.h>
class IrradiancePushBlock : public RenderPushBlock
{
public:
IrradiancePushBlock();
~IrradiancePushBlock();
// Getter methods
float getDeltaPhi() const;
float getDeltaTheta() const;
// Setter methods
void setDeltaPhi(float value);
void setDeltaTheta(float value);
private:
float deltaPhi = (2.0f * float(M_PI)) / 180.0f;
float deltaTheta = (0.5f * float(M_PI)) / 64.0f;
};

View File

@ -0,0 +1,39 @@
#include "LocalizationStrings.h"
const char *LocalizationStrings::getModel() const { return m_model; }
const char *LocalizationStrings::getEnvironmentMap() const { return m_environmentMap; }
const char *LocalizationStrings::getEnvironmentBackGround() const { return m_environmentBackGround; }
const char *LocalizationStrings::getDebugInput() const { return m_debugInput; }
const char *LocalizationStrings::getDebugPBREquation() const { return m_debugPBREquation; }
const char *LocalizationStrings::getAnimation() const { return m_animation; }
const char *LocalizationStrings::getPauseAnimation() const { return m_pauseAnimation; }
const char *LocalizationStrings::getAnimationSeq() const { return m_animationSeq; }
const char *LocalizationStrings::getMenuFile() const { return m_menuFile; }
const char *LocalizationStrings::getMenuOpenNewModel() const { return m_menuOpenNewModel; }
const char *LocalizationStrings::getMenuEnvironment() const { return m_menuEnvironment; }
const char *LocalizationStrings::getMenuEnvironmentConfig() const { return m_menuEnvironmentConfig; }
const char *LocalizationStrings::getMenuAnimation() const { return m_menuAnimation; }
const char *LocalizationStrings::getMenuDebugFrameRate() const { return m_menuDebugFrameRate; }
const char *LocalizationStrings::getMenuDebugInput() const { return m_menuDebugInput; }
const char *LocalizationStrings::getMenuAnimationNoAnimation() const { return m_menuAnimationNoAnimation; }
const char *LocalizationStrings::getMenuAnimationActivation() const { return m_menuAnimationActivation; }
const char *LocalizationStrings::getMenuAnimationAnimationSequence() const { return m_menuAnimationAnimationSequence; }
void LocalizationStrings::setModel(const char *model) { m_model = model; }
void LocalizationStrings::setEnvironmentMap(const char *environmentMap) { m_environmentMap = environmentMap; }
void LocalizationStrings::setEnvironmentBackGround(const char *environmentBackGround) { m_environmentBackGround = environmentBackGround; }
void LocalizationStrings::setDebugInput(const char *debugInput) { m_debugInput = debugInput; }
void LocalizationStrings::setDebugPBREquation(const char *debugPBREquation) { m_debugPBREquation = debugPBREquation; }
void LocalizationStrings::setAnimation(const char *animation) { m_animation = animation; }
void LocalizationStrings::setPauseAnimation(const char *pauseAnimation) { m_pauseAnimation = pauseAnimation; }
void LocalizationStrings::setAnimationSeq(const char *animationSeq) { m_animationSeq = animationSeq; }
void LocalizationStrings::setMenuFile(const char *menuFile) { m_menuFile = menuFile; }
void LocalizationStrings::setMenuOpenNewModel(const char *menuOpenNewModel) { m_menuOpenNewModel = menuOpenNewModel; }
void LocalizationStrings::setMenuEnvironment(const char *menuEnvironment) { m_menuEnvironment = menuEnvironment; }
void LocalizationStrings::setMenuEnvironmentConfig(const char *menuEnvironmentConfig) { m_menuEnvironmentConfig = menuEnvironmentConfig; }
void LocalizationStrings::setMenuAnimation(const char *menuAnimation) { m_menuAnimation = menuAnimation; }
void LocalizationStrings::setMenuDebugFrameRate(const char *menuDebugFrameRate) { m_menuDebugFrameRate = menuDebugFrameRate; }
void LocalizationStrings::setMenuDebugInput(const char *menuDebugInput) { m_menuDebugInput = menuDebugInput; }
void LocalizationStrings::setMenuAnimationNoAnimation(const char *menuAnimationNoAnimation) { m_menuAnimationNoAnimation = menuAnimationNoAnimation; }
void LocalizationStrings::setMenuAnimationActivation(const char *menuAnimationActivation) { m_menuAnimationActivation = menuAnimationActivation; }
void LocalizationStrings::setMenuAnimationAnimationSequence(const char *menuAnimationAnimationSequence) { m_menuAnimationAnimationSequence = menuAnimationAnimationSequence; }

View File

@ -0,0 +1,70 @@
#pragma once
#include <string>
class LocalizationStrings
{
public:
// getters
const char *getModel() const;
const char *getEnvironmentMap() const;
const char *getEnvironmentBackGround() const;
const char *getDebugInput() const;
const char *getDebugPBREquation() const;
const char *getAnimation() const;
const char *getPauseAnimation() const;
const char *getAnimationSeq() const;
const char *getMenuFile() const;
const char *getMenuOpenNewModel() const;
const char *getMenuEnvironment() const;
const char *getMenuEnvironmentConfig() const;
const char *getMenuAnimation() const;
const char *getMenuDebugFrameRate() const;
const char *getMenuDebugInput() const;
const char *getMenuAnimationNoAnimation() const;
const char *getMenuAnimationActivation() const;
const char *getMenuAnimationAnimationSequence() const;
// setters
void setModel(const char *model);
void setEnvironmentMap(const char *environmentMap);
void setEnvironmentBackGround(const char *environmentBackGround);
void setDebugInput(const char *debugInput);
void setDebugPBREquation(const char *debugPBREquation);
void setAnimation(const char *animation);
void setPauseAnimation(const char *pauseAnimation);
void setAnimationSeq(const char *animationSeq);
void setMenuFile(const char *menuFile);
void setMenuOpenNewModel(const char *menuOpenNewModel);
void setMenuEnvironment(const char *menuEnvironment);
void setMenuEnvironmentConfig(const char *menuEnvironmentConfig);
void setMenuAnimation(const char *menuAnimation);
void setMenuDebugFrameRate(const char *menuDebugFrameRate);
void setMenuDebugInput(const char *menuDebugInput);
void setMenuAnimationNoAnimation(const char *menuAnimationNoAnimation);
void setMenuAnimationActivation(const char *menuAnimationActivation);
void setMenuAnimationAnimationSequence(const char *menuAnimationAnimationSequence);
private:
const char *m_model = "模型";
const char *m_environmentMap = "环境贴图";
const char *m_environmentBackGround = "启用背景贴图";
const char *m_debugInput = "输入";
const char *m_debugPBREquation = "PBR计算参数";
const char *m_animation = "动画";
const char *m_pauseAnimation = "启用动画";
const char *m_animationSeq = "动画序列";
// menu item
const char *m_menuFile = "文件";
const char *m_menuOpenNewModel = "新模型..";
const char *m_menuEnvironment = "环境光照";
const char *m_menuEnvironmentConfig = "设置";
const char *m_menuAnimation = "动画";
const char *m_menuDebugFrameRate = "fps";
const char *m_menuDebugInput = "输入";
const char *m_menuAnimationNoAnimation = "当前模型没有动画!";
const char *m_menuAnimationActivation = "开关";
const char *m_menuAnimationAnimationSequence = "动画序列";
};

View File

@ -0,0 +1,31 @@
#include "PrefilterPushBlock.h"
PrefilterPushBlock::PrefilterPushBlock()
{
}
PrefilterPushBlock::~PrefilterPushBlock()
{
}
// Getter method definitions
float PrefilterPushBlock::getRoughness() const
{
return roughness;
}
uint32_t PrefilterPushBlock::getNumSamples() const
{
return numSamples;
}
// Setter method definitions
void PrefilterPushBlock::setRoughness(float value)
{
roughness = value;
}
void PrefilterPushBlock::setNumSamples(uint32_t value)
{
numSamples = value;
}

View File

@ -0,0 +1,20 @@
#pragma once
#include "RenderPushBlock.h"
class PrefilterPushBlock : public RenderPushBlock
{
public:
PrefilterPushBlock();
~PrefilterPushBlock();
// Getter methods
float getRoughness() const;
uint32_t getNumSamples() const;
// Setter methods
void setRoughness(float value);
void setNumSamples(uint32_t value);
private:
float roughness;
uint32_t numSamples = 32u;
};

View File

@ -0,0 +1,143 @@
#include "PushConstBlockMaterial.h"
// Getter method definitions
const glm::vec4& PushConstBlockMaterial::getBaseColorFactor() const
{
return baseColorFactor;
}
const glm::vec4& PushConstBlockMaterial::getEmissiveFactor() const
{
return emissiveFactor;
}
const glm::vec4& PushConstBlockMaterial::getDiffuseFactor() const
{
return diffuseFactor;
}
const glm::vec4& PushConstBlockMaterial::getSpecularFactor() const
{
return specularFactor;
}
float PushConstBlockMaterial::getWorkflow() const
{
return workflow;
}
int PushConstBlockMaterial::getColorTextureSet() const
{
return colorTextureSet;
}
int PushConstBlockMaterial::getPhysicalDescriptorTextureSet() const
{
return PhysicalDescriptorTextureSet;
}
int PushConstBlockMaterial::getNormalTextureSet() const
{
return normalTextureSet;
}
int PushConstBlockMaterial::getOcclusionTextureSet() const
{
return occlusionTextureSet;
}
int PushConstBlockMaterial::getEmissiveTextureSet() const
{
return emissiveTextureSet;
}
float PushConstBlockMaterial::getMetallicFactor() const
{
return metallicFactor;
}
float PushConstBlockMaterial::getRoughnessFactor() const
{
return roughnessFactor;
}
float PushConstBlockMaterial::getAlphaMask() const
{
return alphaMask;
}
float PushConstBlockMaterial::getAlphaMaskCutoff() const
{
return alphaMaskCutoff;
}
// Setter method definitions
void PushConstBlockMaterial::setBaseColorFactor(const glm::vec4& factor)
{
baseColorFactor = factor;
}
void PushConstBlockMaterial::setEmissiveFactor(const glm::vec4& factor)
{
emissiveFactor = factor;
}
void PushConstBlockMaterial::setDiffuseFactor(const glm::vec4& factor)
{
diffuseFactor = factor;
}
void PushConstBlockMaterial::setSpecularFactor(const glm::vec4& factor)
{
specularFactor = factor;
}
void PushConstBlockMaterial::setWorkflow(float value)
{
workflow = value;
}
void PushConstBlockMaterial::setColorTextureSet(int value)
{
colorTextureSet = value;
}
void PushConstBlockMaterial::setPhysicalDescriptorTextureSet(int value)
{
PhysicalDescriptorTextureSet = value;
}
void PushConstBlockMaterial::setNormalTextureSet(int value)
{
normalTextureSet = value;
}
void PushConstBlockMaterial::setOcclusionTextureSet(int value)
{
occlusionTextureSet = value;
}
void PushConstBlockMaterial::setEmissiveTextureSet(int value)
{
emissiveTextureSet = value;
}
void PushConstBlockMaterial::setMetallicFactor(float value)
{
metallicFactor = value;
}
void PushConstBlockMaterial::setRoughnessFactor(float value)
{
roughnessFactor = value;
}
void PushConstBlockMaterial::setAlphaMask(float value)
{
alphaMask = value;
}
void PushConstBlockMaterial::setAlphaMaskCutoff(float value)
{
alphaMaskCutoff = value;
}

View File

@ -0,0 +1,54 @@
#pragma once
#include <glm/glm.hpp>
class PushConstBlockMaterial
{
public:
// Getter methods
const glm::vec4 &getBaseColorFactor() const;
const glm::vec4 &getEmissiveFactor() const;
const glm::vec4 &getDiffuseFactor() const;
const glm::vec4 &getSpecularFactor() const;
float getWorkflow() const;
int getColorTextureSet() const;
int getPhysicalDescriptorTextureSet() const;
int getNormalTextureSet() const;
int getOcclusionTextureSet() const;
int getEmissiveTextureSet() const;
float getMetallicFactor() const;
float getRoughnessFactor() const;
float getAlphaMask() const;
float getAlphaMaskCutoff() const;
// Setter methods
void setBaseColorFactor(const glm::vec4 &factor);
void setEmissiveFactor(const glm::vec4 &factor);
void setDiffuseFactor(const glm::vec4 &factor);
void setSpecularFactor(const glm::vec4 &factor);
void setWorkflow(float value);
void setColorTextureSet(int value);
void setPhysicalDescriptorTextureSet(int value);
void setNormalTextureSet(int value);
void setOcclusionTextureSet(int value);
void setEmissiveTextureSet(int value);
void setMetallicFactor(float value);
void setRoughnessFactor(float value);
void setAlphaMask(float value);
void setAlphaMaskCutoff(float value);
private:
glm::vec4 baseColorFactor;
glm::vec4 emissiveFactor;
glm::vec4 diffuseFactor;
glm::vec4 specularFactor;
float workflow;
int colorTextureSet;
int PhysicalDescriptorTextureSet;
int normalTextureSet;
int occlusionTextureSet;
int emissiveTextureSet;
float metallicFactor;
float roughnessFactor;
float alphaMask;
float alphaMaskCutoff;
};

View File

@ -0,0 +1,41 @@
#include "RenderDescriptorSetLayoutList.h"
RenderDescriptorSetLayoutList::RenderDescriptorSetLayoutList()
{
}
RenderDescriptorSetLayoutList::~RenderDescriptorSetLayoutList()
{
}
// Getter method definitions
VkDescriptorSetLayout RenderDescriptorSetLayoutList::getScene() const
{
return scene;
}
VkDescriptorSetLayout RenderDescriptorSetLayoutList::getMaterial() const
{
return material;
}
VkDescriptorSetLayout RenderDescriptorSetLayoutList::getNode() const
{
return node;
}
// Setter method definitions
void RenderDescriptorSetLayoutList::setScene(VkDescriptorSetLayout layout)
{
scene = layout;
}
void RenderDescriptorSetLayoutList::setMaterial(VkDescriptorSetLayout layout)
{
material = layout;
}
void RenderDescriptorSetLayoutList::setNode(VkDescriptorSetLayout layout)
{
node = layout;
}

View File

@ -0,0 +1,23 @@
#pragma once
#include <vulkan/vulkan.h>
class RenderDescriptorSetLayoutList
{
public:
RenderDescriptorSetLayoutList();
~RenderDescriptorSetLayoutList();
// Getter methods
VkDescriptorSetLayout getScene() const;
VkDescriptorSetLayout getMaterial() const;
VkDescriptorSetLayout getNode() const;
// Setter methods
void setScene(VkDescriptorSetLayout layout);
void setMaterial(VkDescriptorSetLayout layout);
void setNode(VkDescriptorSetLayout layout);
private:
VkDescriptorSetLayout scene;
VkDescriptorSetLayout material;
VkDescriptorSetLayout node;
};

View File

@ -0,0 +1,41 @@
#include "RenderDescriptorSetList.h"
RenderDescriptorSetList::RenderDescriptorSetList()
{
}
RenderDescriptorSetList::~RenderDescriptorSetList()
{
}
// Getter method definitions
VkDescriptorSet RenderDescriptorSetList::getScene() const
{
return scene;
}
VkDescriptorSet RenderDescriptorSetList::getSkybox() const
{
return skybox;
}
VkDescriptorSet RenderDescriptorSetList::getTonemappingDescriptorSet() const
{
return tonemappingDescriptorSet;
}
// Setter method definitions
void RenderDescriptorSetList::setScene(VkDescriptorSet set)
{
scene = set;
}
void RenderDescriptorSetList::setSkybox(VkDescriptorSet set)
{
skybox = set;
}
void RenderDescriptorSetList::setTonemappingDescriptorSet(VkDescriptorSet set)
{
tonemappingDescriptorSet = set;
}

View File

@ -0,0 +1,23 @@
#pragma once
#include <vulkan/vulkan.h>
class RenderDescriptorSetList
{
public:
RenderDescriptorSetList();
~RenderDescriptorSetList();
// Getter methods
VkDescriptorSet getScene() const;
VkDescriptorSet getSkybox() const;
VkDescriptorSet getTonemappingDescriptorSet() const;
// Setter methods
void setScene(VkDescriptorSet set);
void setSkybox(VkDescriptorSet set);
void setTonemappingDescriptorSet(VkDescriptorSet set);
private:
VkDescriptorSet scene;
VkDescriptorSet skybox;
VkDescriptorSet tonemappingDescriptorSet = VK_NULL_HANDLE;
};

View File

@ -0,0 +1,31 @@
#include "RenderLightSource.h"
RenderLightSource::RenderLightSource()
{
}
RenderLightSource::~RenderLightSource()
{
}
// Getter method definitions
const glm::vec3 &RenderLightSource::getColor() const
{
return color;
}
const glm::vec3 &RenderLightSource::getRotation() const
{
return rotation;
}
// Setter method definitions
void RenderLightSource::setColor(const glm::vec3 &color)
{
this->color = color;
}
void RenderLightSource::setRotation(const glm::vec3 &rotation)
{
this->rotation = rotation;
}

View File

@ -0,0 +1,20 @@
#pragma once
#include <glm/glm.hpp>
class RenderLightSource
{
public:
RenderLightSource();
~RenderLightSource();
// Getter methods
const glm::vec3 &getColor() const;
const glm::vec3 &getRotation() const;
// Setter methods
void setColor(const glm::vec3 &color);
void setRotation(const glm::vec3 &rotation);
private:
glm::vec3 color = glm::vec3(1.0f);
glm::vec3 rotation = glm::vec3(75.0f, 40.0f, 0.0f);
};

View File

@ -0,0 +1,51 @@
#include "RenderOffScreen.h"
RenderOffScreen::RenderOffScreen()
{
}
RenderOffScreen::~RenderOffScreen()
{
}
// Getter method definitions
VkImage RenderOffScreen::getImage() const
{
return image;
}
VkImageView RenderOffScreen::getView() const
{
return view;
}
VkDeviceMemory RenderOffScreen::getMemory() const
{
return memory;
}
VkFramebuffer RenderOffScreen::getFramebuffer() const
{
return framebuffer;
}
// Setter method definitions
void RenderOffScreen::setImage(VkImage img)
{
image = img;
}
void RenderOffScreen::setView(VkImageView imageView)
{
view = imageView;
}
void RenderOffScreen::setMemory(VkDeviceMemory mem)
{
memory = mem;
}
void RenderOffScreen::setFramebuffer(VkFramebuffer fb)
{
framebuffer = fb;
}

View File

@ -0,0 +1,26 @@
#pragma once
#include <vulkan/vulkan.h>
class RenderOffScreen
{
public:
RenderOffScreen();
~RenderOffScreen();
// Getter methods
VkImage getImage() const;
VkImageView getView() const;
VkDeviceMemory getMemory() const;
VkFramebuffer getFramebuffer() const;
// Setter methods
void setImage(VkImage img);
void setView(VkImageView imageView);
void setMemory(VkDeviceMemory mem);
void setFramebuffer(VkFramebuffer fb);
private:
VkImage image;
VkImageView view;
VkDeviceMemory memory;
VkFramebuffer framebuffer;
};

View File

@ -0,0 +1,51 @@
#include "renderPipelineLayoutList.h"
RenderPipelineLayoutList::RenderPipelineLayoutList()
{
}
RenderPipelineLayoutList::~RenderPipelineLayoutList()
{
}
// Getter method definitions
VkDescriptorSetLayout RenderPipelineLayoutList::getScene() const
{
return scene;
}
VkDescriptorSetLayout RenderPipelineLayoutList::getMaterial() const
{
return material;
}
VkDescriptorSetLayout RenderPipelineLayoutList::getNode() const
{
return node;
}
VkPipelineLayout RenderPipelineLayoutList::getTonemappingLayout() const
{
return tonemappingLayout;
}
// Setter method definitions
void RenderPipelineLayoutList::setScene(VkDescriptorSetLayout layout)
{
scene = layout;
}
void RenderPipelineLayoutList::setMaterial(VkDescriptorSetLayout layout)
{
material = layout;
}
void RenderPipelineLayoutList::setNode(VkDescriptorSetLayout layout)
{
node = layout;
}
void RenderPipelineLayoutList::setTonemappingLayout(VkPipelineLayout layout)
{
tonemappingLayout = layout;
}

View File

@ -0,0 +1,26 @@
#pragma once
#include <vulkan/vulkan.h>
class RenderPipelineLayoutList
{
public:
RenderPipelineLayoutList();
~RenderPipelineLayoutList();
// Getter methods
VkDescriptorSetLayout getScene() const;
VkDescriptorSetLayout getMaterial() const;
VkDescriptorSetLayout getNode() const;
VkPipelineLayout getTonemappingLayout() const;
// Setter methods
void setScene(VkDescriptorSetLayout layout);
void setMaterial(VkDescriptorSetLayout layout);
void setNode(VkDescriptorSetLayout layout);
void setTonemappingLayout(VkPipelineLayout layout);
private:
VkDescriptorSetLayout scene;
VkDescriptorSetLayout material;
VkDescriptorSetLayout node;
VkPipelineLayout tonemappingLayout;
};

View File

@ -0,0 +1,81 @@
#include "RenderPipelineList.h"
RenderPipelineList::RenderPipelineList()
{
}
RenderPipelineList::~RenderPipelineList()
{
}
// Getter method definitions
VkPipeline RenderPipelineList::getSkybox() const
{
return skybox;
}
VkPipeline RenderPipelineList::getPbr() const
{
return pbr;
}
VkPipeline RenderPipelineList::getPbrDoubleSided() const
{
return pbrDoubleSided;
}
VkPipeline RenderPipelineList::getPbrAlphaBlend() const
{
return pbrAlphaBlend;
}
VkPipeline RenderPipelineList::getSolid() const
{
return solid;
}
VkPipeline RenderPipelineList::getWireframe() const
{
return wireframe;
}
VkPipeline RenderPipelineList::getToneMapping() const
{
return toneMapping;
}
// Setter method definitions
void RenderPipelineList::setSkybox(VkPipeline pipeline)
{
skybox = pipeline;
}
void RenderPipelineList::setPbr(VkPipeline pipeline)
{
pbr = pipeline;
}
void RenderPipelineList::setPbrDoubleSided(VkPipeline pipeline)
{
pbrDoubleSided = pipeline;
}
void RenderPipelineList::setPbrAlphaBlend(VkPipeline pipeline)
{
pbrAlphaBlend = pipeline;
}
void RenderPipelineList::setSolid(VkPipeline pipeline)
{
solid = pipeline;
}
void RenderPipelineList::setWireframe(VkPipeline pipeline)
{
wireframe = pipeline;
}
void RenderPipelineList::setToneMapping(VkPipeline pipeline)
{
toneMapping = pipeline;
}

View File

@ -0,0 +1,35 @@
#pragma once
#include <vulkan/vulkan.h>
class RenderPipelineList
{
public:
RenderPipelineList();
~RenderPipelineList();
// Getter methods
VkPipeline getSkybox() const;
VkPipeline getPbr() const;
VkPipeline getPbrDoubleSided() const;
VkPipeline getPbrAlphaBlend() const;
VkPipeline getSolid() const;
VkPipeline getWireframe() const;
VkPipeline getToneMapping() const;
// Setter methods
void setSkybox(VkPipeline pipeline);
void setPbr(VkPipeline pipeline);
void setPbrDoubleSided(VkPipeline pipeline);
void setPbrAlphaBlend(VkPipeline pipeline);
void setSolid(VkPipeline pipeline);
void setWireframe(VkPipeline pipeline);
void setToneMapping(VkPipeline pipeline);
private:
VkPipeline skybox;
VkPipeline pbr;
VkPipeline pbrDoubleSided;
VkPipeline pbrAlphaBlend;
VkPipeline solid;
VkPipeline wireframe = VK_NULL_HANDLE;
VkPipeline toneMapping = VK_NULL_HANDLE;
};

View File

@ -0,0 +1,13 @@
#include "RenderPushBlock.h"
// Getter method definitions
const glm::mat4 &RenderPushBlock::getMvp() const
{
return mvp;
}
// Setter method definitions
void RenderPushBlock::setMvp(const glm::mat4 &matrix)
{
mvp = matrix;
}

View File

@ -0,0 +1,16 @@
#pragma once
#include <glm/glm.hpp>
class RenderPushBlock
{
public:
RenderPushBlock();
~RenderPushBlock();
// Getter methods
const glm::mat4 &getMvp() const;
// Setter methods
void setMvp(const glm::mat4 &matrix);
protected:
glm::mat4 mvp;
};

View File

@ -0,0 +1,53 @@
#include "RenderSceneTextures.h"
// Getters
vks::TextureCubeMap &RenderSceneTextures::getEnvironmentCube()
{
return environmentCube;
}
vks::Texture2D &RenderSceneTextures::getEmpty()
{
return empty;
}
vks::Texture2D &RenderSceneTextures::getLutBrdf()
{
return lutBrdf;
}
vks::TextureCubeMap &RenderSceneTextures::getIrradianceCube()
{
return irradianceCube;
}
vks::TextureCubeMap &RenderSceneTextures::getPrefilteredCube()
{
return prefilteredCube;
}
// Setters
void RenderSceneTextures::setEnvironmentCube(const vks::TextureCubeMap &texture)
{
environmentCube = texture;
}
void RenderSceneTextures::setEmpty(const vks::Texture2D &texture)
{
empty = texture;
}
void RenderSceneTextures::setLutBrdf(const vks::Texture2D &texture)
{
lutBrdf = texture;
}
void RenderSceneTextures::setIrradianceCube(const vks::TextureCubeMap &texture)
{
irradianceCube = texture;
}
void RenderSceneTextures::setPrefilteredCube(const vks::TextureCubeMap &texture)
{
prefilteredCube = texture;
}
RenderSceneTextures::RenderSceneTextures()
{
}
RenderSceneTextures::~RenderSceneTextures()
{
}

View File

@ -0,0 +1,31 @@
#pragma once
#include <VulkanTexture.hpp>
class RenderSceneTextures
{
public:
RenderSceneTextures();
~RenderSceneTextures();
// Getters
vks::TextureCubeMap &getEnvironmentCube();
vks::Texture2D &getEmpty();
vks::Texture2D &getLutBrdf();
vks::TextureCubeMap &getIrradianceCube();
vks::TextureCubeMap &getPrefilteredCube();
// Setters
void setEnvironmentCube(const vks::TextureCubeMap &texture);
void setEmpty(const vks::Texture2D &texture);
void setLutBrdf(const vks::Texture2D &texture);
void setIrradianceCube(const vks::TextureCubeMap &texture);
void setPrefilteredCube(const vks::TextureCubeMap &texture);
private:
vks::TextureCubeMap environmentCube;
vks::Texture2D empty;
vks::Texture2D lutBrdf;
vks::TextureCubeMap irradianceCube;
vks::TextureCubeMap prefilteredCube;
};

View File

@ -0,0 +1,8 @@
#include "SceneUBOMatrices.h"
SceneUBOMatrices::SceneUBOMatrices()
{
}
SceneUBOMatrices::~SceneUBOMatrices()
{
}

View File

@ -0,0 +1,9 @@
#pragma once
#include "renderUBOMatrices.h"
class SceneUBOMatrices : public RenderUBOMatrices
{
public:
SceneUBOMatrices();
~SceneUBOMatrices();
};

View File

@ -0,0 +1,8 @@
#include "SkyboxUBOMatrices.h"
SkyboxUBOMatrices::SkyboxUBOMatrices()
{
}
SkyboxUBOMatrices::~SkyboxUBOMatrices()
{
}

View File

@ -0,0 +1,10 @@
#pragma once
#include "renderUBOMatrices.h"
class SkyboxUBOMatrices : public RenderUBOMatrices
{
public:
SkyboxUBOMatrices();
~SkyboxUBOMatrices();
};

View File

@ -0,0 +1,8 @@
#include "VertexStagingBuffer.h"
VertexStagingBuffer::VertexStagingBuffer()
{
}
VertexStagingBuffer::~VertexStagingBuffer()
{
}

View File

@ -0,0 +1,8 @@
#pragma once
#include "renderStagingBuffer.h"
class VertexStagingBuffer : public RenderStagingBuffer
{
public:
VertexStagingBuffer();
~VertexStagingBuffer();
};

View File

@ -1,4 +1,4 @@
#pragma once #pragma once
/// 命名空间宏 /// 命名空间宏
#define VULKANBASE_NAMESPACE_BEGIN namespace VulkanBase { #define VULKANBASE_NAMESPACE_BEGIN namespace VulkanBase {

View File

@ -1,4 +1,4 @@
#include "VulkanDevice.h" #include "VulkanDevice.h"
#include <cassert> #include <cassert>
#include <stdexcept> #include <stdexcept>
#include <VulkanTools.h> #include <VulkanTools.h>
@ -53,7 +53,7 @@ VkPhysicalDevice VulkanDevice::getPhysicalDevice()
return m_physicalDevice; return m_physicalDevice;
} }
uint32_t VulkanDevice::getMemoryType(uint32_t typeBits, VkMemoryPropertyFlags properties, VkBool32* memTypeFound = nullptr) uint32_t VulkanDevice::getMemoryType(uint32_t typeBits, VkMemoryPropertyFlags properties, VkBool32* memTypeFound)
{ {
for (uint32_t i = 0; i < m_memoryProperties.memoryTypeCount; i++) { for (uint32_t i = 0; i < m_memoryProperties.memoryTypeCount; i++) {
if ((typeBits & 1) == 1) { if ((typeBits & 1) == 1) {
@ -100,7 +100,7 @@ uint32_t VulkanDevice::getQueueFamilyIndex(VkQueueFlagBits queueFlags)
throw std::runtime_error("Could not find a matching queue family index"); throw std::runtime_error("Could not find a matching queue family index");
} }
VkResult VulkanDevice::createBuffer(VkBufferUsageFlags usageFlags, VkMemoryPropertyFlags memoryPropertyFlags, VkDeviceSize size, VkBuffer* buffer, VkDeviceMemory* memory, void* data = nullptr) VkResult VulkanDevice::createBuffer(VkBufferUsageFlags usageFlags, VkMemoryPropertyFlags memoryPropertyFlags, VkDeviceSize size, VkBuffer* buffer, VkDeviceMemory* memory, void* data)
{ {
// 创建buffer句柄 // 创建buffer句柄
VkBufferCreateInfo bufferCreateInfo{}; VkBufferCreateInfo bufferCreateInfo{};
@ -145,7 +145,7 @@ VkResult VulkanDevice::createBuffer(VkBufferUsageFlags usageFlags, VkMemoryPrope
return VK_SUCCESS; return VK_SUCCESS;
} }
VkCommandPool VulkanDevice::createCommandPool(uint32_t queueFamilyIndex, VkCommandPoolCreateFlags createFlags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT) VkCommandPool VulkanDevice::createCommandPool(uint32_t queueFamilyIndex, VkCommandPoolCreateFlags createFlags)
{ {
/// 创建命令缓冲池 /// 创建命令缓冲池
VkCommandPoolCreateInfo cmdPoolInfo = {}; VkCommandPoolCreateInfo cmdPoolInfo = {};
@ -157,7 +157,7 @@ VkCommandPool VulkanDevice::createCommandPool(uint32_t queueFamilyIndex, VkComma
return cmdPool; return cmdPool;
} }
VkCommandBuffer VulkanDevice::createCommandBuffer(VkCommandBufferLevel level, bool begin = false) VkCommandBuffer VulkanDevice::createCommandBuffer(VkCommandBufferLevel level, bool begin)
{ {
VkCommandBufferAllocateInfo cmdBufAllocateInfo{}; VkCommandBufferAllocateInfo cmdBufAllocateInfo{};
cmdBufAllocateInfo.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; cmdBufAllocateInfo.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO;
@ -183,7 +183,7 @@ void VulkanDevice::beginCommandBuffer(VkCommandBuffer commandBuffer)
VK_CHECK_RESULT(vkBeginCommandBuffer(commandBuffer, &commandBufferBI)); VK_CHECK_RESULT(vkBeginCommandBuffer(commandBuffer, &commandBufferBI));
} }
void VulkanDevice::flushCommandBuffer(VkCommandBuffer commandBuffer, VkQueue queue, bool free = true) void VulkanDevice::flushCommandBuffer(VkCommandBuffer commandBuffer, VkQueue queue, bool free)
{ {
VK_CHECK_RESULT(vkEndCommandBuffer(commandBuffer)); VK_CHECK_RESULT(vkEndCommandBuffer(commandBuffer));

View File

@ -1,378 +1,372 @@
#pragma once #pragma once
#if defined(_WIN32) #if defined(_WIN32)
#include <io.h>
#include <direct.h> #include <direct.h>
#include <io.h>
#else #else
#include<sys/io.h> #include <dirent.h>
#include<dirent.h> #include <sys/io.h>
#endif #endif
#define STB_IMAGE_WRITE_IMPLEMENTATION #define STB_IMAGE_WRITE_IMPLEMENTATION
#include "stb_image_write.h" #include "stb_image_write.h"
#include <assert.h>
#include <chrono>
#include <cstdio>
#include <map>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <cstdio>
#include <string.h> #include <string.h>
#include <assert.h>
#include <vector> #include <vector>
#include <chrono>
#include <map>
#include <locale>
#include <codecvt>
#include "algorithm" #include "algorithm"
#include <iostream> #include <codecvt>
#include <sys/stat.h>
#include <filesystem> #include <filesystem>
#include <iostream>
#include <locale>
#include <sys/stat.h>
#include <vulkan/vulkan.h> #include "VulkanDevice.hpp"
#include "VulkanExampleBase.h" #include "VulkanExampleBase.h"
#include "glTFModel.h" #include "glTFModel.h"
#include <VulkanTexture.hpp>
#include "VulkanDevice.hpp"
#include "ui.hpp" #include "ui.hpp"
#include <VulkanTexture.hpp>
#include <VulkanUtils.hpp> #include <VulkanUtils.hpp>
#include <vulkan/vulkan.h>
#define ENABLE_VALIDATION false #define ENABLE_VALIDATION false
#include "renderEffectState.h"
class PlumageRender : public VulkanExampleBase class PlumageRender : public VulkanExampleBase
{ {
private:
RenderEffectState *m_effectState;
public: public:
bool wireframe = false; struct Models
bool normalMapping = true; {
bool ToneMapping = true; glTFModel::Model scene;
bool pbrEnabled = true; glTFModel::Model skybox;
} models;
struct stat struct Textures
{ {
vks::TextureCubeMap environmentCube;
vks::Texture2D empty;
vks::Texture2D lutBrdf;
vks::TextureCubeMap irradianceCube;
vks::TextureCubeMap prefilteredCube;
} textures;
} info ; struct ShaderData
{
glm::vec4 lightDir;
float exposure = 4.5f;
float gamma = 2.2f;
float prefilteredCubeMipLevels;
float scaleIBLAmbient = 2.0f;
float debugViewInputs = 0;
float debugViewEquation = 0;
} shaderData;
struct ChinesesUI
{
const char *model = "模型";
struct Signal const char *environmentMap = "环境贴图";
{ const char *environmentBackGround = "启用背景贴图";
bool imageSequenceOutputComplete = false; const char *debugInput = "输入";
bool imageSequenceToVideoComplete = false; const char *debugPBREquation = "PBR计算参数";
const char *animation = "动画";
}signal; const char *pauseAnimation = "启用动画";
const char *animationSeq = "动画序列";
// menu item
const char *menuFile = "文件";
const char *menuOpenNewModel = "新模型..";
const char *menuEnvironment = "环境光照";
const char *menuEnvironmentConfig = "设置";
const char *menuAnimation = "动画";
const char *menuDebugFrameRate = "fps";
const char *menuDebugInput = "输入";
const char *menuAnimationNoAnimation = "当前模型没有动画!";
struct Models const char *menuAnimationActivation = "开关";
{ const char *menuAnimationAnimationSequence = "动画序列";
glTFModel::Model scene;
glTFModel::Model skybox;
} models;
struct Textures { } chineseUI;
vks::TextureCubeMap environmentCube;
vks::Texture2D empty;
vks::Texture2D lutBrdf;
vks::TextureCubeMap irradianceCube;
vks::TextureCubeMap prefilteredCube;
} textures;
struct ShaderData { struct UniformBufferSet
glm::vec4 lightDir; {
float exposure = 4.5f; Buffer scene;
float gamma = 2.2f; Buffer skybox;
float prefilteredCubeMipLevels; Buffer params;
float scaleIBLAmbient = 2.0f; };
float debugViewInputs = 0;
float debugViewEquation = 0;
} shaderData;
struct ChinesesUI
{
const char * model = "模型";
const char* environmentMap = "环境贴图";
const char* environmentBackGround = "启用背景贴图";
const char* debugInput = "输入";
const char* debugPBREquation = "PBR计算参数";
const char* animation = "动画";
const char* pauseAnimation = "启用动画";
const char* animationSeq = "动画序列";
// menu item
const char* menuFile = "文件";
const char* menuOpenNewModel = "新模型..";
const char* menuEnvironment = "环境光照";
const char* menuEnvironmentConfig = "设置";
const char* menuAnimation = "动画";
const char* menuDebugFrameRate = "fps";
const char* menuDebugInput = "输入";
const char* menuAnimationNoAnimation = "当前模型没有动画!";
const char* menuAnimationActivation = "开关";
const char* menuAnimationAnimationSequence = "动画序列";
struct UBOMatrices
{
glm::mat4 projection;
glm::mat4 model;
glm::mat4 view;
glm::vec3 camPos;
} shaderDataScene, shaderDataSkybox;
}chineseUI; struct PushConstBlockMaterial
struct UniformBufferSet { {
Buffer scene; glm::vec4 baseColorFactor;
Buffer skybox; glm::vec4 emissiveFactor;
Buffer params; glm::vec4 diffuseFactor;
}; glm::vec4 specularFactor;
float workflow;
int colorTextureSet;
int PhysicalDescriptorTextureSet;
int normalTextureSet;
int occlusionTextureSet;
int emissiveTextureSet;
float metallicFactor;
float roughnessFactor;
float alphaMask;
float alphaMaskCutoff;
} pushConstBlockMaterial;
struct UBOMatrices { struct FilePath
glm::mat4 projection; { // model path
glm::mat4 model; std::string glTFModelFilePath = getAssetPath() + "models/DamagedHelmet/DamagedHelmet.gltf";
glm::mat4 view; std::string modelVertShaderPath = getAssetPath() + "buster_drone/shaders/glsl/mesh.vert.spv";
glm::vec3 camPos; std::string modelFragShaderPath = getAssetPath() + "buster_drone/shaders/glsl/mesh.frag.spv";
} shaderDataScene, shaderDataSkybox;
struct PushConstBlockMaterial { // ui
glm::vec4 baseColorFactor; std::string uiVertShaderPath = getAssetPath() + "shaders/ui.vert.spv";
glm::vec4 emissiveFactor; std::string uiFragShaderPath = getAssetPath() + "shaders/ui.frag.spv";
glm::vec4 diffuseFactor;
glm::vec4 specularFactor;
float workflow;
int colorTextureSet;
int PhysicalDescriptorTextureSet;
int normalTextureSet;
int occlusionTextureSet;
int emissiveTextureSet;
float metallicFactor;
float roughnessFactor;
float alphaMask;
float alphaMaskCutoff;
} pushConstBlockMaterial;
struct FilePath // skybox path
{ //model path std::string skyboxModleFilePath = getAssetPath() + "models/cube.gltf";
std::string glTFModelFilePath = getAssetPath() + "models/DamagedHelmet/DamagedHelmet.gltf"; std::string skyboxVertShaderPath = getAssetPath() + "shaders/skybox.vert.spv";
std::string modelVertShaderPath = getAssetPath() + "buster_drone/shaders/glsl/mesh.vert.spv"; std::string skyboxFragShaderPath = getAssetPath() + "shaders/skybox.frag.spv";
std::string modelFragShaderPath = getAssetPath() + "buster_drone/shaders/glsl/mesh.frag.spv";
//ui
std::string uiVertShaderPath = getAssetPath() + "shaders/ui.vert.spv";
std::string uiFragShaderPath = getAssetPath() + "shaders/ui.frag.spv";
// skybox path std::string iblTexturesFilePath = getAssetPath() + "textures/hdr/gcanyon_cube.ktx";
std::string skyboxModleFilePath = getAssetPath() + "models/cube.gltf"; // tonemapping
std::string skyboxVertShaderPath = getAssetPath() + "shaders/skybox.vert.spv"; std::string tonemappingVertShaderPath = getAssetPath() + "buster_drone/shaders/glsl/genbrdflut.vert.spv";
std::string skyboxFragShaderPath = getAssetPath() + "shaders/skybox.frag.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 iblTexturesFilePath = getAssetPath() + "textures/hdr/gcanyon_cube.ktx"; // cube map
//tonemapping std::string irradianceFragShaderPath = getAssetPath() + "shaders/irradiancecube.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 filterVertShaderPath = getAssetPath() + "shaders/filtercube.vert.spv";
// cube map std::string prefilterEnvmapFragShaderPath = getAssetPath() + "shaders/prefilterenvmap.frag.spv";
std::string irradianceFragShaderPath = getAssetPath() + "shaders/irradiancecube.frag.spv"; // brdf cube map
std::string brdfVertShaderPath = getAssetPath() + "shaders/genbrdflut.vert.spv";
std::string brdfFragShaderPath = getAssetPath() + "shaders/genbrdflut.frag.spv";
// environment map texture
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";
std::string pbrFragShaderPath = getAssetPath() + "shaders/pbr_khr.frag.spv";
std::string filterVertShaderPath = getAssetPath() + "shaders/filtercube.vert.spv"; // ttf file path
std::string ttfFilePath = getAssetPath() + "/data/Roboto-Medium.ttf";
std::string prefilterEnvmapFragShaderPath = getAssetPath() + "shaders/prefilterenvmap.frag.spv"; // output file path
//brdf cube map
std::string brdfVertShaderPath = getAssetPath() + "shaders/genbrdflut.vert.spv";
std::string brdfFragShaderPath = getAssetPath() + "shaders/genbrdflut.frag.spv";
// environment map texture
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";
std::string pbrFragShaderPath = getAssetPath() + "shaders/pbr_khr.frag.spv";
//ttf file path std::string imageOutputPath = getAssetPath() + "output/imageSequence";
std::string ttfFilePath = getAssetPath() + "/data/Roboto-Medium.ttf"; std::string videoOutputPath = getAssetPath() + "output/video";
std::string totalImageOutputPath;
std::string deviceSpecFilePath;
// output file path // script file path
std::string image2videoBatFilePath = getAssetPath() + "script/image2video.bat";
std::string image2videoShFilePath = getAssetPath() + "script/image2video.sh";
std::string imageOutputPath = getAssetPath() + "output/imageSequence"; } filePath;
std::string videoOutputPath = getAssetPath() + "output/video";
std::string totalImageOutputPath;
std::string deviceSpecFilePath;
// script file path float modelrot = 0.0f;
std::string image2videoBatFilePath = getAssetPath() + "script/image2video.bat"; glm::vec3 modelPos = glm::vec3(0.0f);
std::string image2videoShFilePath = getAssetPath() + "script/image2video.sh";
} filePath; enum PBRWorkflows
{
PBR_WORKFLOW_METALLIC_ROUGHNESS = 0,
PBR_WORKFLOW_SPECULAR_GLOSINESS = 1
};
std::map<std::string, std::string> environments;
float modelrot = 0.0f; std::string selectedEnvironment = "papermill";
glm::vec3 modelPos = glm::vec3(0.0f); std::map<std::string, std::string> scenes;
std::string selectedScene = "DamagedHelmet";
enum PBRWorkflows { PBR_WORKFLOW_METALLIC_ROUGHNESS = 0, PBR_WORKFLOW_SPECULAR_GLOSINESS = 1 }; int32_t debugViewInputs = 0;
int32_t debugViewEquation = 0;
struct StagingBuffer
{
VkBuffer buffer;
VkDeviceMemory memory;
} vertexStaging, indexStaging;
std::map<std::string, std::string> environments; struct Pipelines
std::string selectedEnvironment = "papermill"; {
std::map<std::string, std::string> scenes; VkPipeline skybox;
std::string selectedScene = "DamagedHelmet"; VkPipeline pbr;
VkPipeline pbrDoubleSided;
VkPipeline pbrAlphaBlend;
VkPipeline solid;
VkPipeline wireframe = VK_NULL_HANDLE;
VkPipeline toneMapping = VK_NULL_HANDLE;
} pipelines;
int32_t debugViewInputs = 0; VkPipeline boundPipeline = VK_NULL_HANDLE;
int32_t debugViewEquation = 0;
struct StagingBuffer { struct PipelineLayouts
VkBuffer buffer; {
VkDeviceMemory memory; VkDescriptorSetLayout scene;
} vertexStaging, indexStaging; VkDescriptorSetLayout material;
VkDescriptorSetLayout node;
VkPipelineLayout tonemappingLayout;
} pipelineLayouts;
struct Pipelines { VkPipelineLayout pipelineLayout;
VkPipeline skybox;
VkPipeline pbr;
VkPipeline pbrDoubleSided;
VkPipeline pbrAlphaBlend;
VkPipeline solid;
VkPipeline wireframe = VK_NULL_HANDLE;
VkPipeline toneMapping = VK_NULL_HANDLE;
} pipelines;
VkPipeline boundPipeline = VK_NULL_HANDLE; struct DescriptorSets
{
VkDescriptorSet scene;
VkDescriptorSet skybox;
VkDescriptorSet tonemappingDescriptorSet = VK_NULL_HANDLE;
};
struct PipelineLayouts struct DescriptorSetLayouts
{ {
VkDescriptorSetLayout scene; VkDescriptorSetLayout scene;
VkDescriptorSetLayout material; VkDescriptorSetLayout material;
VkDescriptorSetLayout node; VkDescriptorSetLayout node;
VkPipelineLayout tonemappingLayout; } descriptorSetLayouts;
} pipelineLayouts;
VkPipelineLayout pipelineLayout; std::vector<DescriptorSets> descriptorSets;
struct DescriptorSets { std::vector<VkCommandBuffer> commandBuffers;
VkDescriptorSet scene; std::vector<UniformBufferSet> uniformBuffers;
VkDescriptorSet skybox;
VkDescriptorSet tonemappingDescriptorSet = VK_NULL_HANDLE;
};
struct DescriptorSetLayouts { std::vector<VkFence> waitFences;
VkDescriptorSetLayout scene; std::vector<VkSemaphore> renderCompleteSemaphores;
VkDescriptorSetLayout material; std::vector<VkSemaphore> presentCompleteSemaphores;
VkDescriptorSetLayout node;
} descriptorSetLayouts;
std::vector<DescriptorSets> descriptorSets; const uint32_t renderAhead = 2;
uint32_t frameIndex = 0;
std::vector<VkCommandBuffer> commandBuffers; // VkImage swapChainImage;
std::vector<UniformBufferSet> uniformBuffers;
std::vector<VkFence> waitFences; int32_t animationIndex = 0;
std::vector<VkSemaphore> renderCompleteSemaphores; float animationTimer = 0.0f;
std::vector<VkSemaphore> presentCompleteSemaphores; bool animate = true;
const uint32_t renderAhead = 2; bool displayBackground = true;
uint32_t frameIndex = 0;
//VkImage swapChainImage; struct LightSource
{
glm::vec3 color = glm::vec3(1.0f);
glm::vec3 rotation = glm::vec3(75.0f, 40.0f, 0.0f);
} lightSource;
int32_t animationIndex = 0; // cube map generation
float animationTimer = 0.0f;
bool animate = true;
bool displayBackground = true; struct OffScreen
{
VkImage image;
VkImageView view;
VkDeviceMemory memory;
VkFramebuffer framebuffer;
} offscreen;
struct LightSource { struct IrradiancePushBlock
glm::vec3 color = glm::vec3(1.0f); {
glm::vec3 rotation = glm::vec3(75.0f, 40.0f, 0.0f); glm::mat4 mvp;
} lightSource; // Sampling deltas
float deltaPhi = (2.0f * float(M_PI)) / 180.0f;
float deltaTheta = (0.5f * float(M_PI)) / 64.0f;
} irradiancePushBlock;
struct PrefilterPushBlock
{
glm::mat4 mvp;
float roughness;
uint32_t numSamples = 32u;
} prefilterPushBlock;
//cube map generation UI *gui;
struct OffScreen
{
VkImage image;
VkImageView view;
VkDeviceMemory memory;
VkFramebuffer framebuffer;
} offscreen;
struct IrradiancePushBlock
{
glm::mat4 mvp;
// Sampling deltas
float deltaPhi = (2.0f * float(M_PI)) / 180.0f;
float deltaTheta = (0.5f * float(M_PI)) / 64.0f;
} irradiancePushBlock;
struct PrefilterPushBlock { uint64_t savedFrameCounter = settings.startFrameCount;
glm::mat4 mvp;
float roughness;
uint32_t numSamples = 32u;
} prefilterPushBlock;
UI* gui; PlumageRender();
~PlumageRender()
{
// Clean up used Vulkan resources
// Note : Inherited destructor cleans up resources stored in base class
vkDestroyPipeline(device, pipelines.skybox, nullptr);
vkDestroyPipeline(device, pipelines.pbr, nullptr);
vkDestroyPipeline(device, pipelines.pbrAlphaBlend, nullptr);
uint64_t savedFrameCounter = settings.startFrameCount; vkDestroyPipelineLayout(device, pipelineLayout, nullptr);
vkDestroyDescriptorSetLayout(device, descriptorSetLayouts.scene, nullptr);
vkDestroyDescriptorSetLayout(device, descriptorSetLayouts.material, nullptr);
vkDestroyDescriptorSetLayout(device, descriptorSetLayouts.node, nullptr);
PlumageRender(); models.scene.destroy(device);
~PlumageRender() models.skybox.destroy(device);
{
// Clean up used Vulkan resources
// Note : Inherited destructor cleans up resources stored in base class
vkDestroyPipeline(device, pipelines.skybox, nullptr);
vkDestroyPipeline(device, pipelines.pbr, nullptr);
vkDestroyPipeline(device, pipelines.pbrAlphaBlend, nullptr);
vkDestroyPipelineLayout(device, pipelineLayout, nullptr); for (auto buffer : uniformBuffers)
vkDestroyDescriptorSetLayout(device, descriptorSetLayouts.scene, nullptr); {
vkDestroyDescriptorSetLayout(device, descriptorSetLayouts.material, nullptr); buffer.params.destroy();
vkDestroyDescriptorSetLayout(device, descriptorSetLayouts.node, nullptr); buffer.scene.destroy();
buffer.skybox.destroy();
}
for (auto fence : waitFences)
{
vkDestroyFence(device, fence, nullptr);
}
for (auto semaphore : renderCompleteSemaphores)
{
vkDestroySemaphore(device, semaphore, nullptr);
}
for (auto semaphore : presentCompleteSemaphores)
{
vkDestroySemaphore(device, semaphore, nullptr);
}
models.scene.destroy(device); textures.environmentCube.destroy();
models.skybox.destroy(device); textures.irradianceCube.destroy();
textures.prefilteredCube.destroy();
textures.lutBrdf.destroy();
textures.empty.destroy();
delete gui;
}
for (auto buffer : uniformBuffers) { void renderNode(glTFModel::Node *node, uint32_t cbIndex, glTFModel::Material::AlphaMode alphaMode);
buffer.params.destroy(); void loadScene(std::string filename);
buffer.scene.destroy(); void loadEnvironment(std::string filename);
buffer.skybox.destroy(); void buildCommandBuffers();
} void loadAssets();
for (auto fence : waitFences) { void setupNodeDescriptorSet(glTFModel::Node *node);
vkDestroyFence(device, fence, nullptr); void setupDescriptors();
} void preparePipelines();
for (auto semaphore : renderCompleteSemaphores) { // void tonemappingPipelin();
vkDestroySemaphore(device, semaphore, nullptr); void generateCubemaps();
} void generateBRDFLUT();
for (auto semaphore : presentCompleteSemaphores) { void prepareUniformBuffers();
vkDestroySemaphore(device, semaphore, nullptr); void updateUniformBuffers();
} void updateShaderData();
void windowResized();
void prepare();
void submitWork(VkCommandBuffer cmdBuffer, VkQueue queue);
textures.environmentCube.destroy(); void writeImageToFile(std::string filePath);
textures.irradianceCube.destroy(); void outputImageSequence();
textures.prefilteredCube.destroy(); void imageSequenceToVideo();
textures.lutBrdf.destroy(); void removeImageSequence();
textures.empty.destroy(); // void outputScreenShot();
delete gui; uint32_t getMemoryTypeIndex(uint32_t typeBits, VkMemoryPropertyFlags properties);
} virtual void render();
virtual void updateUIOverlay();
void renderNode(glTFModel::Node* node, uint32_t cbIndex, glTFModel::Material::AlphaMode alphaMode); virtual void fileDropped(std::string filename);
void loadScene(std::string filename);
void loadEnvironment(std::string filename);
void buildCommandBuffers();
void loadAssets();
void setupNodeDescriptorSet(glTFModel::Node* node);
void setupDescriptors();
void preparePipelines();
// void tonemappingPipelin();
void generateCubemaps();
void generateBRDFLUT();
void prepareUniformBuffers();
void updateUniformBuffers();
void updateShaderData();
void windowResized();
void prepare();
void submitWork(VkCommandBuffer cmdBuffer, VkQueue queue);
void writeImageToFile(std::string filePath);
void outputImageSequence();
void imageSequenceToVideo();
void removeImageSequence();
//void outputScreenShot();
uint32_t getMemoryTypeIndex(uint32_t typeBits, VkMemoryPropertyFlags properties);
virtual void render();
virtual void updateUIOverlay();
virtual void fileDropped(std::string filename);
}; };

View File

@ -0,0 +1,49 @@
#include "renderEffectState.h"
RenderEffectState::RenderEffectState()
{
}
RenderEffectState::~RenderEffectState()
{
}
void RenderEffectState::setWireframe(bool value)
{
m_wireframe = value;
}
bool RenderEffectState::getWireframe() const
{
return m_wireframe;
}
void RenderEffectState::setNormalMapping(bool value)
{
m_normalMapping = value;
}
bool RenderEffectState::getNormalMapping() const
{
return m_normalMapping;
}
void RenderEffectState::setToneMapping(bool value)
{
m_toneMapping = value;
}
bool RenderEffectState::getToneMapping() const
{
return m_toneMapping;
}
void RenderEffectState::setPbrEnabled(bool value)
{
m_pbrEnabled = value;
}
bool RenderEffectState::getPbrEnabled() const
{
return m_pbrEnabled;
}

View File

@ -0,0 +1,28 @@
#pragma once
class RenderEffectState
{
public:
RenderEffectState();
~RenderEffectState();
void setWireframe(bool value);
bool getWireframe() const;
void setNormalMapping(bool value);
bool getNormalMapping() const;
void setToneMapping(bool value);
bool getToneMapping() const;
void setPbrEnabled(bool value);
bool getPbrEnabled() const;
private:
bool m_wireframe = false;
bool m_normalMapping = true;
bool m_toneMapping = true;
bool m_pbrEnabled = true;
};

View File

@ -0,0 +1,31 @@
#include "renderSceneModel.h"
RenderSceneModel::RenderSceneModel()
{
}
RenderSceneModel::~RenderSceneModel()
{
}
void RenderSceneModel::setScene(glTFModel::Model value)
{
m_scene = value;
}
glTFModel::Model RenderSceneModel::getScene() const
{
return m_scene;
}
void RenderSceneModel::setSkyBox(glTFModel::Model value)
{
m_skybox = value;
}
glTFModel::Model RenderSceneModel::getSkyBox() const
{
return m_skybox;
}

View File

@ -0,0 +1,20 @@
#pragma once
#include "glTFModel.h"
class RenderSceneModel
{
public:
RenderSceneModel();
~RenderSceneModel();
void setScene(glTFModel::Model value);
glTFModel::Model getScene() const;
void setSkyBox(glTFModel::Model value);
glTFModel::Model getSkyBox() const;
private:
glTFModel::Model m_scene;
glTFModel::Model m_skybox;
};

View File

@ -0,0 +1,81 @@
#include "renderShaderData.h"
RenderShaderData::RenderShaderData()
{
}
RenderShaderData::~RenderShaderData()
{
}
// Getters
const glm::vec4 &RenderShaderData::getLightDir() const
{
return m_lightDir;
}
float RenderShaderData::getExposure() const
{
return m_exposure;
}
float RenderShaderData::getGamma() const
{
return m_gamma;
}
float RenderShaderData::getPrefilteredCubeMipLevels() const
{
return m_prefilteredCubeMipLevels;
}
float RenderShaderData::getScaleIBLAmbient() const
{
return m_scaleIBLAmbient;
}
float RenderShaderData::getDebugViewInputs() const
{
return m_debugViewInputs;
}
float RenderShaderData::getDebugViewEquation() const
{
return m_debugViewEquation;
}
// Setters
void RenderShaderData::setLightDir(const glm::vec4 &dir)
{
m_lightDir = dir;
}
void RenderShaderData::setExposure(float exp)
{
m_exposure = exp;
}
void RenderShaderData::setGamma(float g)
{
m_gamma = g;
}
void RenderShaderData::setPrefilteredCubeMipLevels(float levels)
{
m_prefilteredCubeMipLevels = levels;
}
void RenderShaderData::setScaleIBLAmbient(float scale)
{
m_scaleIBLAmbient = scale;
}
void RenderShaderData::setDebugViewInputs(float view)
{
m_debugViewInputs = view;
}
void RenderShaderData::setDebugViewEquation(float equation)
{
m_debugViewEquation = equation;
}

View File

@ -0,0 +1,37 @@
#pragma once
#include <glm/glm.hpp>
class RenderShaderData
{
public:
RenderShaderData();
~RenderShaderData();
// Getters
const glm::vec4 &getLightDir() const;
float getExposure() const;
float getGamma() const;
float getPrefilteredCubeMipLevels() const;
float getScaleIBLAmbient() const;
float getDebugViewInputs() const;
float getDebugViewEquation() const;
// Setters
void setLightDir(const glm::vec4 &dir);
void setExposure(float exp);
void setGamma(float g);
void setPrefilteredCubeMipLevels(float levels);
void setScaleIBLAmbient(float scale);
void setDebugViewInputs(float view);
void setDebugViewEquation(float equation);
private:
glm::vec4 m_lightDir;
float m_exposure = 4.5f;
float m_gamma = 2.2f;
float m_prefilteredCubeMipLevels;
float m_scaleIBLAmbient = 2.0f;
float m_debugViewInputs = 0;
float m_debugViewEquation = 0;
};

View File

@ -0,0 +1,23 @@
#include "renderStagingBuffer.h"
// Getter method definitions
VkBuffer RenderStagingBuffer::getBuffer() const
{
return buffer;
}
VkDeviceMemory RenderStagingBuffer::getMemory() const
{
return memory;
}
// Setter method definitions
void RenderStagingBuffer::setBuffer(VkBuffer buffer)
{
this->buffer = buffer;
}
void RenderStagingBuffer::setMemory(VkDeviceMemory memory)
{
this->memory = memory;
}

View File

@ -0,0 +1,18 @@
#pragma once
#include <vulkan/vulkan.h>
class RenderStagingBuffer
{
public:
// Getter methods
VkBuffer getBuffer() const;
VkDeviceMemory getMemory() const;
// Setter methods
void setBuffer(VkBuffer buffer);
void setMemory(VkDeviceMemory memory);
protected:
VkBuffer buffer;
VkDeviceMemory memory;
};

View File

@ -0,0 +1,43 @@
#include "renderUBOMatrices.h"
// Getter method definitions
const glm::mat4 &RenderUBOMatrices::getProjection() const
{
return projection;
}
const glm::mat4 &RenderUBOMatrices::getModel() const
{
return model;
}
const glm::mat4 &RenderUBOMatrices::getView() const
{
return view;
}
const glm::vec3 &RenderUBOMatrices::getCamPos() const
{
return camPos;
}
// Setter method definitions
void RenderUBOMatrices::setProjection(const glm::mat4 &proj)
{
projection = proj;
}
void RenderUBOMatrices::setModel(const glm::mat4 &mod)
{
model = mod;
}
void RenderUBOMatrices::setView(const glm::mat4 &v)
{
view = v;
}
void RenderUBOMatrices::setCamPos(const glm::vec3 &pos)
{
camPos = pos;
}

View File

@ -0,0 +1,26 @@
#pragma once
#include <glm/glm.hpp>
class RenderUBOMatrices
{
public:
// Getter methods
const glm::mat4 &getProjection() const;
const glm::mat4 &getModel() const;
const glm::mat4 &getView() const;
const glm::vec3 &getCamPos() const;
// Setter methods
void setProjection(const glm::mat4 &proj);
void setModel(const glm::mat4 &mod);
void setView(const glm::mat4 &v);
void setCamPos(const glm::vec3 &pos);
protected:
glm::mat4 projection;
glm::mat4 model;
glm::mat4 view;
glm::vec3 camPos;
};

View File

@ -0,0 +1,41 @@
#include "renderUniformBufferSet.h"
RenderUniformBufferSet::RenderUniformBufferSet()
{
}
RenderUniformBufferSet::~RenderUniformBufferSet()
{
}
// Getter method definitions
const Buffer &RenderUniformBufferSet::getScene() const
{
return scene;
}
const Buffer &RenderUniformBufferSet::getSkybox() const
{
return skybox;
}
const Buffer &RenderUniformBufferSet::getParams() const
{
return params;
}
// Setter method definitions
void RenderUniformBufferSet::setScene(const Buffer &buffer)
{
scene = buffer;
}
void RenderUniformBufferSet::setSkybox(const Buffer &buffer)
{
skybox = buffer;
}
void RenderUniformBufferSet::setParams(const Buffer &buffer)
{
params = buffer;
}

View File

@ -0,0 +1,25 @@
#pragma once
#include "VulkanUtils.hpp"
class RenderUniformBufferSet
{
public:
RenderUniformBufferSet();
~RenderUniformBufferSet();
// Getter methods
const Buffer &getScene() const;
const Buffer &getSkybox() const;
const Buffer &getParams() const;
// Setter methods
void setScene(const Buffer &buffer);
void setSkybox(const Buffer &buffer);
void setParams(const Buffer &buffer);
private:
Buffer scene;
Buffer skybox;
Buffer params;
};

View File

@ -0,0 +1,30 @@
#include "renderVideoOutputState.h"
RenderVideoOutputState::RenderVideoOutputState()
{
}
RenderVideoOutputState::~RenderVideoOutputState()
{
}
void RenderVideoOutputState::setImageSequenceOutputComplete(bool value)
{
m_imageSequenceOutputComplete = value;
}
bool RenderVideoOutputState::getImageSequenceOutputComplete() const
{
return m_imageSequenceOutputComplete;
}
void RenderVideoOutputState::setImageSequenceToVideoComplete(bool value)
{
m_imageSequenceToVideoComplete = value;
}
bool RenderVideoOutputState::getImageSequenceToVideoComplete() const
{
return m_imageSequenceToVideoComplete;
}

View File

@ -0,0 +1,21 @@
#pragma once
class RenderVideoOutputState
{
public:
RenderVideoOutputState();
~RenderVideoOutputState();
void setImageSequenceOutputComplete(bool value);
bool getImageSequenceOutputComplete() const;
void setImageSequenceToVideoComplete(bool value);
bool getImageSequenceToVideoComplete() const;
private:
bool m_imageSequenceOutputComplete = false;
bool m_imageSequenceToVideoComplete = false;
};