diff --git a/CMake/imstkCopyAndCompileShaders.cmake b/CMake/imstkCopyAndCompileShaders.cmake new file mode 100644 index 0000000000000000000000000000000000000000..254bdcc02501dc9dec98fdfa7c642c79dddf3925 --- /dev/null +++ b/CMake/imstkCopyAndCompileShaders.cmake @@ -0,0 +1,49 @@ +#----------------------------------------------------------------------------- +# Compile Shaders +#----------------------------------------------------------------------------- +function(compileShaders sourceShader binaryShader) + add_custom_command( + TARGET ${PROJECT_NAME} + COMMAND glslangvalidator -V ${PROJECT_BINARY_DIR}/Shaders/VulkanShaders/${sourceShader} -o ${PROJECT_BINARY_DIR}/Shaders/VulkanShaders/${binaryShader}) +endfunction() + +function(CopyAndCompileShaders) + if( iMSTK_USE_Vulkan ) + file(COPY ${CMAKE_SOURCE_DIR}/Source/Rendering/VulkanRenderer/VulkanShaders + DESTINATION ${PROJECT_BINARY_DIR}/Shaders) + + # Mesh shaders + compileShaders(Mesh/mesh_vert.vert Mesh/mesh_vert.spv) + compileShaders(Mesh/mesh_tesc.tesc Mesh/mesh_tesc.spv) + compileShaders(Mesh/mesh_tese.tese Mesh/mesh_tese.spv) + compileShaders(Mesh/mesh_frag.frag Mesh/mesh_frag.spv) + compileShaders(Mesh/decal_vert.vert Mesh/decal_vert.spv) + compileShaders(Mesh/decal_frag.frag Mesh/decal_frag.spv) + compileShaders(Mesh/shadow_vert.vert Mesh/shadow_vert.spv) + compileShaders(Mesh/shadow_frag.frag Mesh/shadow_frag.spv) + compileShaders(Mesh/depth_frag.frag Mesh/depth_frag.spv) + + # Post processing shaders + compileShaders(PostProcessing/HDR_tonemap_frag.frag PostProcessing/HDR_tonemap_frag.spv) + compileShaders(PostProcessing/postprocess_vert.vert PostProcessing/postprocess_vert.spv) + compileShaders(PostProcessing/postprocess_frag.frag PostProcessing/postprocess_frag.spv) + compileShaders(PostProcessing/sss_frag.frag PostProcessing/sss_frag.spv) + compileShaders(PostProcessing/composite_frag.frag PostProcessing/composite_frag.spv) + compileShaders(PostProcessing/bloom_threshold_frag.frag PostProcessing/bloom_threshold_frag.spv) + compileShaders(PostProcessing/blur_horizontal_frag.frag PostProcessing/blur_horizontal_frag.spv) + compileShaders(PostProcessing/blur_vertical_frag.frag PostProcessing/blur_vertical_frag.spv) + compileShaders(PostProcessing/bloom_threshold_frag.frag PostProcessing/bloom_threshold_frag.spv) + compileShaders(PostProcessing/ao_frag.frag PostProcessing/ao_frag.spv) + compileShaders(PostProcessing/bilateral_blur_horizontal_frag.frag PostProcessing/bilateral_blur_horizontal_frag.spv) + compileShaders(PostProcessing/bilateral_blur_vertical_frag.frag PostProcessing/bilateral_blur_vertical_frag.spv) + compileShaders(PostProcessing/depth_downscale_frag.frag PostProcessing/depth_downscale_frag.spv) + + file(COPY ${PROJECT_BINARY_DIR}/Shaders/VulkanShaders + DESTINATION ${CMAKE_PROGRAM_PATH}/Shaders) + else( iMSTK_USE_Vulkan ) + file(COPY ${CMAKE_SOURCE_DIR}/Source/Rendering/VTKRenderer/VTKShaders + DESTINATION ${PROJECT_BINARY_DIR}/Shaders) + file(COPY ${CMAKE_SOURCE_DIR}/Source/Rendering/VTKRenderer/VTKShaders + DESTINATION ${CMAKE_PROGRAM_PATH}/Shaders) + endif() +endfunction() \ No newline at end of file diff --git a/Examples/Audio/CMakeLists.txt b/Examples/Audio/CMakeLists.txt index 303c6e51ebade3c538d9dc19238ca8fbc895228a..da16f9c1bbfd561530761104f4f6988766c96473 100644 --- a/Examples/Audio/CMakeLists.txt +++ b/Examples/Audio/CMakeLists.txt @@ -34,10 +34,18 @@ else() SimulationManager SFML) endif() + +#----------------------------------------------------------------------------- +# Add shaders +#----------------------------------------------------------------------------- +include(imstkCopyAndCompileShaders) +CopyAndCompileShaders() #----------------------------------------------------------------------------- # Associate external data #----------------------------------------------------------------------------- +include(imstkCopyAndCompileShaders) +CopyAndCompileShaders() list(APPEND FILE_LIST sound/,REGEX:.*) imstk_add_data(${PROJECT_NAME} ${FILE_LIST}) diff --git a/Examples/BoneDrilling/CMakeLists.txt b/Examples/BoneDrilling/CMakeLists.txt index c586bccf43dfa708abfc077351d1fcaefa6aafdd..f02bc45e841a99e24e2ea11bc3670c81e0247e54 100644 --- a/Examples/BoneDrilling/CMakeLists.txt +++ b/Examples/BoneDrilling/CMakeLists.txt @@ -36,6 +36,12 @@ if(iMSTK_USE_OMNI) SimulationManager SFML) endif() + + #----------------------------------------------------------------------------- + # Add shaders + #----------------------------------------------------------------------------- + include(imstkCopyAndCompileShaders) + CopyAndCompileShaders() #----------------------------------------------------------------------------- # Associate external data diff --git a/Examples/CMakeLists.txt b/Examples/CMakeLists.txt index bcbabd300f17836607fbce94a48f2bd9b679f220..53892158ddc9fcf0b063c659f1fedb2e70c3e4b7 100644 --- a/Examples/CMakeLists.txt +++ b/Examples/CMakeLists.txt @@ -56,8 +56,6 @@ foreach(subdir ${subDirs}) endforeach() #----------------------------------------------------------------------------- -# Shaders +# Add external data #----------------------------------------------------------------------------- -include(imstkCopyAndCompileShaders) -CopyAndCompileShaders() imstk_add_data(${PROJECT_NAME} ${FILE_LIST}) \ No newline at end of file diff --git a/Examples/CameraController/CMakeLists.txt b/Examples/CameraController/CMakeLists.txt index f68c4594f3d4eadcc73f08859b15f06c07a0186a..f5a0b1bd52cbd792e4f27d3406ddfe208f9f1e51 100644 --- a/Examples/CameraController/CMakeLists.txt +++ b/Examples/CameraController/CMakeLists.txt @@ -28,6 +28,12 @@ if(iMSTK_USE_OMNI) # Link libraries to executable #----------------------------------------------------------------------------- target_link_libraries(${PROJECT_NAME} SimulationManager) + + #----------------------------------------------------------------------------- + # Add shaders + #----------------------------------------------------------------------------- + include(imstkCopyAndCompileShaders) + CopyAndCompileShaders() #----------------------------------------------------------------------------- # Associate external data diff --git a/Examples/DeformableBody/CMakeLists.txt b/Examples/DeformableBody/CMakeLists.txt index c70123780bf7f69f7ac07d6dd3b8f3c977bfaaf6..3cca576ce0959b0ecf32f941d44584e0e117d9e0 100644 --- a/Examples/DeformableBody/CMakeLists.txt +++ b/Examples/DeformableBody/CMakeLists.txt @@ -27,6 +27,12 @@ add_executable(${PROJECT_NAME} DeformableBody.cpp) # Link libraries to executable #----------------------------------------------------------------------------- target_link_libraries(${PROJECT_NAME} SimulationManager) + +#----------------------------------------------------------------------------- +# Add shaders +#----------------------------------------------------------------------------- +include(imstkCopyAndCompileShaders) +CopyAndCompileShaders() #----------------------------------------------------------------------------- # Associate external data diff --git a/Examples/ExtractSurface/CMakeLists.txt b/Examples/ExtractSurface/CMakeLists.txt index 6678f44ccba54cff6eac4c163de94a184fd084f6..9dc0023c5d804abd07249ed94952c863994683b6 100644 --- a/Examples/ExtractSurface/CMakeLists.txt +++ b/Examples/ExtractSurface/CMakeLists.txt @@ -22,6 +22,12 @@ project(Example-ExtractSurface) # Create executable #----------------------------------------------------------------------------- add_executable(${PROJECT_NAME} ExtractSurface.cpp) + +#----------------------------------------------------------------------------- +# Add shaders +#----------------------------------------------------------------------------- +include(imstkCopyAndCompileShaders) +CopyAndCompileShaders() #----------------------------------------------------------------------------- # Link libraries to executable diff --git a/Examples/GeometryTransforms/CMakeLists.txt b/Examples/GeometryTransforms/CMakeLists.txt index ae90d695cd2822ca8f21545d6f6cc15e2899d753..56aa29c3ecfd757eb490822a30d38fd966833875 100644 --- a/Examples/GeometryTransforms/CMakeLists.txt +++ b/Examples/GeometryTransforms/CMakeLists.txt @@ -27,6 +27,12 @@ add_executable(${PROJECT_NAME} GeometryTransforms.cpp) # Link libraries to executable #----------------------------------------------------------------------------- target_link_libraries(${PROJECT_NAME} SimulationManager) + +#----------------------------------------------------------------------------- +# Add shaders +#----------------------------------------------------------------------------- +include(imstkCopyAndCompileShaders) +CopyAndCompileShaders() #----------------------------------------------------------------------------- # Associate external data diff --git a/Examples/Graph/CMakeLists.txt b/Examples/Graph/CMakeLists.txt index efdb7e83cc71633a1a545d070d21895c2adc7cfd..c171ed849af2959c4a98ff1eccebf63028aefc9e 100644 --- a/Examples/Graph/CMakeLists.txt +++ b/Examples/Graph/CMakeLists.txt @@ -27,6 +27,12 @@ add_executable(${PROJECT_NAME} Graph.cpp) # Link libraries to executable #----------------------------------------------------------------------------- target_link_libraries(${PROJECT_NAME} SimulationManager) + +#----------------------------------------------------------------------------- +# Add shaders +#----------------------------------------------------------------------------- +include(imstkCopyAndCompileShaders) +CopyAndCompileShaders() #----------------------------------------------------------------------------- # Associate external data diff --git a/Examples/LaparoscopicToolController/CMakeLists.txt b/Examples/LaparoscopicToolController/CMakeLists.txt index e56c2d52840dab87e0ede7123e626491fa8e9f76..e476884fffb42473aa12e6a59cf5f1015aeeaa4f 100644 --- a/Examples/LaparoscopicToolController/CMakeLists.txt +++ b/Examples/LaparoscopicToolController/CMakeLists.txt @@ -28,6 +28,12 @@ if(iMSTK_USE_OMNI) # Link libraries to executable #----------------------------------------------------------------------------- target_link_libraries(${PROJECT_NAME} SimulationManager) + + #----------------------------------------------------------------------------- + # Add shaders + #----------------------------------------------------------------------------- + include(imstkCopyAndCompileShaders) + CopyAndCompileShaders() #----------------------------------------------------------------------------- # Associate external data diff --git a/Examples/MeshIO/CMakeLists.txt b/Examples/MeshIO/CMakeLists.txt index 07b89a1d86abc93371a6dc19c2e16c6cce61df3c..55638e0f25221e86702573513c2d16fe5edfcf96 100644 --- a/Examples/MeshIO/CMakeLists.txt +++ b/Examples/MeshIO/CMakeLists.txt @@ -27,7 +27,13 @@ add_executable(${PROJECT_NAME} MeshIO.cpp) # Link libraries to executable #----------------------------------------------------------------------------- target_link_libraries(${PROJECT_NAME} SimulationManager) - + +#----------------------------------------------------------------------------- +# Add shaders +#----------------------------------------------------------------------------- +include(imstkCopyAndCompileShaders) +CopyAndCompileShaders() + #----------------------------------------------------------------------------- # Associate external data #----------------------------------------------------------------------------- diff --git a/Examples/MshVegaIO/CMakeLists.txt b/Examples/MshVegaIO/CMakeLists.txt index 3370956d297222cdad637fad8a0d2aa44b49e63f..50938df29a1fb4eb5bc2b5758670da598062a3da 100644 --- a/Examples/MshVegaIO/CMakeLists.txt +++ b/Examples/MshVegaIO/CMakeLists.txt @@ -28,6 +28,12 @@ add_executable(${PROJECT_NAME} MshVegaIO.cpp) #----------------------------------------------------------------------------- target_link_libraries(${PROJECT_NAME} SimulationManager) +#----------------------------------------------------------------------------- +# Add shaders +#----------------------------------------------------------------------------- +include(imstkCopyAndCompileShaders) +CopyAndCompileShaders() + #----------------------------------------------------------------------------- # Associate external data #----------------------------------------------------------------------------- diff --git a/Examples/ObjectController/CMakeLists.txt b/Examples/ObjectController/CMakeLists.txt index 766769a1a961707d087feaee94a3dd8f7a33aee9..8aa82c8757cde83e6e0578e801afff27ea357a0d 100644 --- a/Examples/ObjectController/CMakeLists.txt +++ b/Examples/ObjectController/CMakeLists.txt @@ -24,6 +24,12 @@ if(iMSTK_USE_OMNI) #----------------------------------------------------------------------------- add_executable(${PROJECT_NAME} ObjectController.cpp) + #----------------------------------------------------------------------------- + # Add shaders + #----------------------------------------------------------------------------- + include(imstkCopyAndCompileShaders) + CopyAndCompileShaders() + #----------------------------------------------------------------------------- # Link libraries to executable #----------------------------------------------------------------------------- diff --git a/Examples/PBDVolume/CMakeLists.txt b/Examples/PBDVolume/CMakeLists.txt index 916340e7778dabdfdfdc113cb849fb322a5c6dfb..91affca8fb8b0d8d075e96ba818d2bedb4c7eb4a 100644 --- a/Examples/PBDVolume/CMakeLists.txt +++ b/Examples/PBDVolume/CMakeLists.txt @@ -27,6 +27,12 @@ add_executable(${PROJECT_NAME} PBDVolumeExample.cpp) # Link libraries to executable #----------------------------------------------------------------------------- target_link_libraries(${PROJECT_NAME} SimulationManager) + +#----------------------------------------------------------------------------- +# Add shaders +#----------------------------------------------------------------------------- +include(imstkCopyAndCompileShaders) +CopyAndCompileShaders() #----------------------------------------------------------------------------- # Associate external data diff --git a/Examples/Picking/CMakeLists.txt b/Examples/Picking/CMakeLists.txt index 40cfd32a7296534af10b8608244b0bba68202b05..6dd5fad3a78bd1f4a312fc542c37e9cafe3f5431 100644 --- a/Examples/Picking/CMakeLists.txt +++ b/Examples/Picking/CMakeLists.txt @@ -29,6 +29,12 @@ if(iMSTK_USE_OMNI) # Link libraries to executable #----------------------------------------------------------------------------- target_link_libraries(${PROJECT_NAME} SimulationManager) + + #----------------------------------------------------------------------------- + # Add shaders + #----------------------------------------------------------------------------- + include(imstkCopyAndCompileShaders) + CopyAndCompileShaders() #----------------------------------------------------------------------------- # Associate external data diff --git a/Examples/Rendering/CMakeLists.txt b/Examples/Rendering/CMakeLists.txt index 194408c390a7218ccda78a5292428aa8b637835d..d4fec99a23a43fc32c8fa0b0e15751d20e043808 100644 --- a/Examples/Rendering/CMakeLists.txt +++ b/Examples/Rendering/CMakeLists.txt @@ -27,6 +27,12 @@ add_executable(${PROJECT_NAME} Rendering.cpp) # Link libraries to executable #----------------------------------------------------------------------------- target_link_libraries(${PROJECT_NAME} SimulationManager) + +#----------------------------------------------------------------------------- +# Add shaders +#----------------------------------------------------------------------------- +include(imstkCopyAndCompileShaders) +CopyAndCompileShaders() #----------------------------------------------------------------------------- # Associate external data diff --git a/Examples/Screenshot/CMakeLists.txt b/Examples/Screenshot/CMakeLists.txt index 7eefe2a49caf76acc84a24ed7c31bf7dc47217f4..d1aa9bac22fc3544b4c3ec86be29452d1eccb6f5 100644 --- a/Examples/Screenshot/CMakeLists.txt +++ b/Examples/Screenshot/CMakeLists.txt @@ -22,6 +22,12 @@ project(Example-Screenshot) # Create executable #----------------------------------------------------------------------------- add_executable(${PROJECT_NAME} Screenshot.cpp) + +#----------------------------------------------------------------------------- +# Add shaders +#----------------------------------------------------------------------------- +include(imstkCopyAndCompileShaders) +CopyAndCompileShaders() #----------------------------------------------------------------------------- # Link libraries to executable diff --git a/Examples/Viewer/CMakeLists.txt b/Examples/Viewer/CMakeLists.txt index 8a78652106a5c5e07810d9d4da1b593900f84e79..474f5bdcdf6e812c19cf96d396d1c17412db0fa4 100644 --- a/Examples/Viewer/CMakeLists.txt +++ b/Examples/Viewer/CMakeLists.txt @@ -22,6 +22,12 @@ project(Example-Viewer) # Create executable #----------------------------------------------------------------------------- add_executable(${PROJECT_NAME} Viewer.cpp) + +#----------------------------------------------------------------------------- +# Add shaders +#----------------------------------------------------------------------------- +include(imstkCopyAndCompileShaders) +CopyAndCompileShaders() #----------------------------------------------------------------------------- # Link libraries to executable diff --git a/Examples/VirtualCoupling/CMakeLists.txt b/Examples/VirtualCoupling/CMakeLists.txt index d24870ebe0023e7cf21ec0d25e9bb3b371b2db57..a8da49200f16be5dab51cfd5492d4f1b6516b1e3 100644 --- a/Examples/VirtualCoupling/CMakeLists.txt +++ b/Examples/VirtualCoupling/CMakeLists.txt @@ -23,6 +23,12 @@ if(iMSTK_USE_OMNI) # Create executable #----------------------------------------------------------------------------- add_executable(${PROJECT_NAME} VirtualCoupling.cpp) + + #----------------------------------------------------------------------------- + # Add shaders + #----------------------------------------------------------------------------- + include(imstkCopyAndCompileShaders) + CopyAndCompileShaders() #----------------------------------------------------------------------------- # Link libraries to executable diff --git a/Examples/VulkanDecals/CMakeLists.txt b/Examples/VulkanDecals/CMakeLists.txt index d1d62e8c0f2236868229fbb765f696442c97dcce..86edb9e27a2911837176d1e9aef7ab5018451739 100644 --- a/Examples/VulkanDecals/CMakeLists.txt +++ b/Examples/VulkanDecals/CMakeLists.txt @@ -27,6 +27,12 @@ add_executable(${PROJECT_NAME} VulkanDecals.cpp) # Link libraries to executable #----------------------------------------------------------------------------- target_link_libraries(${PROJECT_NAME} SimulationManager) + +#----------------------------------------------------------------------------- +# Add shaders +#----------------------------------------------------------------------------- +include(imstkCopyAndCompileShaders) +CopyAndCompileShaders() #----------------------------------------------------------------------------- # Associate external data diff --git a/Examples/continuousCollisionDetection/CMakeLists.txt b/Examples/continuousCollisionDetection/CMakeLists.txt index ec9ccc8c862d5a69163f955e4822ecd8e2ce9867..6a8b6ffbb8f6d0565ba52e8a7bc4aae885090832 100644 --- a/Examples/continuousCollisionDetection/CMakeLists.txt +++ b/Examples/continuousCollisionDetection/CMakeLists.txt @@ -27,6 +27,12 @@ add_executable(${PROJECT_NAME} continuousCollisionDetection.cpp) # Link libraries to executable #----------------------------------------------------------------------------- target_link_libraries(${PROJECT_NAME} SimulationManager) + +#----------------------------------------------------------------------------- +# Add shaders +#----------------------------------------------------------------------------- +include(imstkCopyAndCompileShaders) +CopyAndCompileShaders() #----------------------------------------------------------------------------- # Associate external data