Awesome
grimoire
What?
<a href="https://github.com/jshrake/grimoire-examples/blob/master/volume.glsl"><img src="https://thumbs.gfycat.com/CriminalEnergeticBird-size_restricted.gif" width="280" height="200" /></a> <a href="https://github.com/jshrake/grimoire-examples/blob/master/kinect2-raymarch.glsl"><img src="https://thumbs.gfycat.com/LikableJoyfulAsianelephant-size_restricted.gif" width="280" height="200" /></a> <a href="https://github.com/jshrake/grimoire/blob/master/examples/scene-0001.glsl"><img src="https://thumbs.gfycat.com/OffensiveEnragedGemsbok-size_restricted.gif" width="280" height="200" /></a>
grimoire is a cross-platform (Windows, MacOS, "Linux") live-coding tool for creating GLSL shader demos in the style of shadertoy and vertexshaderart. Users write a TOML configuration file that defines resources (image, video, audio, webcam, 3D texture, kinect data) and render passes (vertex shader, fragment shader, primitive type and count, blend state, depth state, uniform samplers). Your shaders, resources, and config file are watched for changes and are live updated at runtime. See the examples below to get started or read the SPEC.md for a detailed description of the configuration schema and runtime behavior.
grimoire is my personal prototyping tool and is in the early stages of development. You may encounter bugs and features may change without notice. Do not expect support. With that out of the way, I think you will find grimoire an easy to use, robust, and powerful tool for prototyping shader effects. Feedback is welcome!
examples: shadertoy compatibility
The following shaders demonstrate compatibility with various shadertoy features. All content is copyright by the original author and licensed under the terms specified, or by the default shadertoy license. If you do not want your work included in this list, you can contact me and I will remove it immediately.
- new, source:
cargo run -- ./examples/shadertoy-new
- debug, source:
cargo run -- ./examples/shadertoy-debug
- mouse, source:
cargo run -- ./examples/shadertoy-mouse
- keyboard, source:
cargo run -- ./examples/shadertoy-keyboard-debug
- time, source:
cargo run -- ./examples/shadertoy-time
- fps, source:
cargo run -- ./examples/shadertoy-fps
- microphone, source:
cargo run -- ./examples/shadertoy-microphone
- sound, source:
cargo run -- ./examples/shadertoy-sound
- multipass w/ feedback, source:
cargo run -- ./examples/shadertoy-deformation-feedback
- video:
cargo run -- ./examples/video
- webcam:
cargo run -- ./examples/webcam
Install
grimoire tracks the latest version of Rust 2018 stable, which as of this update is 1.34. Note that I actively develop on both Windows 10 and MacOS 10.14 Mojave, so you should have the best experience on those platforms. The project has travis.ci builders for Ubuntu 18.04, but I do not actively test or develop on this platform. If you encounter bugs, please file an issue.
You need to build and install grimoire from source using rust and install the required system dependencies:
- SDL2 for window and input handling
- GStreamer for video, webcam, audio, microphone, and kinect2 inputs
- OpenGL 3.3+, but uses a subset of OpenGL accessible from GLES 3.0
MacOS
$ curl https://sh.rustup.rs -sSf | sh
$ brew install sdl2 gstreamer gst-plugins-base gst-plugins-good gst-plugins-bad gst-plugins-ugly gst-libav
If running on MacOS 10.14 (Mojave), be sure to manually copy Info.plist to target/debug
or target/release
before running a demo that uses a webcam or microphone resource. The presence of this file allows MacOS to prompt for permission to access the camera and microphone.
If you encounter a build error similar to "Package libffi was not found in the pkg-config search path" you'll need to set your PKG_CONFIG_PATH
as described by brew:
$ export PKG_CONFIG_PATH=/usr/local/opt/libffi/lib/pkgconfig
Windows
- Download and run msys2
- Use the
x86_64-pc-windows-gnu
toolchain:rustup default stable-x86_64-pc-windows-gnu
- Install the required dependencies /w pacman
$ pacman -S mingw-w64-x86_64-pkg-config mingw-w64-x86_64-SDL2 mingw-w64-x86_64-GStreamer mingw-w64-x86_64-gst-plugins-base mingw-w64-x86_64-gst-plugins-good mingw-w64-x86_64-gst-plugins-bad mingw-w64-x86_64-gst-plugins-ugly mingw-w64-x86_64-gst-libav
- Manually copy the SDL2.dll to the top-level grimoire source directory (the one containing Cargo.toml) before running
Note that you need to ensure that your PATH
contains the mingw64/bin directory, and that your PKG_CONFIG_PATH
lists the directory containing all the .pc files. Since I installed msys2 with scoop, my .bash_profile
contains the following lines:
PATH="$PATH:/c/Users/jshrake/scoop/apps/msys2/current/mingw64/bin"
PKG_CONFIG_PATH="/c/Users/jshrake/scoop/apps/msys2/current/mingw64/lib/pkgconfig"
Breadcrumbs:
Linux
$ curl https://sh.rustup.rs -sSf | sh
$ apt-get install libsdl2-dev libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev gstreamer1.0-plugins-base gstreamer1.0-plugins-good gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly gstreamer1.0-libav
Build
Rust uses cargo to manage package dependencies and build:
$ cargo build
or with optimizations:
$ cargo build --release
Run
Display help:
cargo run -- --help
To run the default new shadertoy shader:
RUST_LOG=info cargo run -- ./examples/shadertoy-new/
grimoire will watch for saved changes to any file referenced by ./examples/shadertoy-new/grim.toml, including shaders and assets.
See the log crate documentation for more logging levels.
Playback control
F1
: Toggles play/pauseF2
: Pauses and steps back one frameF3
: Pauses and steps forward one frameF4
: Restarts playback at frame 0 (iTime = 0)ESC
: Exit the application
If you are using the keyboard resouce, be sure to avoid these keys. Additionally, you may want to avoid making use of any of the function keys, as I may use these for other features in the future. Note that while toggling play/pause and restarting playback (F1 and F4) work as expected with audio/video resources, F2 and F3 (frame stepping) do not.
Resources
fragment shaders
- Ray Marching and Signed Distance Functions
- Modeling with Signed Distance Functions
- Ray Marching Distance Fields
- The Book of Shaders
vertex shaders
Inspiration
- shadertoy
- vertexshaderart
- bonzomatic
- interactiveshaderformat
- the book of shaders
- https://shadertoyunofficial.wordpress.com/
License
Licensed under either of
- Apache License, Version 2.0, (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.