Home

Awesome

vulkantoy

Vulkantoy is a small test project that can be used as a shadertoy test app for image shaders on Windows. It compiles shaders and updates image samplers on the fly. Shader inputs are common shadertoy uniform variables and four image sampler2Ds. Shadertoy-shaders with other input resources (like buffers) do not work.

The app has only been tested with Nvidia GTX 970. Debug has Vulkan validation layer enabled.

alt text alt text

Test shaders in the first screenshot:

The second screenshot shows the default appearance with default textures.

Use Without Building

(e.g. with Windows PowerShell)

git clone https://github.com/jpystynen/vulkantoy.git
vulkantoy> .\bin\vulkantoy.exe
vulkantoy> .\bin\vulkantoy_debug.exe

Modify shaders in shaders dir, and modify textures in textures dir. You must be in the root dir when you run the exe. Debug has Vulkan debug report and "VK_LAYER_LUNARG_standard_validation" enabled.

Building

The application uses Window classes for window creation and file directory watching. Does not compile on other platforms.

Dependencies

Build steps

git clone https://github.com/jpystynen/vulkantoy.git
cd external
git clone https://github.com/KhronosGroup/glslang.git
(Refer to glslang wiki if you want to build glslang. Precompiled libs are in external/lib)

Run cmake. Build with VS.

Remember to set the working directory in VS to vulkantoy root.

Shaders

Compiled spir-v files need to be present in shaders directory when the app boots. When the app is running, you can paste your mainImage-function to toy.frag shader between the following comment lines. GLSL shader is recompiled when you save the file. Some shadertoy-shaders might need additional defines for different uniform variable names.

///////////////////////////////////////////////////////////////////////////////
// SHADERTOY SHADER HERE

void mainImage(out vec4 fragColor, in vec2 fragCoord)
{
    fragColor = vec4(1.0, 0.0, 0.0, 1.0);
}

// SHADERTOY SHADER ENDS HERE
///////////////////////////////////////////////////////////////////////////////

Samplers (images)

There are four uniform sampler2Ds created from textures. At boot you need to have four png files (channel[0-3].png) in the textures directory. When the app is running you can replace the png images with any formats that stb_image supports. Searched image names are channel[0-3] and if there are new images they are updated on the fly. E.g. rename channel0.png and copy channel0.tga to textures directory.

Credits

License

MIT. See LICENSE