CONTRIBUTING.md (2969, 2023-12-22)
Cargo.lock (136449, 2023-12-22)
Cargo.toml (1556, 2023-12-22)
LICENSE.md (1047, 2023-12-22)
all_wgsl.wgsl (108294, 2023-12-22)
assets/ (0, 2023-12-22)
assets/Gallery/ (0, 2023-12-22)
assets/Gallery/cosmic/ (0, 2023-12-22)
assets/Gallery/cosmic/screenshot.png (199335, 2023-12-22)
assets/Gallery/cyber-anim-arrowX/ (0, 2023-12-22)
assets/Gallery/cyber-anim-arrowX/cyber-anim-arrowX.png (16790, 2023-12-22)
assets/Gallery/fbmCloud/ (0, 2023-12-22)
assets/Gallery/fbmCloud/fmb_cloud.wgsl (3364, 2023-12-22)
assets/Gallery/fbmCloud/screenshot.png (540516, 2023-12-22)
assets/Gallery/flame/ (0, 2023-12-22)
assets/Gallery/flame/screenshot.png (58125, 2023-12-22)
assets/Gallery/kishimisu-palette/ (0, 2023-12-22)
assets/Gallery/kishimisu-palette/screenshot.png (4141, 2023-12-22)
assets/Gallery/light-spirals/ (0, 2023-12-22)
assets/Gallery/light-spirals/screenshot.png (502209, 2023-12-22)
assets/Gallery/lines/ (0, 2023-12-22)
assets/Gallery/lines/dotted_line.wgsl (931, 2023-12-22)
assets/Gallery/lines/screenshot.png (72869, 2023-12-22)
assets/Gallery/perlin-waves/ (0, 2023-12-22)
assets/Gallery/perlin-waves/perlin-waves.wgsl (3712, 2023-12-22)
... ...
# shadplay
![ferris-adam.png](https://github.com/alphastrata/shadplay/blob/master/readme_assets/ferris-adam.png)
artwork by Maz with SD
[![Bevy tracking](https://github.com/alphastrata/shadplay/blob/master/https://img.shields.io/badge/Bevy%20tracking-main-lightblue)](https://github.com/alphastrata/shadplay/blob/master/https://github.com/bevyengine/bevy/blob/main/docs/plugins_guidelines.md#main-branch-tracking)
## Our [bevy-shader-cheatsheet](https://github.com/alphastrata/shadplay/blob/master/bevy-shaders-cheatsheet.md#Contents)
Shadplay is an app designed to help you learn `wgsl` with minimal friction, specifically for those wanting to learn `wgsl` to write shaders for Bevy.
The idea is to give one the minimal amount of bevy boilerplate etc possible to get started writing `wgsl` asap, and provide a library of examples showing how some things are done, can be done etc.
A secondary goal is to flesh out a relatively comprehensive 'port' of existing cool shader work from places like shadertoy etc -- because there's a few 'gotchas' around the differences in `glsl` and `wgsl` syntax, their respective builtins.
A tertiary goal is to surface the builtins/existing library code that Bevy's codebase provides.
______________________________________________________________________
### Why?
> I have found, and continue to find the shader-universe impenetrable, however: I'd rather attempt to write up and document the content I _wish_ I'd been able to find in my first google search, than complain.
______________________________________________________________________
## Features
- A large collection of example shaders illustrating creative and educational uses. `assets/shaders/yourshadergoeshere.wgsl` specifically focusing on `wgsl`.
- Live preview of shader code on Bevy mesh geometry.
- Textures, see `assets/shaders/howto-texture.wgsl`.
- Drag and drop `.png` or `.jpg` files onto the window to use as said textures.
- Mouse coords over a `uniform`, see `assets/shaders/howto-mouse.wgsl`.
- Colour picker with system copy so that you get an immediate `vecf3(r, g, b)` immediately available for quick pasta action.
- Drag and drop (valid `wgsl`) shaders onto the app.
- Scripts to format your `wgsl` work, so it looks more rusty.
- Scripts to pull _all_ the functions from the bevy codebase's shader code so you can easily lookup what's available for import.
- Scripts to search the bevy sourcecode (opening your browser) for specific keywords.
- Automatic recompilation and update of shaders upon saving changes in your editor.
- Quick iteration and experimentation with `wgsl` shader code.
- Transparent background, with always-on-top (so you can have it on top of your editor, most OSes should be supported).
- Screenshot the shader you're working on with
SPACEBAR, this will also version the shader (at `assets/shaders/myshader.wgsl`) for you i.e:
```shell
screenshots
└──| 01-10-23
└──| 09-23-29
├──| screenshot.png // Your screenshot
└──| screenshot.wgsl// The shader at `assets/shaders/myshader.wgsl`
```
### Keybindings:
The app has some simple hotkeys:
| Hotkey | Action |
| ------------------- | --------------------------------------------------------------------------------- |
|
q | Quit |
|
s | Change Shape in 3D |
|
tab | Toggles the colour picker (should be supported on most systems...) |
|
t | Switch to 2D/ShaderToy Mode |
|
h | Switch to 3D |
|
l | Window-Level |
|
d | Toggle Decorations (not all OSes) |
|
t | Toggle Transparency (returning to fully transparent is not supported) |
|
r | Toggle Rotating shape (3d only) |
|
spacebar | Takes a screenshot && versions the current `.wgsl` |
|
0 | Select the `texture` at index 0 |
|
1 | Select the `texture` at index 1 (assuming you drag-n-dropped a tex onto shadplay) |
|
2 | Select the `texture` at index 2 |
|
3 | Select the `texture` at index 3 |
|
4 | Select the `texture` at index 4 |
|
5 | Select the `texture` at index 5 |
|
6 | Select the `texture` at index 6 |
|
7 | Select the `texture` at index 7 |
|
8 | Select the `texture` at index 8 |
|
9 | Select the `texture` at index 9 |
|
? | Opens the Help UI |
______________________________________________________________________
### To run shadplay, you'll need the following:
- Rust (stable) - Make sure you have Rust installed on your system. You can find installation instructions at [https://www.rust-lang.org/tools/install](https://github.com/alphastrata/shadplay/blob/master/https://www.rust-lang.org/tools/install).
_We assume you can follow their instructions to clear that hurdle_
then:
### Installation
```shell
$ git clone https://github.com/alphastrata/shadplay.git
$ cd shadplay
$ cargo run --release
```
- Then edit the `myshader.wgsl`, or `myshader_2d.wgsl`(if in 2d/shadertoy-mode) file in real time. (
h, and
t to move between 2d/3d).
______________________________________________________________________
## Contributing:
See the [guide](https://github.com/alphastrata/shadplay/blob/master/./CONTRIBUTING.md)
______________________________________________________________________
## TODO:
- \[\] More shader examples (the entirety of shadertoy ported!)
- \[\] drag n drop obj/stl/gltf opening?
- \[\] left/right arrows to swap between shaders from the assets' dir
______________________________________________________________________
## Resources:
- [Fantastic implementations of some sdf composed shapes](https://github.com/alphastrata/shadplay/blob/master/https://gist.github.com/munrocket/f247155fc22ecb8edf974d905c677de1)
- [GM Shaders](https://github.com/alphastrata/shadplay/blob/master/https://mini.gmshaders.com)
- [glsl sandbox](https://github.com/alphastrata/shadplay/blob/master/https://glslsandbox.com/)
- [Shadertoy](https://github.com/alphastrata/shadplay/blob/master/https://www.shadertoy.com/)
- [pcf swap by DGriffin91](https://github.com/alphastrata/shadplay/blob/master/https://github.com/DGriffin91/bevy_mod_standard_material/tree/pcf)
- [GLSL2WGSL converter](https://github.com/alphastrata/shadplay/blob/master/https://eliotbo.github.io/glsl2wgsl/), it's a mixed bag..
- [bevy_shadertoy_wgsl](https://github.com/alphastrata/shadplay/blob/master/https://github.com/eliotbo/bevy_shadertoy_wgsl)
______________________________________________________________________
# Gallery:
- Any shaders in the `assets/shaders` _not_ by the repo's owner contain links to the original work, and obviously their original glsl code is, still theirs.
- Some of those can be seen below
______________________________________________________________________
# FAQ:
Q: I grabbed a shader from the examples, but it's not working!
A: It could be that the shader was contributed some time ago and was, likely made with a bevy version \< 0.12.x so it's likely a formatting thing -- if the naga (the thing which parses and compiles the .wgsl code) error doesn't tell you how to solve the issue please make a bug report and we'll try to get it updated!
Q: What version of bevy are you targeting?
A: `{version = "*"}`
______________________________________________________________________
# LICENSE:
This repository is licensed MIT, with the exception of code within the `assets/shaders/shadertoy-ports` directory, see those individual files' and the links to the original `glsl` code to ascertain their licensing requirements.