Vulkan SDF Renderer + Hot Reloader
Render an SDF like ShaderToy using Vulkan and hot reload based on frag shader changes. That way you can use your favourite editor / LSP and also utilise git.
Supports macOS, Linux, and Windows with native file watcher implementations for each platform.
https://vulkan.lunarg.com/sdk/home
Then follow the steps to do sudo ./install_vulkan.py in SDK System Paths section
VULKAN_SDK $HOME/VulkanSDK/1.4.328.1/macOS
- Install vcpkg (if not already installed):
git clone https://github.com/Microsoft/vcpkg.git cd vcpkg .\bootstrap-vcpkg.bat
- Install dependencies using vcpkg (includes Vulkan):
vcpkg install vulkan:x64-windows glfw3:x64-windows glslang:x64-windows spdlog:x64-windows glm:x64-windows gtest:x64-windows vcpkg integrate install
Note: vcpkg provides Vulkan headers and loader, eliminating the need for a separate Vulkan SDK installation.
cmake -B build .
cmake --build build
./build/vsdf {filepath}.fragcmake -B build -DCMAKE_TOOLCHAIN_FILE="C:/path/to/vcpkg/scripts/buildsystems/vcpkg.cmake" .
cmake --build build --config Release
.\build\Release\vsdf.exe {filepath}.fragHeadless / CI-friendly single-frame run (hide the window and exit after N frames):
./build/vsdf --toy shaders/testtoyshader.frag --frames 1 --headless./build/vsdf --toy path/to/shader.frag./build/vsdf --toy shaders/testtoyshader.fragNote: That if you use --toy we will prepend a template in
shaders/toytemplate.frag which sets up the push constants
like iTime and we will also follow this logic.
if (useToyTemplate) {
Client = glslang::EShClientOpenGL;
ClientVersion = glslang::EShTargetOpenGL_450;
} else {
Client = glslang::EShClientVulkan;
ClientVersion = glslang::EShTargetVulkan_1_0;
}If you don't want any template prepended or you have issues
loading that way, I recommend copying shaders/vulktemplate.frag
and adjusting it to your liking
- See
shaders/vulktemplate.fragto see how push constants are passed in
./build/vsdf path/to/shader.frag--toyPrepend the ShaderToy-compatible template--frames <N>Render N frames then exit (helps CI)--headlessHide the GLFW window (pair withxvfb-runin CI)--log-level <trace|debug|info|warn|error|critical|off>Set spdlog verbosity (default: info)
cmake -B build -DBUILD_TESTS=ON -DDEBUG=ON
cmake --build build
./build/tests/vsdf_tests
./build/tests/filewatcher/filewatcher_testscmake -B build -DBUILD_TESTS=ON -DCMAKE_BUILD_TYPE=Debug -DCMAKE_TOOLCHAIN_FILE="C:/path/to/vcpkg/scripts/buildsystems/vcpkg.cmake" .
cmake --build build --config Debug
.\build\tests\vsdf_tests\Debug\vsdf_tests.exe
.\build\tests\filewatcher\Debug\filewatcher_tests.exenix develop- https://shadertoy.com
- https://iquilezles.org/
- https://www.youtube.com/playlist?list=PL0JVLUVCkk-l7CWCn3-cdftR0oajugYvd (zeux)
- https://github.com/SaschaWillems/Vulkan
(I should try follow this but haven't gotten through it all yet) https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines
