diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..2b4ffc1 --- /dev/null +++ b/.clang-format @@ -0,0 +1,8 @@ +BasedOnStyle: Microsoft +AccessModifierOffset: -4 +AlignConsecutiveMacros: true +AlignTrailingComments: true +AllowShortFunctionsOnASingleLine: Inline +AllowShortIfStatementsOnASingleLine: false +BreakBeforeBraces: Allman +ColumnLimit: 0 \ No newline at end of file diff --git a/.gitignore b/.gitignore index 720f574..c59780b 100644 --- a/.gitignore +++ b/.gitignore @@ -39,7 +39,8 @@ out/ .vs/ vulkan_asset_pack_gltf.zip *.zip - +.cache/ +/.cache # vscode build file build/ @@ -55,3 +56,5 @@ build/ *.ktx data/output/video/device0/result.mp4 + +*.idx diff --git a/CMakeLists.txt b/CMakeLists.txt index 5ebbd31..92f36fa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ -cmake_minimum_required(VERSION 3.5 FATAL_ERROR) -cmake_policy(VERSION 3.5) +cmake_minimum_required(VERSION 3.10) +cmake_policy(SET CMP0077 NEW) -set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake") diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 69144c2..ce9aa5d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,4 +1,4 @@ - + SET(PLUMAGE_RENDER "${CMAKE_CURRENT_SOURCE_DIR}/render") message("working path ${PLUMAGE_RENDER}") @@ -15,8 +15,8 @@ set(GLTF_MODEL_LOADER "gltf/glTFBoundingBox.cpp" "gltf/glTFTexture.h" "gltf/glTFTexture.cpp" - "gltf/glTFModel.h" - "gltf/glTFModel.cpp" + #"gltf/glTFModel.h" + #"gltf/glTFModel.cpp" "gltf/glTFMaterial.h" "gltf/glTFMaterial.cpp" "gltf/glTFPrimitive.h" @@ -36,39 +36,12 @@ set(GLTF_MODEL_LOADER "gltf/glTFMainModel.h" "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_glm_path}) include_directories(${3rdParty_imgui_path}) diff --git a/src/base/CMakeLists.txt b/src/base/CMakeLists.txt index 0c7ee8d..04dbb81 100644 --- a/src/base/CMakeLists.txt +++ b/src/base/CMakeLists.txt @@ -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}) diff --git a/src/gltf/glTFAnimation.h b/src/gltf/glTFAnimation.h index c83dd66..0b896c1 100644 --- a/src/gltf/glTFAnimation.h +++ b/src/gltf/glTFAnimation.h @@ -1,4 +1,4 @@ -#ifndef GLTFANIMATION_H +#ifndef GLTFANIMATION_H #define GLTFANIMATION_H #include "glTFModel_Marco.h" @@ -27,7 +27,6 @@ public: std::vector getSampler(); void pushSamplersBack(glTFAnimationSampler value); - void setName(std::string name); std::string getName(); diff --git a/src/pbr/PbrTextureCoordSet.cpp b/src/pbr/PbrTextureCoordSet.cpp index a60d30c..c2e4915 100644 --- a/src/pbr/PbrTextureCoordSet.cpp +++ b/src/pbr/PbrTextureCoordSet.cpp @@ -1,7 +1,7 @@ -#include "TextureCoordSet.h" +#include "PbrTextureCoordSet.h" -VULKANBASE_NAMESPACE_BEGIN +GLTFLOADER_NAMESPACE_BEGIN TextureCoordSet::TextureCoordSet() { @@ -71,4 +71,4 @@ unsigned char TextureCoordSet::getEmissive() return m_emissive; } -VULKANBASE_NAMESPACE_END \ No newline at end of file +GLTFLOADER_NAMESPACE_END \ No newline at end of file diff --git a/src/render/ConfigFilePath.cpp b/src/render/ConfigFilePath.cpp new file mode 100644 index 0000000..acc9533 --- /dev/null +++ b/src/render/ConfigFilePath.cpp @@ -0,0 +1,307 @@ +#include "configFilePath.h" +#include + +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; +} \ No newline at end of file diff --git a/src/render/ConfigFilePath.h b/src/render/ConfigFilePath.h new file mode 100644 index 0000000..1bef60e --- /dev/null +++ b/src/render/ConfigFilePath.h @@ -0,0 +1,98 @@ +#pragma once + +#include +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"; +}; diff --git a/src/render/IndexStagingBuffer.cpp b/src/render/IndexStagingBuffer.cpp new file mode 100644 index 0000000..24ae063 --- /dev/null +++ b/src/render/IndexStagingBuffer.cpp @@ -0,0 +1,8 @@ +#include "IndexStagingBuffer.h" + +IndexStagingBuffer::IndexStagingBuffer() +{ +} +IndexStagingBuffer::~IndexStagingBuffer() +{ +} \ No newline at end of file diff --git a/src/render/IndexStagingBuffer.h b/src/render/IndexStagingBuffer.h new file mode 100644 index 0000000..f3dabde --- /dev/null +++ b/src/render/IndexStagingBuffer.h @@ -0,0 +1,8 @@ +#pragma once +#include "RenderStagingBuffer.h" +class IndexStagingBuffer : public RenderStagingBuffer +{ +public: + IndexStagingBuffer(); + ~IndexStagingBuffer(); +}; \ No newline at end of file diff --git a/src/render/IrradiancePushBlock.cpp b/src/render/IrradiancePushBlock.cpp new file mode 100644 index 0000000..f5716ab --- /dev/null +++ b/src/render/IrradiancePushBlock.cpp @@ -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; +} \ No newline at end of file diff --git a/src/render/IrradiancePushBlock.h b/src/render/IrradiancePushBlock.h new file mode 100644 index 0000000..ab66c6a --- /dev/null +++ b/src/render/IrradiancePushBlock.h @@ -0,0 +1,23 @@ +#pragma once +#include "RenderPushBlock.h" + +#include + +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; +}; \ No newline at end of file diff --git a/src/render/LocalizationStrings.cpp b/src/render/LocalizationStrings.cpp new file mode 100644 index 0000000..f081586 --- /dev/null +++ b/src/render/LocalizationStrings.cpp @@ -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; } \ No newline at end of file diff --git a/src/render/LocalizationStrings.h b/src/render/LocalizationStrings.h new file mode 100644 index 0000000..87c13f7 --- /dev/null +++ b/src/render/LocalizationStrings.h @@ -0,0 +1,70 @@ +#pragma once + +#include + +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 = "动画序列"; +}; \ No newline at end of file diff --git a/src/render/PrefilterPushBlock.cpp b/src/render/PrefilterPushBlock.cpp new file mode 100644 index 0000000..909786d --- /dev/null +++ b/src/render/PrefilterPushBlock.cpp @@ -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; +} \ No newline at end of file diff --git a/src/render/PrefilterPushBlock.h b/src/render/PrefilterPushBlock.h new file mode 100644 index 0000000..61192d7 --- /dev/null +++ b/src/render/PrefilterPushBlock.h @@ -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; +}; \ No newline at end of file diff --git a/src/render/PushConstBlockMaterial.cpp b/src/render/PushConstBlockMaterial.cpp new file mode 100644 index 0000000..f6b2ad5 --- /dev/null +++ b/src/render/PushConstBlockMaterial.cpp @@ -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; +} \ No newline at end of file diff --git a/src/render/PushConstBlockMaterial.h b/src/render/PushConstBlockMaterial.h new file mode 100644 index 0000000..713c743 --- /dev/null +++ b/src/render/PushConstBlockMaterial.h @@ -0,0 +1,54 @@ +#pragma once + +#include +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; +}; \ No newline at end of file diff --git a/src/render/RenderDescriptorSetLayoutList.cpp b/src/render/RenderDescriptorSetLayoutList.cpp new file mode 100644 index 0000000..b8ea6d9 --- /dev/null +++ b/src/render/RenderDescriptorSetLayoutList.cpp @@ -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; +} \ No newline at end of file diff --git a/src/render/RenderDescriptorSetLayoutList.h b/src/render/RenderDescriptorSetLayoutList.h new file mode 100644 index 0000000..ab8282c --- /dev/null +++ b/src/render/RenderDescriptorSetLayoutList.h @@ -0,0 +1,23 @@ +#pragma once +#include +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; +}; \ No newline at end of file diff --git a/src/render/RenderDescriptorSetList.cpp b/src/render/RenderDescriptorSetList.cpp new file mode 100644 index 0000000..0febb86 --- /dev/null +++ b/src/render/RenderDescriptorSetList.cpp @@ -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; +} \ No newline at end of file diff --git a/src/render/RenderDescriptorSetList.h b/src/render/RenderDescriptorSetList.h new file mode 100644 index 0000000..a95315b --- /dev/null +++ b/src/render/RenderDescriptorSetList.h @@ -0,0 +1,23 @@ +#pragma once +#include +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; +}; \ No newline at end of file diff --git a/src/render/RenderLightSource.cpp b/src/render/RenderLightSource.cpp new file mode 100644 index 0000000..f56cb9b --- /dev/null +++ b/src/render/RenderLightSource.cpp @@ -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; +} \ No newline at end of file diff --git a/src/render/RenderLightSource.h b/src/render/RenderLightSource.h new file mode 100644 index 0000000..503a9dd --- /dev/null +++ b/src/render/RenderLightSource.h @@ -0,0 +1,20 @@ +#pragma once +#include +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); +}; \ No newline at end of file diff --git a/src/render/RenderOffScreen.cpp b/src/render/RenderOffScreen.cpp new file mode 100644 index 0000000..034d7a1 --- /dev/null +++ b/src/render/RenderOffScreen.cpp @@ -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; +} \ No newline at end of file diff --git a/src/render/RenderOffScreen.h b/src/render/RenderOffScreen.h new file mode 100644 index 0000000..d251e42 --- /dev/null +++ b/src/render/RenderOffScreen.h @@ -0,0 +1,26 @@ +#pragma once +#include +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; +}; \ No newline at end of file diff --git a/src/render/RenderPipelineLayoutList.cpp b/src/render/RenderPipelineLayoutList.cpp new file mode 100644 index 0000000..a543c01 --- /dev/null +++ b/src/render/RenderPipelineLayoutList.cpp @@ -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; +} \ No newline at end of file diff --git a/src/render/RenderPipelineLayoutList.h b/src/render/RenderPipelineLayoutList.h new file mode 100644 index 0000000..3c1f4f1 --- /dev/null +++ b/src/render/RenderPipelineLayoutList.h @@ -0,0 +1,26 @@ +#pragma once +#include +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; +}; \ No newline at end of file diff --git a/src/render/RenderPipelineList.cpp b/src/render/RenderPipelineList.cpp new file mode 100644 index 0000000..abe3201 --- /dev/null +++ b/src/render/RenderPipelineList.cpp @@ -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; +} \ No newline at end of file diff --git a/src/render/RenderPipelineList.h b/src/render/RenderPipelineList.h new file mode 100644 index 0000000..baa3acc --- /dev/null +++ b/src/render/RenderPipelineList.h @@ -0,0 +1,35 @@ +#pragma once +#include +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; +}; \ No newline at end of file diff --git a/src/render/RenderPushBlock.cpp b/src/render/RenderPushBlock.cpp new file mode 100644 index 0000000..6be630f --- /dev/null +++ b/src/render/RenderPushBlock.cpp @@ -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; +} \ No newline at end of file diff --git a/src/render/RenderPushBlock.h b/src/render/RenderPushBlock.h new file mode 100644 index 0000000..1101587 --- /dev/null +++ b/src/render/RenderPushBlock.h @@ -0,0 +1,16 @@ +#pragma once +#include +class RenderPushBlock +{ +public: + RenderPushBlock(); + ~RenderPushBlock(); + // Getter methods + const glm::mat4 &getMvp() const; + + // Setter methods + void setMvp(const glm::mat4 &matrix); + +protected: + glm::mat4 mvp; +}; \ No newline at end of file diff --git a/src/render/RenderSceneTextures.cpp b/src/render/RenderSceneTextures.cpp new file mode 100644 index 0000000..d7106d5 --- /dev/null +++ b/src/render/RenderSceneTextures.cpp @@ -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() +{ +} \ No newline at end of file diff --git a/src/render/RenderSceneTextures.h b/src/render/RenderSceneTextures.h new file mode 100644 index 0000000..5ee9dbf --- /dev/null +++ b/src/render/RenderSceneTextures.h @@ -0,0 +1,31 @@ +#pragma once + +#include + +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; +}; diff --git a/src/render/SceneUBOMatrices.cpp b/src/render/SceneUBOMatrices.cpp new file mode 100644 index 0000000..7c5e15a --- /dev/null +++ b/src/render/SceneUBOMatrices.cpp @@ -0,0 +1,8 @@ +#include "SceneUBOMatrices.h" + +SceneUBOMatrices::SceneUBOMatrices() +{ +} +SceneUBOMatrices::~SceneUBOMatrices() +{ +} \ No newline at end of file diff --git a/src/render/SceneUBOMatrices.h b/src/render/SceneUBOMatrices.h new file mode 100644 index 0000000..52df8d2 --- /dev/null +++ b/src/render/SceneUBOMatrices.h @@ -0,0 +1,9 @@ +#pragma once + +#include "renderUBOMatrices.h" +class SceneUBOMatrices : public RenderUBOMatrices +{ +public: + SceneUBOMatrices(); + ~SceneUBOMatrices(); +}; \ No newline at end of file diff --git a/src/render/SkyboxUBOMatrices.cpp b/src/render/SkyboxUBOMatrices.cpp new file mode 100644 index 0000000..e16d79b --- /dev/null +++ b/src/render/SkyboxUBOMatrices.cpp @@ -0,0 +1,8 @@ +#include "SkyboxUBOMatrices.h" + +SkyboxUBOMatrices::SkyboxUBOMatrices() +{ +} +SkyboxUBOMatrices::~SkyboxUBOMatrices() +{ +} \ No newline at end of file diff --git a/src/render/SkyboxUBOMatrices.h b/src/render/SkyboxUBOMatrices.h new file mode 100644 index 0000000..3c9b22f --- /dev/null +++ b/src/render/SkyboxUBOMatrices.h @@ -0,0 +1,10 @@ +#pragma once + +#include "renderUBOMatrices.h" + +class SkyboxUBOMatrices : public RenderUBOMatrices +{ +public: + SkyboxUBOMatrices(); + ~SkyboxUBOMatrices(); +}; \ No newline at end of file diff --git a/src/render/VertexStagingBuffer.cpp b/src/render/VertexStagingBuffer.cpp new file mode 100644 index 0000000..365ad9c --- /dev/null +++ b/src/render/VertexStagingBuffer.cpp @@ -0,0 +1,8 @@ +#include "VertexStagingBuffer.h" + +VertexStagingBuffer::VertexStagingBuffer() +{ +} +VertexStagingBuffer::~VertexStagingBuffer() +{ +} \ No newline at end of file diff --git a/src/render/VertexStagingBuffer.h b/src/render/VertexStagingBuffer.h new file mode 100644 index 0000000..c61f657 --- /dev/null +++ b/src/render/VertexStagingBuffer.h @@ -0,0 +1,8 @@ +#pragma once +#include "renderStagingBuffer.h" +class VertexStagingBuffer : public RenderStagingBuffer +{ +public: + VertexStagingBuffer(); + ~VertexStagingBuffer(); +}; \ No newline at end of file diff --git a/src/render/VulkanBase_Marco.h b/src/render/VulkanBase_Marco.h index d36a557..71924c6 100644 --- a/src/render/VulkanBase_Marco.h +++ b/src/render/VulkanBase_Marco.h @@ -1,4 +1,4 @@ -#pragma once +#pragma once /// 命名空间宏 #define VULKANBASE_NAMESPACE_BEGIN namespace VulkanBase { diff --git a/src/render/VulkanDevice.cpp b/src/render/VulkanDevice.cpp index ba6ed06..f79837f 100644 --- a/src/render/VulkanDevice.cpp +++ b/src/render/VulkanDevice.cpp @@ -1,4 +1,4 @@ -#include "VulkanDevice.h" +#include "VulkanDevice.h" #include #include #include @@ -53,7 +53,7 @@ VkPhysicalDevice VulkanDevice::getPhysicalDevice() 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++) { 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"); } -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句柄 VkBufferCreateInfo bufferCreateInfo{}; @@ -145,7 +145,7 @@ VkResult VulkanDevice::createBuffer(VkBufferUsageFlags usageFlags, VkMemoryPrope 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 = {}; @@ -157,7 +157,7 @@ VkCommandPool VulkanDevice::createCommandPool(uint32_t queueFamilyIndex, VkComma return cmdPool; } -VkCommandBuffer VulkanDevice::createCommandBuffer(VkCommandBufferLevel level, bool begin = false) +VkCommandBuffer VulkanDevice::createCommandBuffer(VkCommandBufferLevel level, bool begin) { VkCommandBufferAllocateInfo cmdBufAllocateInfo{}; cmdBufAllocateInfo.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; @@ -183,7 +183,7 @@ void VulkanDevice::beginCommandBuffer(VkCommandBuffer commandBuffer) 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)); diff --git a/src/render/render.h b/src/render/render.h index f6100c2..6bc379a 100644 --- a/src/render/render.h +++ b/src/render/render.h @@ -1,378 +1,372 @@ -#pragma once - +#pragma once #if defined(_WIN32) -#include #include +#include + #else -#include -#include +#include +#include #endif #define STB_IMAGE_WRITE_IMPLEMENTATION #include "stb_image_write.h" - - +#include +#include +#include +#include #include #include -#include #include -#include #include -#include -#include -#include -#include #include "algorithm" -#include -#include +#include #include +#include +#include +#include -#include +#include "VulkanDevice.hpp" #include "VulkanExampleBase.h" #include "glTFModel.h" -#include -#include "VulkanDevice.hpp" #include "ui.hpp" +#include #include +#include #define ENABLE_VALIDATION false - +#include "renderEffectState.h" class PlumageRender : public VulkanExampleBase { +private: + RenderEffectState *m_effectState; + public: - bool wireframe = false; - bool normalMapping = true; - bool ToneMapping = true; - bool pbrEnabled = true; + struct Models + { + glTFModel::Model scene; + 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 - { - bool imageSequenceOutputComplete = false; - bool imageSequenceToVideoComplete = false; - - }signal; - + 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 = "当前模型没有动画!"; - struct Models - { - glTFModel::Model scene; - glTFModel::Model skybox; - } models; + const char *menuAnimationActivation = "开关"; + const char *menuAnimationAnimationSequence = "动画序列"; - struct Textures { - vks::TextureCubeMap environmentCube; - vks::Texture2D empty; - vks::Texture2D lutBrdf; - vks::TextureCubeMap irradianceCube; - vks::TextureCubeMap prefilteredCube; - } textures; + } chineseUI; - 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 = "模型"; - - 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 UniformBufferSet + { + Buffer scene; + Buffer skybox; + Buffer params; + }; + struct UBOMatrices + { + glm::mat4 projection; + glm::mat4 model; + glm::mat4 view; + glm::vec3 camPos; + } shaderDataScene, shaderDataSkybox; - }chineseUI; - struct UniformBufferSet { - Buffer scene; - Buffer skybox; - Buffer params; - }; + struct PushConstBlockMaterial + { + 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; + } pushConstBlockMaterial; - struct UBOMatrices { - glm::mat4 projection; - glm::mat4 model; - glm::mat4 view; - glm::vec3 camPos; - } shaderDataScene, shaderDataSkybox; + struct FilePath + { // model path + std::string glTFModelFilePath = getAssetPath() + "models/DamagedHelmet/DamagedHelmet.gltf"; + std::string modelVertShaderPath = getAssetPath() + "buster_drone/shaders/glsl/mesh.vert.spv"; + std::string modelFragShaderPath = getAssetPath() + "buster_drone/shaders/glsl/mesh.frag.spv"; - struct PushConstBlockMaterial { - 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; - } pushConstBlockMaterial; + // ui + std::string uiVertShaderPath = getAssetPath() + "shaders/ui.vert.spv"; + std::string uiFragShaderPath = getAssetPath() + "shaders/ui.frag.spv"; - struct FilePath - { //model path - std::string glTFModelFilePath = getAssetPath() + "models/DamagedHelmet/DamagedHelmet.gltf"; - std::string modelVertShaderPath = getAssetPath() + "buster_drone/shaders/glsl/mesh.vert.spv"; - std::string modelFragShaderPath = getAssetPath() + "buster_drone/shaders/glsl/mesh.frag.spv"; - - //ui - std::string uiVertShaderPath = getAssetPath() + "shaders/ui.vert.spv"; - std::string uiFragShaderPath = getAssetPath() + "shaders/ui.frag.spv"; + // skybox path + std::string skyboxModleFilePath = getAssetPath() + "models/cube.gltf"; + std::string skyboxVertShaderPath = getAssetPath() + "shaders/skybox.vert.spv"; + std::string skyboxFragShaderPath = getAssetPath() + "shaders/skybox.frag.spv"; - // skybox path - std::string skyboxModleFilePath = getAssetPath() + "models/cube.gltf"; - std::string skyboxVertShaderPath = getAssetPath() + "shaders/skybox.vert.spv"; - std::string skyboxFragShaderPath = getAssetPath() + "shaders/skybox.frag.spv"; + std::string iblTexturesFilePath = getAssetPath() + "textures/hdr/gcanyon_cube.ktx"; + // tonemapping + 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 iblTexturesFilePath = getAssetPath() + "textures/hdr/gcanyon_cube.ktx"; - //tonemapping - 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"; + // cube map + std::string irradianceFragShaderPath = getAssetPath() + "shaders/irradiancecube.frag.spv"; + std::string filterVertShaderPath = getAssetPath() + "shaders/filtercube.vert.spv"; - // cube map - std::string irradianceFragShaderPath = getAssetPath() + "shaders/irradiancecube.frag.spv"; + std::string prefilterEnvmapFragShaderPath = getAssetPath() + "shaders/prefilterenvmap.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"; - //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"; + // output file path - //ttf file path - std::string ttfFilePath = getAssetPath() + "/data/Roboto-Medium.ttf"; + std::string imageOutputPath = getAssetPath() + "output/imageSequence"; + 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"; - std::string videoOutputPath = getAssetPath() + "output/video"; - std::string totalImageOutputPath; - std::string deviceSpecFilePath; + } filePath; - // script file path - std::string image2videoBatFilePath = getAssetPath() + "script/image2video.bat"; - std::string image2videoShFilePath = getAssetPath() + "script/image2video.sh"; + float modelrot = 0.0f; + glm::vec3 modelPos = glm::vec3(0.0f); - } filePath; + enum PBRWorkflows + { + PBR_WORKFLOW_METALLIC_ROUGHNESS = 0, + PBR_WORKFLOW_SPECULAR_GLOSINESS = 1 + }; - - float modelrot = 0.0f; - glm::vec3 modelPos = glm::vec3(0.0f); - + std::map environments; + std::string selectedEnvironment = "papermill"; + std::map 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 environments; - std::string selectedEnvironment = "papermill"; - std::map scenes; - std::string selectedScene = "DamagedHelmet"; + struct Pipelines + { + VkPipeline skybox; + VkPipeline pbr; + VkPipeline pbrDoubleSided; + VkPipeline pbrAlphaBlend; + VkPipeline solid; + VkPipeline wireframe = VK_NULL_HANDLE; + VkPipeline toneMapping = VK_NULL_HANDLE; + } pipelines; - int32_t debugViewInputs = 0; - int32_t debugViewEquation = 0; + VkPipeline boundPipeline = VK_NULL_HANDLE; - struct StagingBuffer { - VkBuffer buffer; - VkDeviceMemory memory; - } vertexStaging, indexStaging; + struct PipelineLayouts + { + VkDescriptorSetLayout scene; + VkDescriptorSetLayout material; + VkDescriptorSetLayout node; + VkPipelineLayout tonemappingLayout; + } pipelineLayouts; - struct Pipelines { - VkPipeline skybox; - VkPipeline pbr; - VkPipeline pbrDoubleSided; - VkPipeline pbrAlphaBlend; - VkPipeline solid; - VkPipeline wireframe = VK_NULL_HANDLE; - VkPipeline toneMapping = VK_NULL_HANDLE; - } pipelines; + VkPipelineLayout pipelineLayout; - VkPipeline boundPipeline = VK_NULL_HANDLE; + struct DescriptorSets + { + VkDescriptorSet scene; + VkDescriptorSet skybox; + VkDescriptorSet tonemappingDescriptorSet = VK_NULL_HANDLE; + }; - struct PipelineLayouts - { - VkDescriptorSetLayout scene; - VkDescriptorSetLayout material; - VkDescriptorSetLayout node; - VkPipelineLayout tonemappingLayout; - } pipelineLayouts; + struct DescriptorSetLayouts + { + VkDescriptorSetLayout scene; + VkDescriptorSetLayout material; + VkDescriptorSetLayout node; + } descriptorSetLayouts; - VkPipelineLayout pipelineLayout; + std::vector descriptorSets; - struct DescriptorSets { - VkDescriptorSet scene; - VkDescriptorSet skybox; - VkDescriptorSet tonemappingDescriptorSet = VK_NULL_HANDLE; - }; - - + std::vector commandBuffers; + std::vector uniformBuffers; - struct DescriptorSetLayouts { - VkDescriptorSetLayout scene; - VkDescriptorSetLayout material; - VkDescriptorSetLayout node; - } descriptorSetLayouts; + std::vector waitFences; + std::vector renderCompleteSemaphores; + std::vector presentCompleteSemaphores; - std::vector descriptorSets; + const uint32_t renderAhead = 2; + uint32_t frameIndex = 0; - std::vector commandBuffers; - std::vector uniformBuffers; + // VkImage swapChainImage; - std::vector waitFences; - std::vector renderCompleteSemaphores; - std::vector presentCompleteSemaphores; + int32_t animationIndex = 0; + float animationTimer = 0.0f; + bool animate = true; - const uint32_t renderAhead = 2; - uint32_t frameIndex = 0; + bool displayBackground = true; - //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; - float animationTimer = 0.0f; - bool animate = true; + // cube map generation - bool displayBackground = true; + struct OffScreen + { + VkImage image; + VkImageView view; + VkDeviceMemory memory; + VkFramebuffer framebuffer; + } offscreen; - struct LightSource { - glm::vec3 color = glm::vec3(1.0f); - glm::vec3 rotation = glm::vec3(75.0f, 40.0f, 0.0f); - } lightSource; + 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 + { + glm::mat4 mvp; + float roughness; + uint32_t numSamples = 32u; + } prefilterPushBlock; - //cube map generation - - 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; + UI *gui; - struct PrefilterPushBlock { - glm::mat4 mvp; - float roughness; - uint32_t numSamples = 32u; - } prefilterPushBlock; + uint64_t savedFrameCounter = settings.startFrameCount; - 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(); - ~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); + models.scene.destroy(device); + models.skybox.destroy(device); - vkDestroyPipelineLayout(device, pipelineLayout, nullptr); - vkDestroyDescriptorSetLayout(device, descriptorSetLayouts.scene, nullptr); - vkDestroyDescriptorSetLayout(device, descriptorSetLayouts.material, nullptr); - vkDestroyDescriptorSetLayout(device, descriptorSetLayouts.node, nullptr); + for (auto buffer : uniformBuffers) + { + buffer.params.destroy(); + 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); - models.skybox.destroy(device); + textures.environmentCube.destroy(); + textures.irradianceCube.destroy(); + textures.prefilteredCube.destroy(); + textures.lutBrdf.destroy(); + textures.empty.destroy(); + delete gui; + } - for (auto buffer : uniformBuffers) { - buffer.params.destroy(); - 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); - } + void renderNode(glTFModel::Node *node, uint32_t cbIndex, glTFModel::Material::AlphaMode alphaMode); + 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); - textures.environmentCube.destroy(); - textures.irradianceCube.destroy(); - textures.prefilteredCube.destroy(); - textures.lutBrdf.destroy(); - textures.empty.destroy(); - delete gui; - } - - void renderNode(glTFModel::Node* node, uint32_t cbIndex, glTFModel::Material::AlphaMode alphaMode); - 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); + 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); }; \ No newline at end of file diff --git a/src/render/renderEffectState.cpp b/src/render/renderEffectState.cpp new file mode 100644 index 0000000..bae939a --- /dev/null +++ b/src/render/renderEffectState.cpp @@ -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; +} diff --git a/src/render/renderEffectState.h b/src/render/renderEffectState.h new file mode 100644 index 0000000..b73f4b0 --- /dev/null +++ b/src/render/renderEffectState.h @@ -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; + +}; + + + diff --git a/src/render/renderSceneModel.cpp b/src/render/renderSceneModel.cpp new file mode 100644 index 0000000..a0d70cd --- /dev/null +++ b/src/render/renderSceneModel.cpp @@ -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; +} + diff --git a/src/render/renderSceneModel.h b/src/render/renderSceneModel.h new file mode 100644 index 0000000..cb24547 --- /dev/null +++ b/src/render/renderSceneModel.h @@ -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; +}; diff --git a/src/render/renderShaderData.cpp b/src/render/renderShaderData.cpp new file mode 100644 index 0000000..3b54852 --- /dev/null +++ b/src/render/renderShaderData.cpp @@ -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; +} \ No newline at end of file diff --git a/src/render/renderShaderData.h b/src/render/renderShaderData.h new file mode 100644 index 0000000..0fb798f --- /dev/null +++ b/src/render/renderShaderData.h @@ -0,0 +1,37 @@ +#pragma once + +#include + +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; +}; \ No newline at end of file diff --git a/src/render/renderStagingBuffer.cpp b/src/render/renderStagingBuffer.cpp new file mode 100644 index 0000000..a71dc47 --- /dev/null +++ b/src/render/renderStagingBuffer.cpp @@ -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; +} \ No newline at end of file diff --git a/src/render/renderStagingBuffer.h b/src/render/renderStagingBuffer.h new file mode 100644 index 0000000..4bbfb6e --- /dev/null +++ b/src/render/renderStagingBuffer.h @@ -0,0 +1,18 @@ +#pragma once + +#include +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; +}; \ No newline at end of file diff --git a/src/render/renderUBOMatrices.cpp b/src/render/renderUBOMatrices.cpp new file mode 100644 index 0000000..eac61d3 --- /dev/null +++ b/src/render/renderUBOMatrices.cpp @@ -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; +} \ No newline at end of file diff --git a/src/render/renderUBOMatrices.h b/src/render/renderUBOMatrices.h new file mode 100644 index 0000000..de0a4d9 --- /dev/null +++ b/src/render/renderUBOMatrices.h @@ -0,0 +1,26 @@ +#pragma once + +#include + +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; +}; \ No newline at end of file diff --git a/src/render/renderUniformBufferSet.cpp b/src/render/renderUniformBufferSet.cpp new file mode 100644 index 0000000..784cc46 --- /dev/null +++ b/src/render/renderUniformBufferSet.cpp @@ -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; +} \ No newline at end of file diff --git a/src/render/renderUniformBufferSet.h b/src/render/renderUniformBufferSet.h new file mode 100644 index 0000000..52cce33 --- /dev/null +++ b/src/render/renderUniformBufferSet.h @@ -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; +}; \ No newline at end of file diff --git a/src/render/renderVideoOutputState.cpp b/src/render/renderVideoOutputState.cpp new file mode 100644 index 0000000..4f81f30 --- /dev/null +++ b/src/render/renderVideoOutputState.cpp @@ -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; +} + diff --git a/src/render/renderVideoOutputState.h b/src/render/renderVideoOutputState.h new file mode 100644 index 0000000..de4fea4 --- /dev/null +++ b/src/render/renderVideoOutputState.h @@ -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; + +}; +