From 52e5d81ee57fdfb8cb2737410bc89f9188a11935 Mon Sep 17 00:00:00 2001 From: Tobias Frisch <tfrisch@uni-koblenz.de> Date: Fri, 9 Jul 2021 12:27:12 +0200 Subject: [PATCH] [#56] Removed bloom project because it got merged into voxelization Signed-off-by: Tobias Frisch <tfrisch@uni-koblenz.de> --- projects/CMakeLists.txt | 3 +- projects/bloom/.gitignore | 1 - projects/bloom/CMakeLists.txt | 32 -- projects/bloom/resources/Sponza/Sponza.bin | 3 - projects/bloom/resources/Sponza/Sponza.gltf | 3 - .../bloom/resources/Sponza/background.png | 3 - .../bloom/resources/Sponza/chain_texture.png | 3 - projects/bloom/resources/Sponza/lion.png | 3 - .../resources/Sponza/spnza_bricks_a_diff.png | 3 - .../resources/Sponza/sponza_arch_diff.png | 3 - .../Sponza/sponza_ceiling_a_diff.png | 3 - .../resources/Sponza/sponza_column_a_diff.png | 3 - .../resources/Sponza/sponza_column_b_diff.png | 3 - .../resources/Sponza/sponza_column_c_diff.png | 3 - .../Sponza/sponza_curtain_blue_diff.png | 3 - .../resources/Sponza/sponza_curtain_diff.png | 3 - .../Sponza/sponza_curtain_green_diff.png | 3 - .../resources/Sponza/sponza_details_diff.png | 3 - .../Sponza/sponza_fabric_blue_diff.png | 3 - .../resources/Sponza/sponza_fabric_diff.png | 3 - .../Sponza/sponza_fabric_green_diff.png | 3 - .../resources/Sponza/sponza_flagpole_diff.png | 3 - .../resources/Sponza/sponza_floor_a_diff.png | 3 - .../resources/Sponza/sponza_roof_diff.png | 3 - .../resources/Sponza/sponza_thorn_diff.png | 3 - projects/bloom/resources/Sponza/vase_dif.png | 3 - .../bloom/resources/Sponza/vase_hanging.png | 3 - .../bloom/resources/Sponza/vase_plant.png | 3 - .../bloom/resources/Sponza/vase_round.png | 3 - projects/bloom/resources/shaders/comp.spv | Bin 6192 -> 0 bytes .../bloom/resources/shaders/composite.comp | 38 -- .../bloom/resources/shaders/downsample.comp | 76 ---- .../resources/shaders/gammaCorrection.comp | 20 - .../bloom/resources/shaders/lensFlares.comp | 109 ----- .../resources/shaders/perMeshResources.inc | 2 - projects/bloom/resources/shaders/shader.frag | 45 -- projects/bloom/resources/shaders/shader.vert | 22 - projects/bloom/resources/shaders/shadow.frag | 6 - projects/bloom/resources/shaders/shadow.vert | 12 - .../bloom/resources/shaders/upsample.comp | 45 -- projects/bloom/src/BloomAndFlares.cpp | 274 ------------ projects/bloom/src/BloomAndFlares.hpp | 47 -- projects/bloom/src/main.cpp | 417 ------------------ 43 files changed, 1 insertion(+), 1226 deletions(-) delete mode 100644 projects/bloom/.gitignore delete mode 100644 projects/bloom/CMakeLists.txt delete mode 100644 projects/bloom/resources/Sponza/Sponza.bin delete mode 100644 projects/bloom/resources/Sponza/Sponza.gltf delete mode 100644 projects/bloom/resources/Sponza/background.png delete mode 100644 projects/bloom/resources/Sponza/chain_texture.png delete mode 100644 projects/bloom/resources/Sponza/lion.png delete mode 100644 projects/bloom/resources/Sponza/spnza_bricks_a_diff.png delete mode 100644 projects/bloom/resources/Sponza/sponza_arch_diff.png delete mode 100644 projects/bloom/resources/Sponza/sponza_ceiling_a_diff.png delete mode 100644 projects/bloom/resources/Sponza/sponza_column_a_diff.png delete mode 100644 projects/bloom/resources/Sponza/sponza_column_b_diff.png delete mode 100644 projects/bloom/resources/Sponza/sponza_column_c_diff.png delete mode 100644 projects/bloom/resources/Sponza/sponza_curtain_blue_diff.png delete mode 100644 projects/bloom/resources/Sponza/sponza_curtain_diff.png delete mode 100644 projects/bloom/resources/Sponza/sponza_curtain_green_diff.png delete mode 100644 projects/bloom/resources/Sponza/sponza_details_diff.png delete mode 100644 projects/bloom/resources/Sponza/sponza_fabric_blue_diff.png delete mode 100644 projects/bloom/resources/Sponza/sponza_fabric_diff.png delete mode 100644 projects/bloom/resources/Sponza/sponza_fabric_green_diff.png delete mode 100644 projects/bloom/resources/Sponza/sponza_flagpole_diff.png delete mode 100644 projects/bloom/resources/Sponza/sponza_floor_a_diff.png delete mode 100644 projects/bloom/resources/Sponza/sponza_roof_diff.png delete mode 100644 projects/bloom/resources/Sponza/sponza_thorn_diff.png delete mode 100644 projects/bloom/resources/Sponza/vase_dif.png delete mode 100644 projects/bloom/resources/Sponza/vase_hanging.png delete mode 100644 projects/bloom/resources/Sponza/vase_plant.png delete mode 100644 projects/bloom/resources/Sponza/vase_round.png delete mode 100644 projects/bloom/resources/shaders/comp.spv delete mode 100644 projects/bloom/resources/shaders/composite.comp delete mode 100644 projects/bloom/resources/shaders/downsample.comp delete mode 100644 projects/bloom/resources/shaders/gammaCorrection.comp delete mode 100644 projects/bloom/resources/shaders/lensFlares.comp delete mode 100644 projects/bloom/resources/shaders/perMeshResources.inc delete mode 100644 projects/bloom/resources/shaders/shader.frag delete mode 100644 projects/bloom/resources/shaders/shader.vert delete mode 100644 projects/bloom/resources/shaders/shadow.frag delete mode 100644 projects/bloom/resources/shaders/shadow.vert delete mode 100644 projects/bloom/resources/shaders/upsample.comp delete mode 100644 projects/bloom/src/BloomAndFlares.cpp delete mode 100644 projects/bloom/src/BloomAndFlares.hpp delete mode 100644 projects/bloom/src/main.cpp diff --git a/projects/CMakeLists.txt b/projects/CMakeLists.txt index 1c6e3afe..4196d55d 100644 --- a/projects/CMakeLists.txt +++ b/projects/CMakeLists.txt @@ -1,8 +1,7 @@ # Add new projects/examples here: -add_subdirectory(bloom) add_subdirectory(first_triangle) add_subdirectory(first_mesh) -add_subdirectory(particle_simulation) add_subdirectory(first_scene) +add_subdirectory(particle_simulation) add_subdirectory(voxelization) diff --git a/projects/bloom/.gitignore b/projects/bloom/.gitignore deleted file mode 100644 index 3643183e..00000000 --- a/projects/bloom/.gitignore +++ /dev/null @@ -1 +0,0 @@ -bloom \ No newline at end of file diff --git a/projects/bloom/CMakeLists.txt b/projects/bloom/CMakeLists.txt deleted file mode 100644 index 8171938e..00000000 --- a/projects/bloom/CMakeLists.txt +++ /dev/null @@ -1,32 +0,0 @@ -cmake_minimum_required(VERSION 3.16) -project(bloom) - -# setting c++ standard for the project -set(CMAKE_CXX_STANDARD 17) -set(CMAKE_CXX_STANDARD_REQUIRED ON) - -# this should fix the execution path to load local files from the project -set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) - -# adding source files to the project -add_executable(bloom src/main.cpp) - -target_sources(bloom PRIVATE - src/BloomAndFlares.cpp - src/BloomAndFlares.hpp) - -# this should fix the execution path to load local files from the project (for MSVC) -if(MSVC) - set_target_properties(bloom PROPERTIES RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) - set_target_properties(bloom PROPERTIES RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) - - # in addition to setting the output directory, the working directory has to be set - # by default visual studio sets the working directory to the build directory, when using the debugger - set_target_properties(bloom PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) -endif() - -# including headers of dependencies and the VkCV framework -target_include_directories(bloom SYSTEM BEFORE PRIVATE ${vkcv_include} ${vkcv_includes} ${vkcv_asset_loader_include} ${vkcv_camera_include} ${vkcv_shader_compiler_include}) - -# linking with libraries from all dependencies and the VkCV framework -target_link_libraries(bloom vkcv ${vkcv_libraries} vkcv_asset_loader ${vkcv_asset_loader_libraries} vkcv_camera vkcv_shader_compiler) diff --git a/projects/bloom/resources/Sponza/Sponza.bin b/projects/bloom/resources/Sponza/Sponza.bin deleted file mode 100644 index cfedd26c..00000000 --- a/projects/bloom/resources/Sponza/Sponza.bin +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:4b809f7a17687dc99e6f41ca1ea32c06eded8779bf34d16f1f565d750b0ffd68 -size 6347696 diff --git a/projects/bloom/resources/Sponza/Sponza.gltf b/projects/bloom/resources/Sponza/Sponza.gltf deleted file mode 100644 index 172ea07e..00000000 --- a/projects/bloom/resources/Sponza/Sponza.gltf +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:5cc0ecad5c4694088ff820e663619c370421afc1323ac487406e8e9b4735d787 -size 713962 diff --git a/projects/bloom/resources/Sponza/background.png b/projects/bloom/resources/Sponza/background.png deleted file mode 100644 index b64def12..00000000 --- a/projects/bloom/resources/Sponza/background.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:f5b5f900ff8ed83a31750ec8e428b5b91273794ddcbfc4e4b8a6a7e781f8c686 -size 1417666 diff --git a/projects/bloom/resources/Sponza/chain_texture.png b/projects/bloom/resources/Sponza/chain_texture.png deleted file mode 100644 index c1e1768c..00000000 --- a/projects/bloom/resources/Sponza/chain_texture.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:d8362cfd472880daeaea37439326a4651d1338680ae69bb2513fc6b17c8de7d4 -size 490895 diff --git a/projects/bloom/resources/Sponza/lion.png b/projects/bloom/resources/Sponza/lion.png deleted file mode 100644 index c49c7f0e..00000000 --- a/projects/bloom/resources/Sponza/lion.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:9f882f746c3a9cd51a9c6eedc1189b97668721d91a3fe49232036e789912c652 -size 2088728 diff --git a/projects/bloom/resources/Sponza/spnza_bricks_a_diff.png b/projects/bloom/resources/Sponza/spnza_bricks_a_diff.png deleted file mode 100644 index cde4c7a6..00000000 --- a/projects/bloom/resources/Sponza/spnza_bricks_a_diff.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:b94219c2f5f943f3f4715c74e7d1038bf0ab3b3b3216a758eaee67f875df0851 -size 1928829 diff --git a/projects/bloom/resources/Sponza/sponza_arch_diff.png b/projects/bloom/resources/Sponza/sponza_arch_diff.png deleted file mode 100644 index bcd9bda2..00000000 --- a/projects/bloom/resources/Sponza/sponza_arch_diff.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:c0df2c8a01b2843b1c792b494f7173cdbc4f834840fc2177af3e5d690fceda57 -size 1596151 diff --git a/projects/bloom/resources/Sponza/sponza_ceiling_a_diff.png b/projects/bloom/resources/Sponza/sponza_ceiling_a_diff.png deleted file mode 100644 index 59de631f..00000000 --- a/projects/bloom/resources/Sponza/sponza_ceiling_a_diff.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:ab6c187a81aa68f4eba30119e17fce2e4882a9ec320f70c90482dbe9da82b1c6 -size 1872074 diff --git a/projects/bloom/resources/Sponza/sponza_column_a_diff.png b/projects/bloom/resources/Sponza/sponza_column_a_diff.png deleted file mode 100644 index 01a82432..00000000 --- a/projects/bloom/resources/Sponza/sponza_column_a_diff.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:2c291507e2808bb83e160ab4b020689817df273baad3713a9ad19ac15fac6826 -size 1840992 diff --git a/projects/bloom/resources/Sponza/sponza_column_b_diff.png b/projects/bloom/resources/Sponza/sponza_column_b_diff.png deleted file mode 100644 index 10a660cc..00000000 --- a/projects/bloom/resources/Sponza/sponza_column_b_diff.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:2820b0267c4289c6cedbb42721792a57ef244ec2d0935941011c2a7d3fe88a9b -size 2170433 diff --git a/projects/bloom/resources/Sponza/sponza_column_c_diff.png b/projects/bloom/resources/Sponza/sponza_column_c_diff.png deleted file mode 100644 index bc46fd97..00000000 --- a/projects/bloom/resources/Sponza/sponza_column_c_diff.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:a0bc993ff59865468ef4530798930c7dfefb07482d71db45bc2a520986b27735 -size 2066950 diff --git a/projects/bloom/resources/Sponza/sponza_curtain_blue_diff.png b/projects/bloom/resources/Sponza/sponza_curtain_blue_diff.png deleted file mode 100644 index 384c8c2c..00000000 --- a/projects/bloom/resources/Sponza/sponza_curtain_blue_diff.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:b85c6bb3cd5105f48d3812ec8e7a1068521ce69e917300d79e136e19d45422fb -size 9510905 diff --git a/projects/bloom/resources/Sponza/sponza_curtain_diff.png b/projects/bloom/resources/Sponza/sponza_curtain_diff.png deleted file mode 100644 index af842e9f..00000000 --- a/projects/bloom/resources/Sponza/sponza_curtain_diff.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:563c56bdbbee395a6ef7f0c51c8ac9223c162e517b4cdba0d4654e8de27c98d8 -size 9189263 diff --git a/projects/bloom/resources/Sponza/sponza_curtain_green_diff.png b/projects/bloom/resources/Sponza/sponza_curtain_green_diff.png deleted file mode 100644 index 6c9b6391..00000000 --- a/projects/bloom/resources/Sponza/sponza_curtain_green_diff.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:238fe1c7f481388d1c1d578c2da8d411b99e8f0030ab62060a306db333124476 -size 8785458 diff --git a/projects/bloom/resources/Sponza/sponza_details_diff.png b/projects/bloom/resources/Sponza/sponza_details_diff.png deleted file mode 100644 index 12656686..00000000 --- a/projects/bloom/resources/Sponza/sponza_details_diff.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:cb1223b3bb82f8757e7df25a6891f1239cdd7ec59990340e952fb2d6b7ea570c -size 1522643 diff --git a/projects/bloom/resources/Sponza/sponza_fabric_blue_diff.png b/projects/bloom/resources/Sponza/sponza_fabric_blue_diff.png deleted file mode 100644 index 879d16ef..00000000 --- a/projects/bloom/resources/Sponza/sponza_fabric_blue_diff.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:467d290bf5d4b2a017da140ba9e244ed8a8a9be5418a9ac9bcb4ad572ae2d7ab -size 2229440 diff --git a/projects/bloom/resources/Sponza/sponza_fabric_diff.png b/projects/bloom/resources/Sponza/sponza_fabric_diff.png deleted file mode 100644 index 3311287a..00000000 --- a/projects/bloom/resources/Sponza/sponza_fabric_diff.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:1594f59cc2848db26add47361f4e665e3d8afa147760ed915d839fea42b20287 -size 2267382 diff --git a/projects/bloom/resources/Sponza/sponza_fabric_green_diff.png b/projects/bloom/resources/Sponza/sponza_fabric_green_diff.png deleted file mode 100644 index de110f36..00000000 --- a/projects/bloom/resources/Sponza/sponza_fabric_green_diff.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:902b87faab221173bf370cea7c74cb9060b4d870ac6316b190dafded1cb12993 -size 2258220 diff --git a/projects/bloom/resources/Sponza/sponza_flagpole_diff.png b/projects/bloom/resources/Sponza/sponza_flagpole_diff.png deleted file mode 100644 index 5f6e0812..00000000 --- a/projects/bloom/resources/Sponza/sponza_flagpole_diff.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:bfffb62e770959c725d0f3db6dc7dbdd46a380ec55ef884dab94d44ca017b438 -size 1425673 diff --git a/projects/bloom/resources/Sponza/sponza_floor_a_diff.png b/projects/bloom/resources/Sponza/sponza_floor_a_diff.png deleted file mode 100644 index 788ed764..00000000 --- a/projects/bloom/resources/Sponza/sponza_floor_a_diff.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:a16f9230fa91f9f31dfca6216ce205f1ef132d44f3b012fbf6efc0fba69770ab -size 1996838 diff --git a/projects/bloom/resources/Sponza/sponza_roof_diff.png b/projects/bloom/resources/Sponza/sponza_roof_diff.png deleted file mode 100644 index c5b84261..00000000 --- a/projects/bloom/resources/Sponza/sponza_roof_diff.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:7fc412138c20da19f8173e53545e771f4652558dff624d4dc67143e40efe562b -size 2320533 diff --git a/projects/bloom/resources/Sponza/sponza_thorn_diff.png b/projects/bloom/resources/Sponza/sponza_thorn_diff.png deleted file mode 100644 index 7a914267..00000000 --- a/projects/bloom/resources/Sponza/sponza_thorn_diff.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:a73a17c883cd0d0d67cfda2dc4118400a916366c05b9a5ac465f0c8b30fd9c8e -size 635001 diff --git a/projects/bloom/resources/Sponza/vase_dif.png b/projects/bloom/resources/Sponza/vase_dif.png deleted file mode 100644 index 61236a81..00000000 --- a/projects/bloom/resources/Sponza/vase_dif.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:53d06f52bf9e59df4cf00237707cca76c4f692bda61a62b06a30d321311d6dd9 -size 1842101 diff --git a/projects/bloom/resources/Sponza/vase_hanging.png b/projects/bloom/resources/Sponza/vase_hanging.png deleted file mode 100644 index 36a3cee7..00000000 --- a/projects/bloom/resources/Sponza/vase_hanging.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:a9d10b4f27a3c9a78d5bac882fdd4b6a6987c262f48fa490670fe5e235951e31 -size 1432804 diff --git a/projects/bloom/resources/Sponza/vase_plant.png b/projects/bloom/resources/Sponza/vase_plant.png deleted file mode 100644 index 7ad95e70..00000000 --- a/projects/bloom/resources/Sponza/vase_plant.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:d2087371ff02212fb7014b6daefa191cf5676d2227193fff261a5d02f554cb8e -size 998089 diff --git a/projects/bloom/resources/Sponza/vase_round.png b/projects/bloom/resources/Sponza/vase_round.png deleted file mode 100644 index c17953ab..00000000 --- a/projects/bloom/resources/Sponza/vase_round.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:aa23d48d492d5d4ada2ddb27d1ef22952b214e6eb3b301c65f9d88442723d20a -size 1871399 diff --git a/projects/bloom/resources/shaders/comp.spv b/projects/bloom/resources/shaders/comp.spv deleted file mode 100644 index 85c7e74cfc0a89917bf6dd1a7ec449368274c1d3..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6192 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 diff --git a/projects/bloom/resources/shaders/composite.comp b/projects/bloom/resources/shaders/composite.comp deleted file mode 100644 index 190bed06..00000000 --- a/projects/bloom/resources/shaders/composite.comp +++ /dev/null @@ -1,38 +0,0 @@ -#version 450 -#extension GL_ARB_separate_shader_objects : enable - -layout(set=0, binding=0) uniform texture2D blurImage; -layout(set=0, binding=1) uniform texture2D lensImage; -layout(set=0, binding=2) uniform sampler linearSampler; -layout(set=0, binding=3, r11f_g11f_b10f) uniform image2D colorBuffer; - -layout(local_size_x = 8, local_size_y = 8, local_size_z = 1) in; - - -void main() -{ - if(any(greaterThanEqual(gl_GlobalInvocationID.xy, imageSize(colorBuffer)))){ - return; - } - - ivec2 pixel_coord = ivec2(gl_GlobalInvocationID.xy); - vec2 pixel_size = vec2(1.0f) / textureSize(sampler2D(blurImage, linearSampler), 0); - vec2 UV = pixel_coord.xy * pixel_size; - - vec4 composite_color = vec4(0.0f); - - vec3 blur_color = texture(sampler2D(blurImage, linearSampler), UV).rgb; - vec3 lens_color = texture(sampler2D(lensImage, linearSampler), UV).rgb; - vec3 main_color = imageLoad(colorBuffer, pixel_coord).rgb; - - // composite blur and lens features - float bloom_weight = 0.25f; - float lens_weight = 0.25f; - float main_weight = 1 - (bloom_weight + lens_weight); - - composite_color.rgb = blur_color * bloom_weight + - lens_color * lens_weight + - main_color * main_weight; - - imageStore(colorBuffer, pixel_coord, composite_color); -} \ No newline at end of file diff --git a/projects/bloom/resources/shaders/downsample.comp b/projects/bloom/resources/shaders/downsample.comp deleted file mode 100644 index 2ab00c7c..00000000 --- a/projects/bloom/resources/shaders/downsample.comp +++ /dev/null @@ -1,76 +0,0 @@ -#version 450 -#extension GL_ARB_separate_shader_objects : enable - -layout(set=0, binding=0) uniform texture2D inBlurImage; -layout(set=0, binding=1) uniform sampler inImageSampler; -layout(set=0, binding=2, r11f_g11f_b10f) uniform writeonly image2D outBlurImage; - -layout(local_size_x = 8, local_size_y = 8, local_size_z = 1) in; - - -void main() -{ - if(any(greaterThanEqual(gl_GlobalInvocationID.xy, imageSize(outBlurImage)))){ - return; - } - - ivec2 pixel_coord = ivec2(gl_GlobalInvocationID.xy); - vec2 pixel_size = vec2(1.0f) / imageSize(outBlurImage); - vec2 UV = pixel_coord.xy * pixel_size; - vec2 UV_offset = UV + 0.5f * pixel_size; - - vec2 color_fetches[13] = { - // center neighbourhood (RED) - vec2(-1, 1), // LT - vec2(-1, -1), // LB - vec2( 1, -1), // RB - vec2( 1, 1), // RT - - vec2(-2, 2), // LT - vec2( 0, 2), // CT - vec2( 2, 2), // RT - - vec2(0 ,-2), // LC - vec2(0 , 0), // CC - vec2(2, 0), // CR - - vec2(-2, -2), // LB - vec2(0 , -2), // CB - vec2(2 , -2) // RB - }; - - float color_weights[13] = { - // 0.5f - 1.f/8.f, - 1.f/8.f, - 1.f/8.f, - 1.f/8.f, - - // 0.125f - 1.f/32.f, - 1.f/16.f, - 1.f/32.f, - - // 0.25f - 1.f/16.f, - 1.f/8.f, - 1.f/16.f, - - // 0.125f - 1.f/32.f, - 1.f/16.f, - 1.f/32.f - }; - - vec3 sampled_color = vec3(0.0f); - - for(uint i = 0; i < 13; i++) - { - vec2 color_fetch = UV_offset + color_fetches[i] * pixel_size; - vec3 color = texture(sampler2D(inBlurImage, inImageSampler), color_fetch).rgb; - color *= color_weights[i]; - sampled_color += color; - } - - imageStore(outBlurImage, pixel_coord, vec4(sampled_color, 1.f)); -} \ No newline at end of file diff --git a/projects/bloom/resources/shaders/gammaCorrection.comp b/projects/bloom/resources/shaders/gammaCorrection.comp deleted file mode 100644 index f89ad167..00000000 --- a/projects/bloom/resources/shaders/gammaCorrection.comp +++ /dev/null @@ -1,20 +0,0 @@ -#version 440 - -layout(set=0, binding=0, r11f_g11f_b10f) uniform image2D inImage; -layout(set=0, binding=1, rgba8) uniform image2D outImage; - - -layout(local_size_x = 8, local_size_y = 8, local_size_z = 1) in; - -void main(){ - - if(any(greaterThanEqual(gl_GlobalInvocationID.xy, imageSize(inImage)))){ - return; - } - ivec2 uv = ivec2(gl_GlobalInvocationID.xy); - vec3 linearColor = imageLoad(inImage, uv).rgb; - // cheap Reinhard tone mapping - linearColor = linearColor/(linearColor + 1.0f); - vec3 gammaCorrected = pow(linearColor, vec3(1.f / 2.2f)); - imageStore(outImage, uv, vec4(gammaCorrected, 0.f)); -} \ No newline at end of file diff --git a/projects/bloom/resources/shaders/lensFlares.comp b/projects/bloom/resources/shaders/lensFlares.comp deleted file mode 100644 index ce27d885..00000000 --- a/projects/bloom/resources/shaders/lensFlares.comp +++ /dev/null @@ -1,109 +0,0 @@ -#version 450 -#extension GL_ARB_separate_shader_objects : enable - -layout(set=0, binding=0) uniform texture2D blurBuffer; -layout(set=0, binding=1) uniform sampler linearSampler; -layout(set=0, binding=2, r11f_g11f_b10f) uniform image2D lensBuffer; - -layout(local_size_x = 8, local_size_y = 8, local_size_z = 1) in; - -vec3 sampleColorChromaticAberration(vec2 _uv) -{ - vec2 toCenter = (vec2(0.5) - _uv); - - vec3 colorScales = vec3(-1, 0, 1); - float aberrationScale = 0.1; - vec3 scaleFactors = colorScales * aberrationScale; - - float r = texture(sampler2D(blurBuffer, linearSampler), _uv + toCenter * scaleFactors.r).r; - float g = texture(sampler2D(blurBuffer, linearSampler), _uv + toCenter * scaleFactors.g).g; - float b = texture(sampler2D(blurBuffer, linearSampler), _uv + toCenter * scaleFactors.b).b; - return vec3(r, g, b); -} - -// _uv assumed to be flipped UV coordinates! -vec3 ghost_vectors(vec2 _uv) -{ - vec2 ghost_vec = (vec2(0.5f) - _uv); - - const uint c_ghost_count = 64; - const float c_ghost_spacing = length(ghost_vec) / c_ghost_count; - - ghost_vec *= c_ghost_spacing; - - vec3 ret_color = vec3(0.0f); - - for (uint i = 0; i < c_ghost_count; ++i) - { - // sample scene color - vec2 s_uv = fract(_uv + ghost_vec * vec2(i)); - vec3 s = sampleColorChromaticAberration(s_uv); - - // tint/weight - float d = distance(s_uv, vec2(0.5)); - float weight = 1.0f - smoothstep(0.0f, 0.75f, d); - s *= weight; - - ret_color += s; - } - - ret_color /= c_ghost_count; - return ret_color; -} - -vec3 halo(vec2 _uv) -{ - const float c_aspect_ratio = float(imageSize(lensBuffer).x) / float(imageSize(lensBuffer).y); - const float c_radius = 0.6f; - const float c_halo_thickness = 0.1f; - - vec2 halo_vec = vec2(0.5) - _uv; - //halo_vec.x /= c_aspect_ratio; - halo_vec = normalize(halo_vec); - //halo_vec.x *= c_aspect_ratio; - - - //vec2 w_uv = (_uv - vec2(0.5, 0.0)) * vec2(c_aspect_ratio, 1.0) + vec2(0.5, 0.0); - vec2 w_uv = _uv; - float d = distance(w_uv, vec2(0.5)); // distance to center - - float distance_to_halo = abs(d - c_radius); - - float halo_weight = 0.0f; - if(abs(d - c_radius) <= c_halo_thickness) - { - float distance_to_border = c_halo_thickness - distance_to_halo; - halo_weight = distance_to_border / c_halo_thickness; - - //halo_weight = clamp((halo_weight / 0.4f), 0.0f, 1.0f); - halo_weight = pow(halo_weight, 2.0f); - - - //halo_weight = 1.0f; - } - - return sampleColorChromaticAberration(_uv + halo_vec) * halo_weight; -} - - - -void main() -{ - if(any(greaterThanEqual(gl_GlobalInvocationID.xy, imageSize(lensBuffer)))){ - return; - } - - ivec2 pixel_coord = ivec2(gl_GlobalInvocationID.xy); - vec2 pixel_size = vec2(1.0f) / imageSize(lensBuffer); - vec2 UV = pixel_coord.xy * pixel_size; - - vec2 flipped_UV = vec2(1.0f) - UV; - - vec3 color = vec3(0.0f); - - color += ghost_vectors(flipped_UV); - color += halo(UV); - color *= 0.5f; - - imageStore(lensBuffer, pixel_coord, vec4(color, 0.0f)); -} \ No newline at end of file diff --git a/projects/bloom/resources/shaders/perMeshResources.inc b/projects/bloom/resources/shaders/perMeshResources.inc deleted file mode 100644 index 95e4fb7c..00000000 --- a/projects/bloom/resources/shaders/perMeshResources.inc +++ /dev/null @@ -1,2 +0,0 @@ -layout(set=1, binding=0) uniform texture2D albedoTexture; -layout(set=1, binding=1) uniform sampler textureSampler; \ No newline at end of file diff --git a/projects/bloom/resources/shaders/shader.frag b/projects/bloom/resources/shaders/shader.frag deleted file mode 100644 index 3e95b450..00000000 --- a/projects/bloom/resources/shaders/shader.frag +++ /dev/null @@ -1,45 +0,0 @@ -#version 450 -#extension GL_ARB_separate_shader_objects : enable -#extension GL_GOOGLE_include_directive : enable - -#include "perMeshResources.inc" - -layout(location = 0) in vec3 passNormal; -layout(location = 1) in vec2 passUV; -layout(location = 2) in vec3 passPos; - -layout(location = 0) out vec3 outColor; - -layout(set=0, binding=0) uniform sunBuffer { - vec3 L; float padding; - mat4 lightMatrix; -}; -layout(set=0, binding=1) uniform texture2D shadowMap; -layout(set=0, binding=2) uniform sampler shadowMapSampler; - -float shadowTest(vec3 worldPos){ - vec4 lightPos = lightMatrix * vec4(worldPos, 1); - lightPos /= lightPos.w; - lightPos.xy = lightPos.xy * 0.5 + 0.5; - - if(any(lessThan(lightPos.xy, vec2(0))) || any(greaterThan(lightPos.xy, vec2(1)))){ - return 1; - } - - lightPos.z = clamp(lightPos.z, 0, 1); - - float shadowMapSample = texture(sampler2D(shadowMap, shadowMapSampler), lightPos.xy).r; - float bias = 0.01f; - shadowMapSample += bias; - return shadowMapSample < lightPos.z ? 0 : 1; -} - -void main() { - vec3 N = normalize(passNormal); - vec3 sunColor = vec3(10); - vec3 sun = sunColor * clamp(dot(N, L), 0, 1); - sun *= shadowTest(passPos); - vec3 ambient = vec3(0.05); - vec3 albedo = texture(sampler2D(albedoTexture, textureSampler), passUV).rgb; - outColor = albedo * (sun + ambient); -} \ No newline at end of file diff --git a/projects/bloom/resources/shaders/shader.vert b/projects/bloom/resources/shaders/shader.vert deleted file mode 100644 index 926f86af..00000000 --- a/projects/bloom/resources/shaders/shader.vert +++ /dev/null @@ -1,22 +0,0 @@ -#version 450 -#extension GL_ARB_separate_shader_objects : enable - -layout(location = 0) in vec3 inPosition; -layout(location = 1) in vec3 inNormal; -layout(location = 2) in vec2 inUV; - -layout(location = 0) out vec3 passNormal; -layout(location = 1) out vec2 passUV; -layout(location = 2) out vec3 passPos; - -layout( push_constant ) uniform constants{ - mat4 mvp; - mat4 model; -}; - -void main() { - gl_Position = mvp * vec4(inPosition, 1.0); - passNormal = mat3(model) * inNormal; // assuming no weird stuff like shearing or non-uniform scaling - passUV = inUV; - passPos = (model * vec4(inPosition, 1)).xyz; -} \ No newline at end of file diff --git a/projects/bloom/resources/shaders/shadow.frag b/projects/bloom/resources/shaders/shadow.frag deleted file mode 100644 index 848f853f..00000000 --- a/projects/bloom/resources/shaders/shadow.frag +++ /dev/null @@ -1,6 +0,0 @@ -#version 450 -#extension GL_ARB_separate_shader_objects : enable - -void main() { - -} \ No newline at end of file diff --git a/projects/bloom/resources/shaders/shadow.vert b/projects/bloom/resources/shaders/shadow.vert deleted file mode 100644 index e0f41d42..00000000 --- a/projects/bloom/resources/shaders/shadow.vert +++ /dev/null @@ -1,12 +0,0 @@ -#version 450 -#extension GL_ARB_separate_shader_objects : enable - -layout(location = 0) in vec3 inPosition; - -layout( push_constant ) uniform constants{ - mat4 mvp; -}; - -void main() { - gl_Position = mvp * vec4(inPosition, 1.0); -} \ No newline at end of file diff --git a/projects/bloom/resources/shaders/upsample.comp b/projects/bloom/resources/shaders/upsample.comp deleted file mode 100644 index 0ddeedb5..00000000 --- a/projects/bloom/resources/shaders/upsample.comp +++ /dev/null @@ -1,45 +0,0 @@ -#version 450 -#extension GL_ARB_separate_shader_objects : enable - -layout(set=0, binding=0) uniform texture2D inUpsampleImage; -layout(set=0, binding=1) uniform sampler inImageSampler; -layout(set=0, binding=2, r11f_g11f_b10f) uniform image2D outUpsampleImage; - -layout(local_size_x = 8, local_size_y = 8, local_size_z = 1) in; - -void main() -{ - if(any(greaterThanEqual(gl_GlobalInvocationID.xy, imageSize(outUpsampleImage)))){ - return; - } - - - ivec2 pixel_coord = ivec2(gl_GlobalInvocationID.xy); - vec2 pixel_size = vec2(1.0f) / imageSize(outUpsampleImage); - vec2 UV = pixel_coord.xy * pixel_size; - - const float gauss_kernel[3] = {1.f, 2.f, 1.f}; - const float gauss_weight = 16.f; - - vec3 sampled_color = vec3(0.f); - - for(int i = -1; i <= 1; i++) - { - for(int j = -1; j <= 1; j++) - { - vec2 sample_location = UV + vec2(j, i) * pixel_size; - vec3 color = texture(sampler2D(inUpsampleImage, inImageSampler), sample_location).rgb; - color *= gauss_kernel[j+1]; - color *= gauss_kernel[i+1]; - color /= gauss_weight; - - sampled_color += color; - } - } - - //vec3 prev_color = imageLoad(outUpsampleImage, pixel_coord).rgb; - //float bloomRimStrength = 0.75f; // adjust this to change strength of bloom - //sampled_color = mix(prev_color, sampled_color, bloomRimStrength); - - imageStore(outUpsampleImage, pixel_coord, vec4(sampled_color, 1.f)); -} \ No newline at end of file diff --git a/projects/bloom/src/BloomAndFlares.cpp b/projects/bloom/src/BloomAndFlares.cpp deleted file mode 100644 index 7529dcf0..00000000 --- a/projects/bloom/src/BloomAndFlares.cpp +++ /dev/null @@ -1,274 +0,0 @@ -#include "BloomAndFlares.hpp" -#include <vkcv/shader/GLSLCompiler.hpp> - -BloomAndFlares::BloomAndFlares( - vkcv::Core *p_Core, - vk::Format colorBufferFormat, - uint32_t width, - uint32_t height) : - - p_Core(p_Core), - m_ColorBufferFormat(colorBufferFormat), - m_Width(width), - m_Height(height), - m_LinearSampler(p_Core->createSampler(vkcv::SamplerFilterType::LINEAR, - vkcv::SamplerFilterType::LINEAR, - vkcv::SamplerMipmapMode::LINEAR, - vkcv::SamplerAddressMode::CLAMP_TO_EDGE)), - m_Blur(p_Core->createImage(colorBufferFormat, width, height, 1, true, true, false)), - m_LensFeatures(p_Core->createImage(colorBufferFormat, width, height, 1, false, true, false)) -{ - vkcv::shader::GLSLCompiler compiler; - - // DOWNSAMPLE - vkcv::ShaderProgram dsProg; - compiler.compile(vkcv::ShaderStage::COMPUTE, - "resources/shaders/downsample.comp", - [&](vkcv::ShaderStage shaderStage, const std::filesystem::path& path) - { - dsProg.addShader(shaderStage, path); - }); - for(uint32_t mipLevel = 0; mipLevel < m_Blur.getMipCount(); mipLevel++) - { - m_DownsampleDescSets.push_back( - p_Core->createDescriptorSet(dsProg.getReflectedDescriptors()[0])); - } - m_DownsamplePipe = p_Core->createComputePipeline( - dsProg, { p_Core->getDescriptorSet(m_DownsampleDescSets[0]).layout }); - - // UPSAMPLE - vkcv::ShaderProgram usProg; - compiler.compile(vkcv::ShaderStage::COMPUTE, - "resources/shaders/upsample.comp", - [&](vkcv::ShaderStage shaderStage, const std::filesystem::path& path) - { - usProg.addShader(shaderStage, path); - }); - for(uint32_t mipLevel = 0; mipLevel < m_Blur.getMipCount(); mipLevel++) - { - m_UpsampleDescSets.push_back( - p_Core->createDescriptorSet(usProg.getReflectedDescriptors()[0])); - } - m_UpsamplePipe = p_Core->createComputePipeline( - usProg, { p_Core->getDescriptorSet(m_UpsampleDescSets[0]).layout }); - - // LENS FEATURES - vkcv::ShaderProgram lensProg; - compiler.compile(vkcv::ShaderStage::COMPUTE, - "resources/shaders/lensFlares.comp", - [&](vkcv::ShaderStage shaderStage, const std::filesystem::path& path) - { - lensProg.addShader(shaderStage, path); - }); - m_LensFlareDescSet = p_Core->createDescriptorSet(lensProg.getReflectedDescriptors()[0]); - m_LensFlarePipe = p_Core->createComputePipeline( - lensProg, { p_Core->getDescriptorSet(m_LensFlareDescSet).layout }); - - // COMPOSITE - vkcv::ShaderProgram compProg; - compiler.compile(vkcv::ShaderStage::COMPUTE, - "resources/shaders/composite.comp", - [&](vkcv::ShaderStage shaderStage, const std::filesystem::path& path) - { - compProg.addShader(shaderStage, path); - }); - m_CompositeDescSet = p_Core->createDescriptorSet(compProg.getReflectedDescriptors()[0]); - m_CompositePipe = p_Core->createComputePipeline( - compProg, { p_Core->getDescriptorSet(m_CompositeDescSet).layout }); -} - -void BloomAndFlares::execDownsamplePipe(const vkcv::CommandStreamHandle &cmdStream, - const vkcv::ImageHandle &colorAttachment) -{ - auto dispatchCountX = static_cast<float>(m_Width) / 8.0f; - auto dispatchCountY = static_cast<float>(m_Height) / 8.0f; - // blur dispatch - uint32_t initialDispatchCount[3] = { - static_cast<uint32_t>(glm::ceil(dispatchCountX)), - static_cast<uint32_t>(glm::ceil(dispatchCountY)), - 1 - }; - - // downsample dispatch of original color attachment - p_Core->prepareImageForSampling(cmdStream, colorAttachment); - p_Core->prepareImageForStorage(cmdStream, m_Blur.getHandle()); - - vkcv::DescriptorWrites initialDownsampleWrites; - initialDownsampleWrites.sampledImageWrites = {vkcv::SampledImageDescriptorWrite(0, colorAttachment)}; - initialDownsampleWrites.samplerWrites = {vkcv::SamplerDescriptorWrite(1, m_LinearSampler)}; - initialDownsampleWrites.storageImageWrites = {vkcv::StorageImageDescriptorWrite(2, m_Blur.getHandle(), 0) }; - p_Core->writeDescriptorSet(m_DownsampleDescSets[0], initialDownsampleWrites); - - p_Core->recordComputeDispatchToCmdStream( - cmdStream, - m_DownsamplePipe, - initialDispatchCount, - {vkcv::DescriptorSetUsage(0, p_Core->getDescriptorSet(m_DownsampleDescSets[0]).vulkanHandle)}, - vkcv::PushConstants(0)); - - // downsample dispatches of blur buffer's mip maps - float mipDispatchCountX = dispatchCountX; - float mipDispatchCountY = dispatchCountY; - for(uint32_t mipLevel = 1; mipLevel < m_DownsampleDescSets.size(); mipLevel++) - { - // mip descriptor writes - vkcv::DescriptorWrites mipDescriptorWrites; - mipDescriptorWrites.sampledImageWrites = {vkcv::SampledImageDescriptorWrite(0, m_Blur.getHandle(), mipLevel - 1, true)}; - mipDescriptorWrites.samplerWrites = {vkcv::SamplerDescriptorWrite(1, m_LinearSampler)}; - mipDescriptorWrites.storageImageWrites = {vkcv::StorageImageDescriptorWrite(2, m_Blur.getHandle(), mipLevel) }; - p_Core->writeDescriptorSet(m_DownsampleDescSets[mipLevel], mipDescriptorWrites); - - // mip dispatch calculation - mipDispatchCountX /= 2.0f; - mipDispatchCountY /= 2.0f; - - uint32_t mipDispatchCount[3] = { - static_cast<uint32_t>(glm::ceil(mipDispatchCountX)), - static_cast<uint32_t>(glm::ceil(mipDispatchCountY)), - 1 - }; - - if(mipDispatchCount[0] == 0) - mipDispatchCount[0] = 1; - if(mipDispatchCount[1] == 0) - mipDispatchCount[1] = 1; - - // mip blur dispatch - p_Core->recordComputeDispatchToCmdStream( - cmdStream, - m_DownsamplePipe, - mipDispatchCount, - {vkcv::DescriptorSetUsage(0, p_Core->getDescriptorSet(m_DownsampleDescSets[mipLevel]).vulkanHandle)}, - vkcv::PushConstants(0)); - - // image barrier between mips - p_Core->recordImageMemoryBarrier(cmdStream, m_Blur.getHandle()); - } -} - -void BloomAndFlares::execUpsamplePipe(const vkcv::CommandStreamHandle &cmdStream) -{ - // upsample dispatch - p_Core->prepareImageForStorage(cmdStream, m_Blur.getHandle()); - - const uint32_t upsampleMipLevels = std::min( - static_cast<uint32_t>(m_UpsampleDescSets.size() - 1), - static_cast<uint32_t>(5) - ); - - // upsample dispatch for each mip map - for(uint32_t mipLevel = upsampleMipLevels; mipLevel > 0; mipLevel--) - { - // mip descriptor writes - vkcv::DescriptorWrites mipUpsampleWrites; - mipUpsampleWrites.sampledImageWrites = {vkcv::SampledImageDescriptorWrite(0, m_Blur.getHandle(), mipLevel, true)}; - mipUpsampleWrites.samplerWrites = {vkcv::SamplerDescriptorWrite(1, m_LinearSampler)}; - mipUpsampleWrites.storageImageWrites = {vkcv::StorageImageDescriptorWrite(2, m_Blur.getHandle(), mipLevel - 1) }; - p_Core->writeDescriptorSet(m_UpsampleDescSets[mipLevel], mipUpsampleWrites); - - auto mipDivisor = glm::pow(2.0f, static_cast<float>(mipLevel) - 1.0f); - - auto upsampleDispatchX = static_cast<float>(m_Width) / mipDivisor; - auto upsampleDispatchY = static_cast<float>(m_Height) / mipDivisor; - upsampleDispatchX /= 8.0f; - upsampleDispatchY /= 8.0f; - - const uint32_t upsampleDispatchCount[3] = { - static_cast<uint32_t>(glm::ceil(upsampleDispatchX)), - static_cast<uint32_t>(glm::ceil(upsampleDispatchY)), - 1 - }; - - p_Core->recordComputeDispatchToCmdStream( - cmdStream, - m_UpsamplePipe, - upsampleDispatchCount, - {vkcv::DescriptorSetUsage(0, p_Core->getDescriptorSet(m_UpsampleDescSets[mipLevel]).vulkanHandle)}, - vkcv::PushConstants(0) - ); - // image barrier between mips - p_Core->recordImageMemoryBarrier(cmdStream, m_Blur.getHandle()); - } -} - -void BloomAndFlares::execLensFeaturePipe(const vkcv::CommandStreamHandle &cmdStream) -{ - // lens feature generation descriptor writes - p_Core->prepareImageForSampling(cmdStream, m_Blur.getHandle()); - p_Core->prepareImageForStorage(cmdStream, m_LensFeatures.getHandle()); - - vkcv::DescriptorWrites lensFeatureWrites; - lensFeatureWrites.sampledImageWrites = {vkcv::SampledImageDescriptorWrite(0, m_Blur.getHandle(), 0)}; - lensFeatureWrites.samplerWrites = {vkcv::SamplerDescriptorWrite(1, m_LinearSampler)}; - lensFeatureWrites.storageImageWrites = {vkcv::StorageImageDescriptorWrite(2, m_LensFeatures.getHandle(), 0)}; - p_Core->writeDescriptorSet(m_LensFlareDescSet, lensFeatureWrites); - - auto dispatchCountX = static_cast<float>(m_Width) / 8.0f; - auto dispatchCountY = static_cast<float>(m_Height) / 8.0f; - // lens feature generation dispatch - uint32_t lensFeatureDispatchCount[3] = { - static_cast<uint32_t>(glm::ceil(dispatchCountX)), - static_cast<uint32_t>(glm::ceil(dispatchCountY)), - 1 - }; - p_Core->recordComputeDispatchToCmdStream( - cmdStream, - m_LensFlarePipe, - lensFeatureDispatchCount, - {vkcv::DescriptorSetUsage(0, p_Core->getDescriptorSet(m_LensFlareDescSet).vulkanHandle)}, - vkcv::PushConstants(0)); -} - -void BloomAndFlares::execCompositePipe(const vkcv::CommandStreamHandle &cmdStream, - const vkcv::ImageHandle &colorAttachment) -{ - p_Core->prepareImageForSampling(cmdStream, m_Blur.getHandle()); - p_Core->prepareImageForSampling(cmdStream, m_LensFeatures.getHandle()); - p_Core->prepareImageForStorage(cmdStream, colorAttachment); - - // bloom composite descriptor write - vkcv::DescriptorWrites compositeWrites; - compositeWrites.sampledImageWrites = {vkcv::SampledImageDescriptorWrite(0, m_Blur.getHandle()), - vkcv::SampledImageDescriptorWrite(1, m_LensFeatures.getHandle())}; - compositeWrites.samplerWrites = {vkcv::SamplerDescriptorWrite(2, m_LinearSampler)}; - compositeWrites.storageImageWrites = {vkcv::StorageImageDescriptorWrite(3, colorAttachment)}; - p_Core->writeDescriptorSet(m_CompositeDescSet, compositeWrites); - - float dispatchCountX = static_cast<float>(m_Width) / 8.0f; - float dispatchCountY = static_cast<float>(m_Height) / 8.0f; - - uint32_t compositeDispatchCount[3] = { - static_cast<uint32_t>(glm::ceil(dispatchCountX)), - static_cast<uint32_t>(glm::ceil(dispatchCountY)), - 1 - }; - - // bloom composite dispatch - p_Core->recordComputeDispatchToCmdStream( - cmdStream, - m_CompositePipe, - compositeDispatchCount, - {vkcv::DescriptorSetUsage(0, p_Core->getDescriptorSet(m_CompositeDescSet).vulkanHandle)}, - vkcv::PushConstants(0)); -} - -void BloomAndFlares::execWholePipeline(const vkcv::CommandStreamHandle &cmdStream, - const vkcv::ImageHandle &colorAttachment) -{ - execDownsamplePipe(cmdStream, colorAttachment); - execUpsamplePipe(cmdStream); - execLensFeaturePipe(cmdStream); - execCompositePipe(cmdStream, colorAttachment); -} - -void BloomAndFlares::updateImageDimensions(uint32_t width, uint32_t height) -{ - m_Width = width; - m_Height = height; - - p_Core->getContext().getDevice().waitIdle(); - m_Blur = p_Core->createImage(m_ColorBufferFormat, m_Width, m_Height, 1, true, true, false); - m_LensFeatures = p_Core->createImage(m_ColorBufferFormat, m_Width, m_Height, 1, false, true, false); -} - - diff --git a/projects/bloom/src/BloomAndFlares.hpp b/projects/bloom/src/BloomAndFlares.hpp deleted file mode 100644 index 756b1ca1..00000000 --- a/projects/bloom/src/BloomAndFlares.hpp +++ /dev/null @@ -1,47 +0,0 @@ -#pragma once -#include <vkcv/Core.hpp> -#include <glm/glm.hpp> - -class BloomAndFlares{ -public: - BloomAndFlares(vkcv::Core *p_Core, - vk::Format colorBufferFormat, - uint32_t width, - uint32_t height); - - void execWholePipeline(const vkcv::CommandStreamHandle &cmdStream, const vkcv::ImageHandle &colorAttachment); - - void updateImageDimensions(uint32_t width, uint32_t height); - -private: - vkcv::Core *p_Core; - - vk::Format m_ColorBufferFormat; - uint32_t m_Width; - uint32_t m_Height; - - vkcv::SamplerHandle m_LinearSampler; - vkcv::Image m_Blur; - vkcv::Image m_LensFeatures; - - - vkcv::PipelineHandle m_DownsamplePipe; - std::vector<vkcv::DescriptorSetHandle> m_DownsampleDescSets; // per mip desc set - - vkcv::PipelineHandle m_UpsamplePipe; - std::vector<vkcv::DescriptorSetHandle> m_UpsampleDescSets; // per mip desc set - - vkcv::PipelineHandle m_LensFlarePipe; - vkcv::DescriptorSetHandle m_LensFlareDescSet; - - vkcv::PipelineHandle m_CompositePipe; - vkcv::DescriptorSetHandle m_CompositeDescSet; - - void execDownsamplePipe(const vkcv::CommandStreamHandle &cmdStream, const vkcv::ImageHandle &colorAttachment); - void execUpsamplePipe(const vkcv::CommandStreamHandle &cmdStream); - void execLensFeaturePipe(const vkcv::CommandStreamHandle &cmdStream); - void execCompositePipe(const vkcv::CommandStreamHandle &cmdStream, const vkcv::ImageHandle &colorAttachment); -}; - - - diff --git a/projects/bloom/src/main.cpp b/projects/bloom/src/main.cpp deleted file mode 100644 index 95435a69..00000000 --- a/projects/bloom/src/main.cpp +++ /dev/null @@ -1,417 +0,0 @@ -#include <iostream> -#include <vkcv/Core.hpp> -#include <GLFW/glfw3.h> -#include <vkcv/camera/CameraManager.hpp> -#include <chrono> -#include <vkcv/asset/asset_loader.hpp> -#include <vkcv/shader/GLSLCompiler.hpp> -#include <vkcv/Logger.hpp> -#include "BloomAndFlares.hpp" -#include <glm/glm.hpp> - -int main(int argc, const char** argv) { - const char* applicationName = "Bloom"; - - uint32_t windowWidth = 1920; - uint32_t windowHeight = 1080; - - vkcv::Window window = vkcv::Window::create( - applicationName, - windowWidth, - windowHeight, - true - ); - - vkcv::camera::CameraManager cameraManager(window); - uint32_t camIndex = cameraManager.addCamera(vkcv::camera::ControllerType::PILOT); - uint32_t camIndex2 = cameraManager.addCamera(vkcv::camera::ControllerType::TRACKBALL); - - cameraManager.getCamera(camIndex).setPosition(glm::vec3(0.f, 0.f, 3.f)); - cameraManager.getCamera(camIndex).setNearFar(0.1f, 30.0f); - cameraManager.getCamera(camIndex).setYaw(180.0f); - - cameraManager.getCamera(camIndex2).setNearFar(0.1f, 30.0f); - - vkcv::Core core = vkcv::Core::create( - window, - applicationName, - VK_MAKE_VERSION(0, 0, 1), - { vk::QueueFlagBits::eTransfer,vk::QueueFlagBits::eGraphics, vk::QueueFlagBits::eCompute }, - {}, - { "VK_KHR_swapchain" } - ); - - const char* path = argc > 1 ? argv[1] : "resources/Sponza/Sponza.gltf"; - vkcv::asset::Scene scene; - int result = vkcv::asset::loadScene(path, scene); - - if (result == 1) { - std::cout << "Scene loading successful!" << std::endl; - } - else { - std::cout << "Scene loading failed: " << result << std::endl; - return 1; - } - - // build index and vertex buffers - assert(!scene.vertexGroups.empty()); - std::vector<std::vector<uint8_t>> vBuffers; - std::vector<std::vector<uint8_t>> iBuffers; - - std::vector<vkcv::VertexBufferBinding> vBufferBindings; - std::vector<std::vector<vkcv::VertexBufferBinding>> vertexBufferBindings; - std::vector<vkcv::asset::VertexAttribute> vAttributes; - - for (int i = 0; i < scene.vertexGroups.size(); i++) { - - vBuffers.push_back(scene.vertexGroups[i].vertexBuffer.data); - iBuffers.push_back(scene.vertexGroups[i].indexBuffer.data); - - auto& attributes = scene.vertexGroups[i].vertexBuffer.attributes; - - std::sort(attributes.begin(), attributes.end(), [](const vkcv::asset::VertexAttribute& x, const vkcv::asset::VertexAttribute& y) { - return static_cast<uint32_t>(x.type) < static_cast<uint32_t>(y.type); - }); - } - - std::vector<vkcv::Buffer<uint8_t>> vertexBuffers; - for (const vkcv::asset::VertexGroup& group : scene.vertexGroups) { - vertexBuffers.push_back(core.createBuffer<uint8_t>( - vkcv::BufferType::VERTEX, - group.vertexBuffer.data.size())); - vertexBuffers.back().fill(group.vertexBuffer.data); - } - - std::vector<vkcv::Buffer<uint8_t>> indexBuffers; - for (const auto& dataBuffer : iBuffers) { - indexBuffers.push_back(core.createBuffer<uint8_t>( - vkcv::BufferType::INDEX, - dataBuffer.size())); - indexBuffers.back().fill(dataBuffer); - } - - int vertexBufferIndex = 0; - for (const auto& vertexGroup : scene.vertexGroups) { - for (const auto& attribute : vertexGroup.vertexBuffer.attributes) { - vAttributes.push_back(attribute); - vBufferBindings.push_back(vkcv::VertexBufferBinding(attribute.offset, vertexBuffers[vertexBufferIndex].getVulkanHandle())); - } - vertexBufferBindings.push_back(vBufferBindings); - vBufferBindings.clear(); - vertexBufferIndex++; - } - - const vk::Format colorBufferFormat = vk::Format::eB10G11R11UfloatPack32; - const vkcv::AttachmentDescription color_attachment( - vkcv::AttachmentOperation::STORE, - vkcv::AttachmentOperation::CLEAR, - colorBufferFormat - ); - - const vk::Format depthBufferFormat = vk::Format::eD32Sfloat; - const vkcv::AttachmentDescription depth_attachment( - vkcv::AttachmentOperation::STORE, - vkcv::AttachmentOperation::CLEAR, - depthBufferFormat - ); - - vkcv::PassConfig forwardPassDefinition({ color_attachment, depth_attachment }); - vkcv::PassHandle forwardPass = core.createPass(forwardPassDefinition); - - vkcv::shader::GLSLCompiler compiler; - - vkcv::ShaderProgram forwardProgram; - compiler.compile(vkcv::ShaderStage::VERTEX, std::filesystem::path("resources/shaders/shader.vert"), - [&](vkcv::ShaderStage shaderStage, const std::filesystem::path& path) { - forwardProgram.addShader(shaderStage, path); - }); - compiler.compile(vkcv::ShaderStage::FRAGMENT, std::filesystem::path("resources/shaders/shader.frag"), - [&](vkcv::ShaderStage shaderStage, const std::filesystem::path& path) { - forwardProgram.addShader(shaderStage, path); - }); - - const std::vector<vkcv::VertexAttachment> vertexAttachments = forwardProgram.getVertexAttachments(); - - std::vector<vkcv::VertexBinding> vertexBindings; - for (size_t i = 0; i < vertexAttachments.size(); i++) { - vertexBindings.push_back(vkcv::VertexBinding(i, { vertexAttachments[i] })); - } - const vkcv::VertexLayout vertexLayout (vertexBindings); - - // shadow map - vkcv::SamplerHandle shadowSampler = core.createSampler( - vkcv::SamplerFilterType::NEAREST, - vkcv::SamplerFilterType::NEAREST, - vkcv::SamplerMipmapMode::NEAREST, - vkcv::SamplerAddressMode::CLAMP_TO_EDGE - ); - const vk::Format shadowMapFormat = vk::Format::eD16Unorm; - const uint32_t shadowMapResolution = 1024; - const vkcv::Image shadowMap = core.createImage(shadowMapFormat, shadowMapResolution, shadowMapResolution, 1); - - // light info buffer - struct LightInfo { - glm::vec3 direction; - float padding; - glm::mat4 lightMatrix; - }; - LightInfo lightInfo; - vkcv::Buffer lightBuffer = core.createBuffer<LightInfo>(vkcv::BufferType::UNIFORM, sizeof(glm::vec3)); - - vkcv::DescriptorSetHandle forwardShadingDescriptorSet = - core.createDescriptorSet({ forwardProgram.getReflectedDescriptors()[0] }); - - vkcv::DescriptorWrites forwardDescriptorWrites; - forwardDescriptorWrites.uniformBufferWrites = { vkcv::UniformBufferDescriptorWrite(0, lightBuffer.getHandle()) }; - forwardDescriptorWrites.sampledImageWrites = { vkcv::SampledImageDescriptorWrite(1, shadowMap.getHandle()) }; - forwardDescriptorWrites.samplerWrites = { vkcv::SamplerDescriptorWrite(2, shadowSampler) }; - core.writeDescriptorSet(forwardShadingDescriptorSet, forwardDescriptorWrites); - - vkcv::SamplerHandle colorSampler = core.createSampler( - vkcv::SamplerFilterType::LINEAR, - vkcv::SamplerFilterType::LINEAR, - vkcv::SamplerMipmapMode::LINEAR, - vkcv::SamplerAddressMode::REPEAT - ); - - // prepare per mesh descriptor sets - std::vector<vkcv::DescriptorSetHandle> perMeshDescriptorSets; - std::vector<vkcv::Image> sceneImages; - for (const auto& vertexGroup : scene.vertexGroups) { - perMeshDescriptorSets.push_back(core.createDescriptorSet(forwardProgram.getReflectedDescriptors()[1])); - - const auto& material = scene.materials[vertexGroup.materialIndex]; - - int baseColorIndex = material.baseColor; - if (baseColorIndex < 0) { - vkcv_log(vkcv::LogLevel::WARNING, "Material lacks base color"); - baseColorIndex = 0; - } - - vkcv::asset::Texture& sceneTexture = scene.textures[baseColorIndex]; - - sceneImages.push_back(core.createImage(vk::Format::eR8G8B8A8Srgb, sceneTexture.w, sceneTexture.h)); - sceneImages.back().fill(sceneTexture.data.data()); - - vkcv::DescriptorWrites setWrites; - setWrites.sampledImageWrites = { - vkcv::SampledImageDescriptorWrite(0, sceneImages.back().getHandle()) - }; - setWrites.samplerWrites = { - vkcv::SamplerDescriptorWrite(1, colorSampler), - }; - core.writeDescriptorSet(perMeshDescriptorSets.back(), setWrites); - } - - const vkcv::PipelineConfig forwardPipelineConfig { - forwardProgram, - windowWidth, - windowHeight, - forwardPass, - vertexLayout, - { core.getDescriptorSet(forwardShadingDescriptorSet).layout, - core.getDescriptorSet(perMeshDescriptorSets[0]).layout }, - true - }; - - vkcv::PipelineHandle forwardPipeline = core.createGraphicsPipeline(forwardPipelineConfig); - - if (!forwardPipeline) { - std::cout << "Error. Could not create graphics pipeline. Exiting." << std::endl; - return EXIT_FAILURE; - } - - vkcv::ImageHandle depthBuffer = core.createImage(depthBufferFormat, windowWidth, windowHeight).getHandle(); - vkcv::ImageHandle colorBuffer = core.createImage(colorBufferFormat, windowWidth, windowHeight, 1, false, true, true).getHandle(); - - const vkcv::ImageHandle swapchainInput = vkcv::ImageHandle::createSwapchainImageHandle(); - - vkcv::ShaderProgram shadowShader; - compiler.compile(vkcv::ShaderStage::VERTEX, "resources/shaders/shadow.vert", - [&](vkcv::ShaderStage shaderStage, const std::filesystem::path& path) { - shadowShader.addShader(shaderStage, path); - }); - compiler.compile(vkcv::ShaderStage::FRAGMENT, "resources/shaders/shadow.frag", - [&](vkcv::ShaderStage shaderStage, const std::filesystem::path& path) { - shadowShader.addShader(shaderStage, path); - }); - - const std::vector<vkcv::AttachmentDescription> shadowAttachments = { - vkcv::AttachmentDescription(vkcv::AttachmentOperation::STORE, vkcv::AttachmentOperation::CLEAR, shadowMapFormat) - }; - const vkcv::PassConfig shadowPassConfig(shadowAttachments); - const vkcv::PassHandle shadowPass = core.createPass(shadowPassConfig); - const vkcv::PipelineConfig shadowPipeConfig{ - shadowShader, - shadowMapResolution, - shadowMapResolution, - shadowPass, - vertexLayout, - {}, - false - }; - const vkcv::PipelineHandle shadowPipe = core.createGraphicsPipeline(shadowPipeConfig); - - // gamma correction compute shader - vkcv::ShaderProgram gammaCorrectionProgram; - compiler.compile(vkcv::ShaderStage::COMPUTE, "resources/shaders/gammaCorrection.comp", - [&](vkcv::ShaderStage shaderStage, const std::filesystem::path& path) { - gammaCorrectionProgram.addShader(shaderStage, path); - }); - vkcv::DescriptorSetHandle gammaCorrectionDescriptorSet = core.createDescriptorSet(gammaCorrectionProgram.getReflectedDescriptors()[0]); - vkcv::PipelineHandle gammaCorrectionPipeline = core.createComputePipeline(gammaCorrectionProgram, - { core.getDescriptorSet(gammaCorrectionDescriptorSet).layout }); - - BloomAndFlares baf(&core, colorBufferFormat, windowWidth, windowHeight); - - - // model matrices per mesh - std::vector<glm::mat4> modelMatrices; - modelMatrices.resize(scene.vertexGroups.size(), glm::mat4(1.f)); - for (const auto& mesh : scene.meshes) { - const glm::mat4 m = *reinterpret_cast<const glm::mat4*>(&mesh.modelMatrix[0]); - for (const auto& vertexGroupIndex : mesh.vertexGroups) { - modelMatrices[vertexGroupIndex] = m; - } - } - - // prepare drawcalls - std::vector<vkcv::Mesh> meshes; - for (int i = 0; i < scene.vertexGroups.size(); i++) { - vkcv::Mesh mesh( - vertexBufferBindings[i], - indexBuffers[i].getVulkanHandle(), - scene.vertexGroups[i].numIndices); - meshes.push_back(mesh); - } - - std::vector<vkcv::DrawcallInfo> drawcalls; - std::vector<vkcv::DrawcallInfo> shadowDrawcalls; - for (int i = 0; i < meshes.size(); i++) { - drawcalls.push_back(vkcv::DrawcallInfo(meshes[i], { - vkcv::DescriptorSetUsage(0, core.getDescriptorSet(forwardShadingDescriptorSet).vulkanHandle), - vkcv::DescriptorSetUsage(1, core.getDescriptorSet(perMeshDescriptorSets[i]).vulkanHandle) })); - shadowDrawcalls.push_back(vkcv::DrawcallInfo(meshes[i], {})); - } - - auto start = std::chrono::system_clock::now(); - const auto appStartTime = start; - while (window.isWindowOpen()) { - vkcv::Window::pollEvents(); - - uint32_t swapchainWidth, swapchainHeight; - if (!core.beginFrame(swapchainWidth, swapchainHeight)) { - continue; - } - - if ((swapchainWidth != windowWidth) || ((swapchainHeight != windowHeight))) { - depthBuffer = core.createImage(depthBufferFormat, swapchainWidth, swapchainHeight).getHandle(); - colorBuffer = core.createImage(colorBufferFormat, swapchainWidth, swapchainHeight, 1, false, true, true).getHandle(); - - baf.updateImageDimensions(swapchainWidth, swapchainHeight); - - windowWidth = swapchainWidth; - windowHeight = swapchainHeight; - } - - auto end = std::chrono::system_clock::now(); - auto deltatime = std::chrono::duration_cast<std::chrono::microseconds>(end - start); - - start = end; - cameraManager.update(0.000001 * static_cast<double>(deltatime.count())); - - auto duration = std::chrono::duration_cast<std::chrono::milliseconds>(end - appStartTime); - - const float sunTheta = 0.0001f * static_cast<float>(duration.count()); - lightInfo.direction = glm::normalize(glm::vec3(std::cos(sunTheta), 1, std::sin(sunTheta))); - - const float shadowProjectionSize = 20.f; - glm::mat4 projectionLight = glm::ortho( - -shadowProjectionSize, - shadowProjectionSize, - -shadowProjectionSize, - shadowProjectionSize, - -shadowProjectionSize, - shadowProjectionSize); - - glm::mat4 vulkanCorrectionMatrix(1.f); - vulkanCorrectionMatrix[2][2] = 0.5; - vulkanCorrectionMatrix[3][2] = 0.5; - projectionLight = vulkanCorrectionMatrix * projectionLight; - - const glm::mat4 viewLight = glm::lookAt(glm::vec3(0), -lightInfo.direction, glm::vec3(0, -1, 0)); - - lightInfo.lightMatrix = projectionLight * viewLight; - lightBuffer.fill({ lightInfo }); - - const glm::mat4 viewProjectionCamera = cameraManager.getActiveCamera().getMVP(); - - vkcv::PushConstants pushConstants (2 * sizeof(glm::mat4)); - vkcv::PushConstants shadowPushConstants (sizeof(glm::mat4)); - - for (const auto& m : modelMatrices) { - pushConstants.appendDrawcall(std::array<glm::mat4, 2>{ viewProjectionCamera * m, m }); - shadowPushConstants.appendDrawcall(lightInfo.lightMatrix * m); - } - - - const std::vector<vkcv::ImageHandle> renderTargets = { colorBuffer, depthBuffer }; - - const - - auto cmdStream = core.createCommandStream(vkcv::QueueType::Graphics); - - // shadow map - core.recordDrawcallsToCmdStream( - cmdStream, - shadowPass, - shadowPipe, - shadowPushConstants, - shadowDrawcalls, - { shadowMap.getHandle() }); - core.prepareImageForSampling(cmdStream, shadowMap.getHandle()); - - // main pass - core.recordDrawcallsToCmdStream( - cmdStream, - forwardPass, - forwardPipeline, - pushConstants, - drawcalls, - renderTargets); - - const uint32_t gammaCorrectionLocalGroupSize = 8; - const uint32_t gammaCorrectionDispatchCount[3] = { - static_cast<uint32_t>(glm::ceil(static_cast<float>(windowWidth) / static_cast<float>(gammaCorrectionLocalGroupSize))), - static_cast<uint32_t>(glm::ceil(static_cast<float>(windowHeight) / static_cast<float>(gammaCorrectionLocalGroupSize))), - 1 - }; - - baf.execWholePipeline(cmdStream, colorBuffer); - - core.prepareImageForStorage(cmdStream, swapchainInput); - - // gamma correction descriptor write - vkcv::DescriptorWrites gammaCorrectionDescriptorWrites; - gammaCorrectionDescriptorWrites.storageImageWrites = { - vkcv::StorageImageDescriptorWrite(0, colorBuffer), - vkcv::StorageImageDescriptorWrite(1, swapchainInput) }; - core.writeDescriptorSet(gammaCorrectionDescriptorSet, gammaCorrectionDescriptorWrites); - - // gamma correction dispatch - core.recordComputeDispatchToCmdStream( - cmdStream, - gammaCorrectionPipeline, - gammaCorrectionDispatchCount, - { vkcv::DescriptorSetUsage(0, core.getDescriptorSet(gammaCorrectionDescriptorSet).vulkanHandle) }, - vkcv::PushConstants(0)); - - // present and end - core.prepareSwapchainImageForPresent(cmdStream); - core.submitCommandStream(cmdStream); - - core.endFrame(); - } - - return 0; -} -- GitLab