Giter Site home page Giter Site logo

cmaughan / vklive Goto Github PK

View Code? Open in Web Editor NEW
15.0 3.0 3.0 35 MB

A 'simple' live coding environment, currently for Vulkan.

License: Other

CMake 1.92% Batchfile 0.14% C 0.42% C++ 89.32% GLSL 8.05% Shell 0.15%
live-coding shaders vulkan linux macos windows zep

vklive's Introduction

VkLive - A Vulkan Live Coding Editor

Builds GitHub license

This is a work in progress Vulkan/Shader editing project. It runs on Windows and has recently been fixed to run on Mac. Linux now builds but hasn't been tested yet! I've been building live editing tools for years, but they always got too big and I never got to the point of shipping anything. This project pulls in the best/working bits of the visual tools I've built and ships it ;) I've paid attention to managing the basics, and making things work well. I'd love to know what you think.

Currently, you can edit a simple description of your scene in terms of passes and geometry, then you can edit the shader files in your project folder. The main selling point is the easy UI, and great error feedback when editing shaders. Mostly the code is c-like, with structs and functions. It should be relatively easy to follow. The ImGui bits are ported to Vulkan hpp, which might be useful to some; it is certainly more manageable this way.

Audio input is now supported, and the audio data is converted to a frequency spectrum and uploaded as a texture containing right/left stereo spectrum and right/left audio. See the example template to play with it.

If you like live coding, shaders, shadertoy, or are learning how to use Vulkan to render, then this might be a fun tool for you to play with. If you make a nice project, please send it along, or add a screenshot to the screenshot thread! Built for fun, and to update my GPU graphics knowledge.

Video Overview

VkLive Overview

Audio Input

An audio spectrum analysis; best seen live! This is from a ShaderToy example, provided as a template in the file menu: VkLive Audio

Features

  • CTRL+ENTER to evaluate the project/shader you are viewing.
  • Can edit/save the files in modal VIM or Notepad style mode (CTRL+2 or CTRL+1).
  • Scene description for passes and geometry, rendertargets and textures.
  • Fragment, Vertex and Geometry Shaders have been tested so far.
  • Can declare rendertargets, write to them, and sample them in later passes.
  • Can declare textures and read them in shaders
  • A special texture name 'AudioAnalysis' represents the audio input data.
  • Load/Save projects in different folders
  • All API objects are debug-labelled, including the ImGui ones, making it easy to diagnose errors in tools like NVIDIA Nsight, and find your way around.
  • Default project has background and foreground geometry and time input. Template examples show off features.

TODO

  • More error checking of device creation problems.
  • More flexible UBO. You can't change the UBO yet (eventually you will get an automatically built UBO based on your spec)
  • Ray tracing support.
  • Low DPI/Mac DPI. You may not have a good experience on a low DPI setup, and on Mac there are tweaks required too.

Build

Don't forget to pull the submodules (vcpkg for all the libraries I use, Zep for the editor). On Mac I build it with CLion. On Windows, I usually load the solution into Visual Studio after the config step. You will likely need to install the latest Vulkan SDK on your platform (and at time of writing, you definately need the latest)

git submodule update --init
prebuild.bat OR ./prebuild.sh
config.bat OR ./config.sh
build.bat OR 'cmake --build .' in the build folder

Design

So how does it work? Firstly, all text editing is handled by Zep. It does the heavy lifting of showing tabs, editing text, flashing when you evaluate, syntax coloring, error popups, etc. The windows are created by SDL, and the UI is drawn by ImGui. The rendering engine is designed as a simple collection of C-like functions and structs. There is a thread in the main application which can spot changes to the code, rebuild the vulkan pipeline and send the new state into an update queue if it works. If it doesn't, the previous state is maintained until it is fixed. The Vulkan validation layers catch all problems so far, which helps keep the app stable while the user tweaks things. The scenegraph is a simple language parsed by MPC, and controls the render passes. Shaders are now partially reflected, so that bindings can be dynamically built. I'll write more here when I get time ;)

Built On

Built on the Zep editor, the project I built that started this journey several years ago: https://github.com/Rezonality/Zep

Vulkan - The project currently uses Vulkan for all rendering. I may do Metal/DX12 at some point for fun.

VCPKG - Microsoft's freaking awesome cross platform manager with an unfortunate 'not sounding cross platform at all' name. The following packages are used currently: Freetype - Better font rendering assimp - Asset import for loading models clipp - Commandline parser for command line arguments fmt - String formatting library imgui - ImGui API reproc++ - Process launch library for loading shader compiler binary SDL2 - SDL UI library for creating windows, etc. tomlplusplus - Toml file format parser for reading config files unofficial-concurrentqueue - Concurrent lock/free queue for thread interactions tinyfiledialogs - File dialogs that look OS specific and more standard unofficial-nativefiledialog - File dialogs that look OS specific and more standard mpc - The parser used in the scene graph file kissfft - For spectrum analysis of audio

vklive's People

Contributors

cmaughan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

vklive's Issues

Build fails on Linux: undefined reference to `__atomic_load_16'

[100%] Linking CXX executable Rezonality
/usr/bin/ld: libvklive.a(vulkan_scene.cpp.o): in function `vulkan::vulkan_scene_render(vulkan::VulkanContext&, vulkan::RenderContext&, Scene&)':
vulkan_scene.cpp:(.text+0xb6ee): undefined reference to `__atomic_load_16'
/usr/bin/ld: libvklive.a(audio_analysis.cpp.o): in function `Audio::audio_analysis_calculate_spectrum_bands(Audio::AudioAnalysis&, Audio::AudioAnalysisData&)':
audio_analysis.cpp:(.text+0x4ed): undefined reference to `__atomic_load_16'
/usr/bin/ld: audio_analysis.cpp:(.text+0x51d): undefined reference to `__atomic_store_16'
collect2: error: ld returned 1 exit status
gmake[2]: *** [CMakeFiles/Rezonality.dir/build.make:264: Rezonality] Error 1
gmake[1]: *** [CMakeFiles/Makefile2:129: CMakeFiles/Rezonality.dir/all] Error 2
gmake: *** [Makefile:136: all] Error 2

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.