From 4054f76e47f12d24cc22b80d4f7ae354faf530e5 Mon Sep 17 00:00:00 2001 From: Vanessa Karolek <vaka1997@uni-koblenz.de> Date: Thu, 8 Jul 2021 19:07:52 +0200 Subject: [PATCH] [#92] add rtx project Currently, it is just a copy of first_scene. --- projects/CMakeLists.txt | 1 + projects/rtx/.gitignore | 1 + projects/rtx/CMakeLists.txt | 28 ++ .../Cutlery/Cutlery_chrome_BaseColor.png | 3 + .../Cutlery/Cutlery_chrome_Normal.png | 3 + .../Cutlery/Cutlery_details_BaseColor.png | 3 + .../Cutlery/Cutlery_details_Normal.png | 3 + .../Paris_LiquorBottle_01_Caps_BaseColor.png | 3 + .../Paris_LiquorBottle_01_Caps_Normal.png | 3 + ...s_LiquorBottle_01_Glass_Wine_BaseColor.png | 3 + ...aris_LiquorBottle_01_Glass_Wine_Normal.png | 3 + .../Cutlery/Plates_Ceramic_BaseColor.png | 3 + .../Cutlery/Plates_Ceramic_Normal.png | 3 + ...ils_BaseColor-Plates_Details_BaseColor.png | 3 + .../Cutlery/Plates_Details_Normal.png | 3 + .../Cutlery/ToffeeJar_Label_BaseColor.png | 3 + .../Cutlery/ToffeeJar_Label_Normal.png | 3 + .../Cutlery/TransparentGlass_BaseColor.png | 3 + .../Cutlery/TransparentGlass_Normal.png | 3 + .../rtx/resources/Cutlery/cutlerySzene.bin | 3 + .../rtx/resources/Cutlery/cutlerySzene.glb | 3 + .../rtx/resources/Cutlery/cutlerySzene.gltf | 3 + projects/rtx/resources/Sponza/Sponza.bin | 3 + projects/rtx/resources/Sponza/Sponza.gltf | 3 + projects/rtx/resources/Sponza/background.png | 3 + .../rtx/resources/Sponza/chain_texture.png | 3 + projects/rtx/resources/Sponza/lion.png | 3 + .../resources/Sponza/spnza_bricks_a_diff.png | 3 + .../rtx/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 + .../rtx/resources/Sponza/sponza_roof_diff.png | 3 + .../resources/Sponza/sponza_thorn_diff.png | 3 + projects/rtx/resources/Sponza/vase_dif.png | 3 + .../rtx/resources/Sponza/vase_hanging.png | 3 + projects/rtx/resources/Sponza/vase_plant.png | 3 + projects/rtx/resources/Sponza/vase_round.png | 3 + projects/rtx/resources/Szene/Szene.bin | 3 + projects/rtx/resources/Szene/Szene.gltf | 3 + projects/rtx/resources/Szene/boards2_vcyc.jpg | 3 + .../rtx/resources/Szene/boards2_vcyc_jpg.jpg | 3 + projects/rtx/resources/shaders/compile.bat | 3 + projects/rtx/resources/shaders/frag.spv | Bin 0 -> 920 bytes projects/rtx/resources/shaders/shader.frag | 15 + projects/rtx/resources/shaders/shader.vert | 19 ++ projects/rtx/resources/shaders/vert.spv | Bin 0 -> 1520 bytes projects/rtx/src/main.cpp | 264 ++++++++++++++++++ 58 files changed, 478 insertions(+) create mode 100644 projects/rtx/.gitignore create mode 100644 projects/rtx/CMakeLists.txt create mode 100644 projects/rtx/resources/Cutlery/Cutlery_chrome_BaseColor.png create mode 100644 projects/rtx/resources/Cutlery/Cutlery_chrome_Normal.png create mode 100644 projects/rtx/resources/Cutlery/Cutlery_details_BaseColor.png create mode 100644 projects/rtx/resources/Cutlery/Cutlery_details_Normal.png create mode 100644 projects/rtx/resources/Cutlery/Paris_LiquorBottle_01_Caps_BaseColor.png create mode 100644 projects/rtx/resources/Cutlery/Paris_LiquorBottle_01_Caps_Normal.png create mode 100644 projects/rtx/resources/Cutlery/Paris_LiquorBottle_01_Glass_Wine_BaseColor.png create mode 100644 projects/rtx/resources/Cutlery/Paris_LiquorBottle_01_Glass_Wine_Normal.png create mode 100644 projects/rtx/resources/Cutlery/Plates_Ceramic_BaseColor.png create mode 100644 projects/rtx/resources/Cutlery/Plates_Ceramic_Normal.png create mode 100644 projects/rtx/resources/Cutlery/Plates_Details_BaseColor-Plates_Details_BaseColor.png create mode 100644 projects/rtx/resources/Cutlery/Plates_Details_Normal.png create mode 100644 projects/rtx/resources/Cutlery/ToffeeJar_Label_BaseColor.png create mode 100644 projects/rtx/resources/Cutlery/ToffeeJar_Label_Normal.png create mode 100644 projects/rtx/resources/Cutlery/TransparentGlass_BaseColor.png create mode 100644 projects/rtx/resources/Cutlery/TransparentGlass_Normal.png create mode 100644 projects/rtx/resources/Cutlery/cutlerySzene.bin create mode 100644 projects/rtx/resources/Cutlery/cutlerySzene.glb create mode 100644 projects/rtx/resources/Cutlery/cutlerySzene.gltf create mode 100644 projects/rtx/resources/Sponza/Sponza.bin create mode 100644 projects/rtx/resources/Sponza/Sponza.gltf create mode 100644 projects/rtx/resources/Sponza/background.png create mode 100644 projects/rtx/resources/Sponza/chain_texture.png create mode 100644 projects/rtx/resources/Sponza/lion.png create mode 100644 projects/rtx/resources/Sponza/spnza_bricks_a_diff.png create mode 100644 projects/rtx/resources/Sponza/sponza_arch_diff.png create mode 100644 projects/rtx/resources/Sponza/sponza_ceiling_a_diff.png create mode 100644 projects/rtx/resources/Sponza/sponza_column_a_diff.png create mode 100644 projects/rtx/resources/Sponza/sponza_column_b_diff.png create mode 100644 projects/rtx/resources/Sponza/sponza_column_c_diff.png create mode 100644 projects/rtx/resources/Sponza/sponza_curtain_blue_diff.png create mode 100644 projects/rtx/resources/Sponza/sponza_curtain_diff.png create mode 100644 projects/rtx/resources/Sponza/sponza_curtain_green_diff.png create mode 100644 projects/rtx/resources/Sponza/sponza_details_diff.png create mode 100644 projects/rtx/resources/Sponza/sponza_fabric_blue_diff.png create mode 100644 projects/rtx/resources/Sponza/sponza_fabric_diff.png create mode 100644 projects/rtx/resources/Sponza/sponza_fabric_green_diff.png create mode 100644 projects/rtx/resources/Sponza/sponza_flagpole_diff.png create mode 100644 projects/rtx/resources/Sponza/sponza_floor_a_diff.png create mode 100644 projects/rtx/resources/Sponza/sponza_roof_diff.png create mode 100644 projects/rtx/resources/Sponza/sponza_thorn_diff.png create mode 100644 projects/rtx/resources/Sponza/vase_dif.png create mode 100644 projects/rtx/resources/Sponza/vase_hanging.png create mode 100644 projects/rtx/resources/Sponza/vase_plant.png create mode 100644 projects/rtx/resources/Sponza/vase_round.png create mode 100644 projects/rtx/resources/Szene/Szene.bin create mode 100644 projects/rtx/resources/Szene/Szene.gltf create mode 100644 projects/rtx/resources/Szene/boards2_vcyc.jpg create mode 100644 projects/rtx/resources/Szene/boards2_vcyc_jpg.jpg create mode 100644 projects/rtx/resources/shaders/compile.bat create mode 100644 projects/rtx/resources/shaders/frag.spv create mode 100644 projects/rtx/resources/shaders/shader.frag create mode 100644 projects/rtx/resources/shaders/shader.vert create mode 100644 projects/rtx/resources/shaders/vert.spv create mode 100644 projects/rtx/src/main.cpp diff --git a/projects/CMakeLists.txt b/projects/CMakeLists.txt index 1c6e3afe..eb16689e 100644 --- a/projects/CMakeLists.txt +++ b/projects/CMakeLists.txt @@ -3,6 +3,7 @@ add_subdirectory(bloom) add_subdirectory(first_triangle) add_subdirectory(first_mesh) +add_subdirectory(rtx) add_subdirectory(particle_simulation) add_subdirectory(first_scene) add_subdirectory(voxelization) diff --git a/projects/rtx/.gitignore b/projects/rtx/.gitignore new file mode 100644 index 00000000..b0d80266 --- /dev/null +++ b/projects/rtx/.gitignore @@ -0,0 +1 @@ +first_scene diff --git a/projects/rtx/CMakeLists.txt b/projects/rtx/CMakeLists.txt new file mode 100644 index 00000000..e3c07a5b --- /dev/null +++ b/projects/rtx/CMakeLists.txt @@ -0,0 +1,28 @@ +cmake_minimum_required(VERSION 3.16) +project(rtx) + +# 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(rtx src/main.cpp) + +# this should fix the execution path to load local files from the project (for MSVC) +if(MSVC) + set_target_properties(rtx PROPERTIES RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) + set_target_properties(rtx 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(rtx PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) +endif() + +# including headers of dependencies and the VkCV framework +target_include_directories(rtx SYSTEM BEFORE PRIVATE ${vkcv_include} ${vkcv_includes} ${vkcv_asset_loader_include} ${vkcv_camera_include}) + +# linking with libraries from all dependencies and the VkCV framework +target_link_libraries(rtx vkcv ${vkcv_libraries} vkcv_asset_loader ${vkcv_asset_loader_libraries} vkcv_camera) diff --git a/projects/rtx/resources/Cutlery/Cutlery_chrome_BaseColor.png b/projects/rtx/resources/Cutlery/Cutlery_chrome_BaseColor.png new file mode 100644 index 00000000..8258525f --- /dev/null +++ b/projects/rtx/resources/Cutlery/Cutlery_chrome_BaseColor.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0ce87f6407ee40ffa60983587aeb52333d59b4b1c01a53e11f4bb227ba1099d9 +size 109 diff --git a/projects/rtx/resources/Cutlery/Cutlery_chrome_Normal.png b/projects/rtx/resources/Cutlery/Cutlery_chrome_Normal.png new file mode 100644 index 00000000..620fe762 --- /dev/null +++ b/projects/rtx/resources/Cutlery/Cutlery_chrome_Normal.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:68a0064d457a6f7994814b07d943deda778754128935689874334300ede6161d +size 2332064 diff --git a/projects/rtx/resources/Cutlery/Cutlery_details_BaseColor.png b/projects/rtx/resources/Cutlery/Cutlery_details_BaseColor.png new file mode 100644 index 00000000..5570e88c --- /dev/null +++ b/projects/rtx/resources/Cutlery/Cutlery_details_BaseColor.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:42c2715635081eb29c4489ce631798b0e9c881460efc0aa63d0e81641a0dcfe9 +size 108 diff --git a/projects/rtx/resources/Cutlery/Cutlery_details_Normal.png b/projects/rtx/resources/Cutlery/Cutlery_details_Normal.png new file mode 100644 index 00000000..d07681f5 --- /dev/null +++ b/projects/rtx/resources/Cutlery/Cutlery_details_Normal.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:15b0133e140899c47ccf35b0f99a7e337e3110ae089f45d27faf9983f3e0a1f7 +size 770758 diff --git a/projects/rtx/resources/Cutlery/Paris_LiquorBottle_01_Caps_BaseColor.png b/projects/rtx/resources/Cutlery/Paris_LiquorBottle_01_Caps_BaseColor.png new file mode 100644 index 00000000..1845e8a7 --- /dev/null +++ b/projects/rtx/resources/Cutlery/Paris_LiquorBottle_01_Caps_BaseColor.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ea7c82c0f9e25afa401470df1fb6903f508fa138d21ad30f57a9153b0395b198 +size 521315 diff --git a/projects/rtx/resources/Cutlery/Paris_LiquorBottle_01_Caps_Normal.png b/projects/rtx/resources/Cutlery/Paris_LiquorBottle_01_Caps_Normal.png new file mode 100644 index 00000000..1c800c04 --- /dev/null +++ b/projects/rtx/resources/Cutlery/Paris_LiquorBottle_01_Caps_Normal.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:119efbbc020244ff9b7ff16ac9795a6d4b1808d1b90d81d20d2c874d0dc8a924 +size 1693468 diff --git a/projects/rtx/resources/Cutlery/Paris_LiquorBottle_01_Glass_Wine_BaseColor.png b/projects/rtx/resources/Cutlery/Paris_LiquorBottle_01_Glass_Wine_BaseColor.png new file mode 100644 index 00000000..36f46ebf --- /dev/null +++ b/projects/rtx/resources/Cutlery/Paris_LiquorBottle_01_Glass_Wine_BaseColor.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:99896468c7d47dd5391d585eecf149f420eca3bfec31923c21fa86c45fe02d0f +size 108 diff --git a/projects/rtx/resources/Cutlery/Paris_LiquorBottle_01_Glass_Wine_Normal.png b/projects/rtx/resources/Cutlery/Paris_LiquorBottle_01_Glass_Wine_Normal.png new file mode 100644 index 00000000..28c205d4 --- /dev/null +++ b/projects/rtx/resources/Cutlery/Paris_LiquorBottle_01_Glass_Wine_Normal.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b31618aa5adce4ad476bec2c03718c5ae097250e784344f2d298b8a74c3bfd46 +size 90 diff --git a/projects/rtx/resources/Cutlery/Plates_Ceramic_BaseColor.png b/projects/rtx/resources/Cutlery/Plates_Ceramic_BaseColor.png new file mode 100644 index 00000000..e0104189 --- /dev/null +++ b/projects/rtx/resources/Cutlery/Plates_Ceramic_BaseColor.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6eff6ccd12d8b39d60ae5ee91edd73d4d7838fcb5d9bc6ff0e671bdf009134e9 +size 109 diff --git a/projects/rtx/resources/Cutlery/Plates_Ceramic_Normal.png b/projects/rtx/resources/Cutlery/Plates_Ceramic_Normal.png new file mode 100644 index 00000000..fa13483d --- /dev/null +++ b/projects/rtx/resources/Cutlery/Plates_Ceramic_Normal.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:fe92c40ff4032fdaf10eeafd943657a0c6e0bfb3f38770f5654aa943a660f421 +size 59419 diff --git a/projects/rtx/resources/Cutlery/Plates_Details_BaseColor-Plates_Details_BaseColor.png b/projects/rtx/resources/Cutlery/Plates_Details_BaseColor-Plates_Details_BaseColor.png new file mode 100644 index 00000000..b91d0ac6 --- /dev/null +++ b/projects/rtx/resources/Cutlery/Plates_Details_BaseColor-Plates_Details_BaseColor.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4ca7d436a68a2a1237aee6e763b2954f01666b21f1dbd46929a322ea277483d2 +size 779227 diff --git a/projects/rtx/resources/Cutlery/Plates_Details_Normal.png b/projects/rtx/resources/Cutlery/Plates_Details_Normal.png new file mode 100644 index 00000000..6efd9679 --- /dev/null +++ b/projects/rtx/resources/Cutlery/Plates_Details_Normal.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b01fc6482054c64d7407b283731e57fce0601a8db28b6781c14fae3c6b30b0fe +size 504362 diff --git a/projects/rtx/resources/Cutlery/ToffeeJar_Label_BaseColor.png b/projects/rtx/resources/Cutlery/ToffeeJar_Label_BaseColor.png new file mode 100644 index 00000000..d0e0c4f4 --- /dev/null +++ b/projects/rtx/resources/Cutlery/ToffeeJar_Label_BaseColor.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:df138ee68c1d455652d1b9ae3dd03e93fcd2f6a0d8a1f12e3710f39143088674 +size 1593466 diff --git a/projects/rtx/resources/Cutlery/ToffeeJar_Label_Normal.png b/projects/rtx/resources/Cutlery/ToffeeJar_Label_Normal.png new file mode 100644 index 00000000..9f310653 --- /dev/null +++ b/projects/rtx/resources/Cutlery/ToffeeJar_Label_Normal.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6af5da97cbb25d79aea2dde8dd71ecbd495334fe34e99497ba17821be93fd7fd +size 2696676 diff --git a/projects/rtx/resources/Cutlery/TransparentGlass_BaseColor.png b/projects/rtx/resources/Cutlery/TransparentGlass_BaseColor.png new file mode 100644 index 00000000..4e4f0fcb --- /dev/null +++ b/projects/rtx/resources/Cutlery/TransparentGlass_BaseColor.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2796affdfdcf6bc805176d9f85505680b5ee52eeec625e9eaeea4f0ff3854883 +size 108 diff --git a/projects/rtx/resources/Cutlery/TransparentGlass_Normal.png b/projects/rtx/resources/Cutlery/TransparentGlass_Normal.png new file mode 100644 index 00000000..28c205d4 --- /dev/null +++ b/projects/rtx/resources/Cutlery/TransparentGlass_Normal.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b31618aa5adce4ad476bec2c03718c5ae097250e784344f2d298b8a74c3bfd46 +size 90 diff --git a/projects/rtx/resources/Cutlery/cutlerySzene.bin b/projects/rtx/resources/Cutlery/cutlerySzene.bin new file mode 100644 index 00000000..ab9a0aa4 --- /dev/null +++ b/projects/rtx/resources/Cutlery/cutlerySzene.bin @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f545b986e0a1ac5bff5d49693a52042aa37878425818f72c69c243da20d1f99d +size 183324 diff --git a/projects/rtx/resources/Cutlery/cutlerySzene.glb b/projects/rtx/resources/Cutlery/cutlerySzene.glb new file mode 100644 index 00000000..b0c5f345 --- /dev/null +++ b/projects/rtx/resources/Cutlery/cutlerySzene.glb @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:fb1bad604192ca36222c0ca485ba87b846ecbd11ee8254327e04e3c993b00116 +size 11150396 diff --git a/projects/rtx/resources/Cutlery/cutlerySzene.gltf b/projects/rtx/resources/Cutlery/cutlerySzene.gltf new file mode 100644 index 00000000..53e339cd --- /dev/null +++ b/projects/rtx/resources/Cutlery/cutlerySzene.gltf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c77cd60e2327daca1a01044e45f2c38655f7b781bd07985fc0135328a8a96b57 +size 34312 diff --git a/projects/rtx/resources/Sponza/Sponza.bin b/projects/rtx/resources/Sponza/Sponza.bin new file mode 100644 index 00000000..cfedd26c --- /dev/null +++ b/projects/rtx/resources/Sponza/Sponza.bin @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4b809f7a17687dc99e6f41ca1ea32c06eded8779bf34d16f1f565d750b0ffd68 +size 6347696 diff --git a/projects/rtx/resources/Sponza/Sponza.gltf b/projects/rtx/resources/Sponza/Sponza.gltf new file mode 100644 index 00000000..172ea07e --- /dev/null +++ b/projects/rtx/resources/Sponza/Sponza.gltf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5cc0ecad5c4694088ff820e663619c370421afc1323ac487406e8e9b4735d787 +size 713962 diff --git a/projects/rtx/resources/Sponza/background.png b/projects/rtx/resources/Sponza/background.png new file mode 100644 index 00000000..b64def12 --- /dev/null +++ b/projects/rtx/resources/Sponza/background.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f5b5f900ff8ed83a31750ec8e428b5b91273794ddcbfc4e4b8a6a7e781f8c686 +size 1417666 diff --git a/projects/rtx/resources/Sponza/chain_texture.png b/projects/rtx/resources/Sponza/chain_texture.png new file mode 100644 index 00000000..c1e1768c --- /dev/null +++ b/projects/rtx/resources/Sponza/chain_texture.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d8362cfd472880daeaea37439326a4651d1338680ae69bb2513fc6b17c8de7d4 +size 490895 diff --git a/projects/rtx/resources/Sponza/lion.png b/projects/rtx/resources/Sponza/lion.png new file mode 100644 index 00000000..c49c7f0e --- /dev/null +++ b/projects/rtx/resources/Sponza/lion.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9f882f746c3a9cd51a9c6eedc1189b97668721d91a3fe49232036e789912c652 +size 2088728 diff --git a/projects/rtx/resources/Sponza/spnza_bricks_a_diff.png b/projects/rtx/resources/Sponza/spnza_bricks_a_diff.png new file mode 100644 index 00000000..cde4c7a6 --- /dev/null +++ b/projects/rtx/resources/Sponza/spnza_bricks_a_diff.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b94219c2f5f943f3f4715c74e7d1038bf0ab3b3b3216a758eaee67f875df0851 +size 1928829 diff --git a/projects/rtx/resources/Sponza/sponza_arch_diff.png b/projects/rtx/resources/Sponza/sponza_arch_diff.png new file mode 100644 index 00000000..bcd9bda2 --- /dev/null +++ b/projects/rtx/resources/Sponza/sponza_arch_diff.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c0df2c8a01b2843b1c792b494f7173cdbc4f834840fc2177af3e5d690fceda57 +size 1596151 diff --git a/projects/rtx/resources/Sponza/sponza_ceiling_a_diff.png b/projects/rtx/resources/Sponza/sponza_ceiling_a_diff.png new file mode 100644 index 00000000..59de631f --- /dev/null +++ b/projects/rtx/resources/Sponza/sponza_ceiling_a_diff.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ab6c187a81aa68f4eba30119e17fce2e4882a9ec320f70c90482dbe9da82b1c6 +size 1872074 diff --git a/projects/rtx/resources/Sponza/sponza_column_a_diff.png b/projects/rtx/resources/Sponza/sponza_column_a_diff.png new file mode 100644 index 00000000..01a82432 --- /dev/null +++ b/projects/rtx/resources/Sponza/sponza_column_a_diff.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2c291507e2808bb83e160ab4b020689817df273baad3713a9ad19ac15fac6826 +size 1840992 diff --git a/projects/rtx/resources/Sponza/sponza_column_b_diff.png b/projects/rtx/resources/Sponza/sponza_column_b_diff.png new file mode 100644 index 00000000..10a660cc --- /dev/null +++ b/projects/rtx/resources/Sponza/sponza_column_b_diff.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2820b0267c4289c6cedbb42721792a57ef244ec2d0935941011c2a7d3fe88a9b +size 2170433 diff --git a/projects/rtx/resources/Sponza/sponza_column_c_diff.png b/projects/rtx/resources/Sponza/sponza_column_c_diff.png new file mode 100644 index 00000000..bc46fd97 --- /dev/null +++ b/projects/rtx/resources/Sponza/sponza_column_c_diff.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a0bc993ff59865468ef4530798930c7dfefb07482d71db45bc2a520986b27735 +size 2066950 diff --git a/projects/rtx/resources/Sponza/sponza_curtain_blue_diff.png b/projects/rtx/resources/Sponza/sponza_curtain_blue_diff.png new file mode 100644 index 00000000..384c8c2c --- /dev/null +++ b/projects/rtx/resources/Sponza/sponza_curtain_blue_diff.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b85c6bb3cd5105f48d3812ec8e7a1068521ce69e917300d79e136e19d45422fb +size 9510905 diff --git a/projects/rtx/resources/Sponza/sponza_curtain_diff.png b/projects/rtx/resources/Sponza/sponza_curtain_diff.png new file mode 100644 index 00000000..af842e9f --- /dev/null +++ b/projects/rtx/resources/Sponza/sponza_curtain_diff.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:563c56bdbbee395a6ef7f0c51c8ac9223c162e517b4cdba0d4654e8de27c98d8 +size 9189263 diff --git a/projects/rtx/resources/Sponza/sponza_curtain_green_diff.png b/projects/rtx/resources/Sponza/sponza_curtain_green_diff.png new file mode 100644 index 00000000..6c9b6391 --- /dev/null +++ b/projects/rtx/resources/Sponza/sponza_curtain_green_diff.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:238fe1c7f481388d1c1d578c2da8d411b99e8f0030ab62060a306db333124476 +size 8785458 diff --git a/projects/rtx/resources/Sponza/sponza_details_diff.png b/projects/rtx/resources/Sponza/sponza_details_diff.png new file mode 100644 index 00000000..12656686 --- /dev/null +++ b/projects/rtx/resources/Sponza/sponza_details_diff.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:cb1223b3bb82f8757e7df25a6891f1239cdd7ec59990340e952fb2d6b7ea570c +size 1522643 diff --git a/projects/rtx/resources/Sponza/sponza_fabric_blue_diff.png b/projects/rtx/resources/Sponza/sponza_fabric_blue_diff.png new file mode 100644 index 00000000..879d16ef --- /dev/null +++ b/projects/rtx/resources/Sponza/sponza_fabric_blue_diff.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:467d290bf5d4b2a017da140ba9e244ed8a8a9be5418a9ac9bcb4ad572ae2d7ab +size 2229440 diff --git a/projects/rtx/resources/Sponza/sponza_fabric_diff.png b/projects/rtx/resources/Sponza/sponza_fabric_diff.png new file mode 100644 index 00000000..3311287a --- /dev/null +++ b/projects/rtx/resources/Sponza/sponza_fabric_diff.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1594f59cc2848db26add47361f4e665e3d8afa147760ed915d839fea42b20287 +size 2267382 diff --git a/projects/rtx/resources/Sponza/sponza_fabric_green_diff.png b/projects/rtx/resources/Sponza/sponza_fabric_green_diff.png new file mode 100644 index 00000000..de110f36 --- /dev/null +++ b/projects/rtx/resources/Sponza/sponza_fabric_green_diff.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:902b87faab221173bf370cea7c74cb9060b4d870ac6316b190dafded1cb12993 +size 2258220 diff --git a/projects/rtx/resources/Sponza/sponza_flagpole_diff.png b/projects/rtx/resources/Sponza/sponza_flagpole_diff.png new file mode 100644 index 00000000..5f6e0812 --- /dev/null +++ b/projects/rtx/resources/Sponza/sponza_flagpole_diff.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:bfffb62e770959c725d0f3db6dc7dbdd46a380ec55ef884dab94d44ca017b438 +size 1425673 diff --git a/projects/rtx/resources/Sponza/sponza_floor_a_diff.png b/projects/rtx/resources/Sponza/sponza_floor_a_diff.png new file mode 100644 index 00000000..788ed764 --- /dev/null +++ b/projects/rtx/resources/Sponza/sponza_floor_a_diff.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a16f9230fa91f9f31dfca6216ce205f1ef132d44f3b012fbf6efc0fba69770ab +size 1996838 diff --git a/projects/rtx/resources/Sponza/sponza_roof_diff.png b/projects/rtx/resources/Sponza/sponza_roof_diff.png new file mode 100644 index 00000000..c5b84261 --- /dev/null +++ b/projects/rtx/resources/Sponza/sponza_roof_diff.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7fc412138c20da19f8173e53545e771f4652558dff624d4dc67143e40efe562b +size 2320533 diff --git a/projects/rtx/resources/Sponza/sponza_thorn_diff.png b/projects/rtx/resources/Sponza/sponza_thorn_diff.png new file mode 100644 index 00000000..7a914267 --- /dev/null +++ b/projects/rtx/resources/Sponza/sponza_thorn_diff.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a73a17c883cd0d0d67cfda2dc4118400a916366c05b9a5ac465f0c8b30fd9c8e +size 635001 diff --git a/projects/rtx/resources/Sponza/vase_dif.png b/projects/rtx/resources/Sponza/vase_dif.png new file mode 100644 index 00000000..61236a81 --- /dev/null +++ b/projects/rtx/resources/Sponza/vase_dif.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:53d06f52bf9e59df4cf00237707cca76c4f692bda61a62b06a30d321311d6dd9 +size 1842101 diff --git a/projects/rtx/resources/Sponza/vase_hanging.png b/projects/rtx/resources/Sponza/vase_hanging.png new file mode 100644 index 00000000..36a3cee7 --- /dev/null +++ b/projects/rtx/resources/Sponza/vase_hanging.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a9d10b4f27a3c9a78d5bac882fdd4b6a6987c262f48fa490670fe5e235951e31 +size 1432804 diff --git a/projects/rtx/resources/Sponza/vase_plant.png b/projects/rtx/resources/Sponza/vase_plant.png new file mode 100644 index 00000000..7ad95e70 --- /dev/null +++ b/projects/rtx/resources/Sponza/vase_plant.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d2087371ff02212fb7014b6daefa191cf5676d2227193fff261a5d02f554cb8e +size 998089 diff --git a/projects/rtx/resources/Sponza/vase_round.png b/projects/rtx/resources/Sponza/vase_round.png new file mode 100644 index 00000000..c17953ab --- /dev/null +++ b/projects/rtx/resources/Sponza/vase_round.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:aa23d48d492d5d4ada2ddb27d1ef22952b214e6eb3b301c65f9d88442723d20a +size 1871399 diff --git a/projects/rtx/resources/Szene/Szene.bin b/projects/rtx/resources/Szene/Szene.bin new file mode 100644 index 00000000..c87d2763 --- /dev/null +++ b/projects/rtx/resources/Szene/Szene.bin @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ee4742718f720d589a2a03f5d879f8c50ba9057718d191a43b046eaa9071080d +size 70328 diff --git a/projects/rtx/resources/Szene/Szene.gltf b/projects/rtx/resources/Szene/Szene.gltf new file mode 100644 index 00000000..e5a32b29 --- /dev/null +++ b/projects/rtx/resources/Szene/Szene.gltf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:75ba834118792ebbacf528a1690c7d04df4b4c8122b9f99a9aa9a9d075d2c86a +size 7421 diff --git a/projects/rtx/resources/Szene/boards2_vcyc.jpg b/projects/rtx/resources/Szene/boards2_vcyc.jpg new file mode 100644 index 00000000..2636039e --- /dev/null +++ b/projects/rtx/resources/Szene/boards2_vcyc.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:cca33a6e58ddd1b37a6e6853a9aa0e7b15ca678937119194752393dd2a0a0564 +size 1192476 diff --git a/projects/rtx/resources/Szene/boards2_vcyc_jpg.jpg b/projects/rtx/resources/Szene/boards2_vcyc_jpg.jpg new file mode 100644 index 00000000..2636039e --- /dev/null +++ b/projects/rtx/resources/Szene/boards2_vcyc_jpg.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:cca33a6e58ddd1b37a6e6853a9aa0e7b15ca678937119194752393dd2a0a0564 +size 1192476 diff --git a/projects/rtx/resources/shaders/compile.bat b/projects/rtx/resources/shaders/compile.bat new file mode 100644 index 00000000..b4521235 --- /dev/null +++ b/projects/rtx/resources/shaders/compile.bat @@ -0,0 +1,3 @@ +%VULKAN_SDK%\Bin32\glslc.exe shader.vert -o vert.spv +%VULKAN_SDK%\Bin32\glslc.exe shader.frag -o frag.spv +pause \ No newline at end of file diff --git a/projects/rtx/resources/shaders/frag.spv b/projects/rtx/resources/shaders/frag.spv new file mode 100644 index 0000000000000000000000000000000000000000..087e4e22fb2fcec27d99b3ff2aa1a705fe755796 GIT binary patch literal 920 zcmZQ(Qf6mhU}WH8;AN0yfB-=TCI&_Z1_o{hHZbk(6YQf`T#}+^Vrl?V!N<T1qQG+e z3>*wB3=CkLo0ypglHg=uU=U+qV31*8U=Uzn2FtNCFfcGPFf%YQFfbfq1gYm_aQBIK z404JuPAy0*N-Rl@FV09zNiB-cPs&P7E-417;R2~~_xE@Aag9$dD2OjEsmw`@&&kY7 zjZeueN=+`wEK3Ec<3LiEnU|bXnu4r=m4OB92AKO;8CV%WZp<$&an8@lF9Nw4B*w$Q zz>u3-oDq^*QBqoz%D~FN#vs7Jz)%9=2Pfth<fIlcFo4Vh`L7_cxHvQn#AgNj6~y<; zFUn2KVPJ4)U;*192Qr)i!UvhJgvM7y;)Co$mIv`c@}Rf?nFq2HWFCwU3SST(WP~sS z6F6)Y!J*6mW{WW}Gq5o*FeorEFo-j-Fo5C!#0SNm0s{*J2RKd`z~a_WJ}6v3@{$ak z3|tHhVErKbKz6_|j1Mw{8!8A=3o--52l*2uEXBaYzz4RUg@GR=z`y|JgVcfeApe1c zr5TtRgcumW_JQ0f0<{;ERzP-$GJsMj0|Q7Lq!+{og$2kRAoUVZ^`LYJQZEfv5ArWa zJ%|qqE0B6K23By`fYgHQ2Kn^|0}}%)0|SFC0}I#<ybKHsAU}ZkAomM`(=h`>7y~QV zox%(Z3?MZiagZ92yTqYsKAeG-0puP@1_lO@I*_<O0|z*ar5G3(K;j?_vK!<ckRR<B Sn89fUB>$Izk->t2kpTei7*62; literal 0 HcmV?d00001 diff --git a/projects/rtx/resources/shaders/shader.frag b/projects/rtx/resources/shaders/shader.frag new file mode 100644 index 00000000..b5494bea --- /dev/null +++ b/projects/rtx/resources/shaders/shader.frag @@ -0,0 +1,15 @@ +#version 450 +#extension GL_ARB_separate_shader_objects : enable + +layout(location = 0) in vec3 passNormal; +layout(location = 1) in vec2 passUV; + +layout(location = 0) out vec3 outColor; + +layout(set=0, binding=0) uniform texture2D meshTexture; +layout(set=0, binding=1) uniform sampler textureSampler; + +void main() { + outColor = texture(sampler2D(meshTexture, textureSampler), passUV).rgb; + //outColor = passNormal * 0.5 + 0.5; +} \ No newline at end of file diff --git a/projects/rtx/resources/shaders/shader.vert b/projects/rtx/resources/shaders/shader.vert new file mode 100644 index 00000000..76855152 --- /dev/null +++ b/projects/rtx/resources/shaders/shader.vert @@ -0,0 +1,19 @@ +#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( push_constant ) uniform constants{ + mat4 mvp; +}; + +void main() { + gl_Position = mvp * vec4(inPosition, 1.0); + passNormal = inNormal; + passUV = inUV; +} \ No newline at end of file diff --git a/projects/rtx/resources/shaders/vert.spv b/projects/rtx/resources/shaders/vert.spv new file mode 100644 index 0000000000000000000000000000000000000000..374c023e14b351eb43cbcda5951cbb8b3d6f96a1 GIT binary patch literal 1520 zcmZQ(Qf6mhU}WH8;APNdfB-=TCI&_Z1_o{hHZbk(6YQf`T#}+^Vrl?V!N<T1qQG+e z4BTKg3j+f~ZenI0h{Makz#z%Mz@Wmwz@W;&z@W*%z@W{*z`)GF%)rFJz;K9>fq{jA zlfm65-Z982zBsiYu_&=5HNH3_F(tJqK0hfdHMyi1q=pNm#@*lF-N!XPxu77vxTG>C zH9jXZFEu_TvnVyWB(p3Pq>ckgU1nZ#PH76V0#*hV24wfKGO&SNot_gPkXjU$T2zu+ z0dhARR2;+x$>kSkmSpDVF|aYPgVlq=1T3DJR}!3Al?qY^lLPrHJty8dC$qpMv$!NN zFF6&i4-{G;xzd~*xEw13GXp4`KxVKqurdfTFfb(N=Ye#Byw1SJzycNn$>)|8Fo4tx zgE$Nf3?TKO@XgE%fH@H?1`6+j#NuMV{G!~%9Edtl_-E$9L_lIJ;P?Qk3k`$tL2;9r z2jVd>crdVn{R*-Q60-;~kpDqqAR49)<ZqA|$d52F5E~>03UhY`X0Ul6bsk85Vr77s z3-UL}E@cpbCdSUdz#zcDzyLA>qz+_;I|B<iZOK8^gZLnSBlAIi2Ju1e1j&QaA2J{0 zUl1Q;o-hLwI87>oQzrwMEylpiz{bG9puoVuAkM(T0CES25Au&F0}BHOR1V|>Z783U z0hEgv7-Se&7`PZ1!1_UAa?msdGXo?C!U_y53_RdG0m^3#4AxLSC{2LE4`dG?)E<yO zK=y$6{2)si7#JiNSioTeG8g17IR<8MdI5zO$ZR171_qG*pl}134dR2+4@e9oF9MYZ zsR#K{9O`C}-5_}hsDD7>ApIadD9yp#0tydluv;4JLFyHuegU}$#0SME$SjzC5FZpz zATgMEpm+kA2eMxsYCkAWK>9VH=7GdP>Op)^Jc9It<h7vggUN&Vpm+tDXU4z^jz>_q zfSd@@^Miqj0hHz(8CV%Weivn6U;u>&C_HVUVJXJIzyJ~l@j>pEf|g@}44@JN6t@fv zATf}cFfmyMh#1ITm>4K+fz*Ng62QO?PCxPt5d9$aAbC*OO=MsN%Yo7v$Zn7tko!Pk zsl>nlE+0VdvtwXp0P#WUU~W@`maQN;P`HBlAURNY=s?R`kQ^w?K>WW9j0_eGj0^z8 C!Fam> literal 0 HcmV?d00001 diff --git a/projects/rtx/src/main.cpp b/projects/rtx/src/main.cpp new file mode 100644 index 00000000..3f95d318 --- /dev/null +++ b/projects/rtx/src/main.cpp @@ -0,0 +1,264 @@ +#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/Logger.hpp> + +glm::mat4 arrayTo4x4Matrix(std::array<float,16> array){ + glm::mat4 matrix; + for (int i = 0; i < 4; i++){ + for (int j = 0; j < 4; j++){ + matrix[i][j] = array[j * 4 + i]; + } + } + return matrix; +} + +int main(int argc, const char** argv) { + const char* applicationName = "First Scene (RTX ON)"; + + uint32_t windowWidth = 800; + uint32_t windowHeight = 600; + + vkcv::Window window = vkcv::Window::create( + applicationName, + windowWidth, + windowHeight, + true + ); + + vkcv::camera::CameraManager cameraManager(window); + uint32_t camIndex0 = cameraManager.addCamera(vkcv::camera::ControllerType::PILOT); + uint32_t camIndex1 = cameraManager.addCamera(vkcv::camera::ControllerType::TRACKBALL); + + cameraManager.getCamera(camIndex0).setPosition(glm::vec3(0, 0, -3)); + cameraManager.getCamera(camIndex0).setNearFar(0.1f, 30.0f); + + cameraManager.getCamera(camIndex1).setNearFar(0.1f, 30.0f); + + vkcv::Core core = vkcv::Core::create( + window, + applicationName, + VK_MAKE_VERSION(0, 0, 1), + { vk::QueueFlagBits::eGraphics ,vk::QueueFlagBits::eCompute , vk::QueueFlagBits::eTransfer }, + {}, + { "VK_KHR_swapchain" } + ); + + vkcv::asset::Scene scene; + + const char* path = argc > 1 ? argv[1] : "resources/Sponza/Sponza.gltf"; + int result = vkcv::asset::loadScene(path, scene); + + if (result == 1) { + std::cout << "Mesh loading successful!" << std::endl; + } + else { + std::cout << "Mesh loading failed: " << result << std::endl; + return 1; + } + + 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 vkcv::AttachmentDescription present_color_attachment( + vkcv::AttachmentOperation::STORE, + vkcv::AttachmentOperation::CLEAR, + core.getSwapchain().getFormat() + ); + + const vkcv::AttachmentDescription depth_attachment( + vkcv::AttachmentOperation::STORE, + vkcv::AttachmentOperation::CLEAR, + vk::Format::eD32Sfloat + ); + + vkcv::PassConfig scenePassDefinition({ present_color_attachment, depth_attachment }); + vkcv::PassHandle scenePass = core.createPass(scenePassDefinition); + + if (!scenePass) { + std::cout << "Error. Could not create renderpass. Exiting." << std::endl; + return EXIT_FAILURE; + } + + vkcv::ShaderProgram sceneShaderProgram{}; + sceneShaderProgram.addShader(vkcv::ShaderStage::VERTEX, std::filesystem::path("resources/shaders/vert.spv")); + sceneShaderProgram.addShader(vkcv::ShaderStage::FRAGMENT, std::filesystem::path("resources/shaders/frag.spv")); + + const std::vector<vkcv::VertexAttachment> vertexAttachments = sceneShaderProgram.getVertexAttachments(); + std::vector<vkcv::VertexBinding> bindings; + for (size_t i = 0; i < vertexAttachments.size(); i++) { + bindings.push_back(vkcv::VertexBinding(i, { vertexAttachments[i] })); + } + + const vkcv::VertexLayout sceneLayout(bindings); + + uint32_t setID = 0; + + std::vector<vkcv::DescriptorBinding> descriptorBindings = { sceneShaderProgram.getReflectedDescriptors()[setID] }; + + vkcv::SamplerHandle sampler = core.createSampler( + vkcv::SamplerFilterType::LINEAR, + vkcv::SamplerFilterType::LINEAR, + vkcv::SamplerMipmapMode::LINEAR, + vkcv::SamplerAddressMode::REPEAT + ); + + std::vector<vkcv::Image> sceneImages; + std::vector<vkcv::DescriptorSetHandle> descriptorSets; + for (const auto& vertexGroup : scene.vertexGroups) { + descriptorSets.push_back(core.createDescriptorSet(descriptorBindings)); + + 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, sampler) }; + core.writeDescriptorSet(descriptorSets.back(), setWrites); + } + + const vkcv::PipelineConfig scenePipelineDefsinition{ + sceneShaderProgram, + UINT32_MAX, + UINT32_MAX, + scenePass, + {sceneLayout}, + { core.getDescriptorSet(descriptorSets[0]).layout }, + true }; + vkcv::PipelineHandle scenePipeline = core.createGraphicsPipeline(scenePipelineDefsinition); + + if (!scenePipeline) { + std::cout << "Error. Could not create graphics pipeline. Exiting." << std::endl; + return EXIT_FAILURE; + } + + vkcv::ImageHandle depthBuffer = core.createImage(vk::Format::eD32Sfloat, windowWidth, windowHeight).getHandle(); + + const vkcv::ImageHandle swapchainInput = vkcv::ImageHandle::createSwapchainImageHandle(); + + std::vector<vkcv::DrawcallInfo> drawcalls; + for(int i = 0; i < scene.vertexGroups.size(); i++){ + vkcv::Mesh renderMesh(vertexBufferBindings[i], indexBuffers[i].getVulkanHandle(), scene.vertexGroups[i].numIndices); + + vkcv::DescriptorSetUsage descriptorUsage(0, core.getDescriptorSet(descriptorSets[i]).vulkanHandle); + + drawcalls.push_back(vkcv::DrawcallInfo(renderMesh, {descriptorUsage},1)); + } + + std::vector<glm::mat4> modelMatrices; + modelMatrices.resize(scene.vertexGroups.size(), glm::mat4(1.f)); + for (const auto &mesh : scene.meshes) { + const glm::mat4 m = arrayTo4x4Matrix(mesh.modelMatrix); + for (const auto &vertexGroupIndex : mesh.vertexGroups) { + modelMatrices[vertexGroupIndex] = m; + } + } + std::vector<glm::mat4> mvp; + + auto start = std::chrono::system_clock::now(); + while (window.isWindowOpen()) { + vkcv::Window::pollEvents(); + + if(window.getHeight() == 0 || window.getWidth() == 0) + continue; + + uint32_t swapchainWidth, swapchainHeight; + if (!core.beginFrame(swapchainWidth, swapchainHeight)) { + continue; + } + + if ((swapchainWidth != windowWidth) || ((swapchainHeight != windowHeight))) { + depthBuffer = core.createImage(vk::Format::eD32Sfloat, swapchainWidth, swapchainHeight).getHandle(); + + 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())); + glm::mat4 vp = cameraManager.getActiveCamera().getMVP(); + + mvp.clear(); + for (const auto& m : modelMatrices) { + mvp.push_back(vp * m); + } + + vkcv::PushConstantData pushConstantData((void*)mvp.data(), sizeof(glm::mat4)); + + const std::vector<vkcv::ImageHandle> renderTargets = { swapchainInput, depthBuffer }; + auto cmdStream = core.createCommandStream(vkcv::QueueType::Graphics); + + core.recordDrawcallsToCmdStream( + cmdStream, + scenePass, + scenePipeline, + pushConstantData, + drawcalls, + renderTargets); + core.prepareSwapchainImageForPresent(cmdStream); + core.submitCommandStream(cmdStream); + core.endFrame(); + } + + return 0; +} -- GitLab