shadercrab

Crates.ioshadercrab
lib.rsshadercrab
version0.1.2
sourcesrc
created_at2021-12-28 12:16:33.079321
updated_at2021-12-28 12:37:13.905986
descriptionA simple single buffer shadertoy emulator
homepage
repositoryhttps://github.com/Dimev/shadercrab
max_upload_size
id504162
size56,244
Dimev (Dimev)

documentation

README

Shadercrab

A simple single buffer shadertoy emulator

Installation:

With cargo (rust's package manager): cargo install shadercrab

From source (Also needs cargo): Clone this repo, and run cargo build --release to compile the program

Usage:

If installed with cargo and it's in path: shadercrab "path/to/shader"

From source: cargo run --release -- "path/to/shader"

Shadercrab takes in a single file path as an argument. This shader is then compiled and displayed to the output window. When the R key is pressed or when the file is modified, the shader is reloaded.

The shader is according to how shadertoy handles the "main" tab, which means it needs this function: mainImage(out vec4 fragColor, in vec2 fragCoord) where

  • fragColor is the output color for the pixel, in sRGB space
  • fragCoord is the pixel coordinate, (0, 0) at the bottom left, (window_width, window_height) at the top right

The following constants are also defined:

  • float iTime is the time elapsed since the shader was (re)loaded, in seconds
  • int iFrame is the number of frames that have been rendered
  • vec3 iResolution where xy is the resolution of the window, and z is the aspect ration (y / x)
  • vec4 iMouse where xy are the mouse cursor position, in pixel coords and zw the state of whether the mouse buttons are held down. The mouse position can be changed by dragging the mouse

License

Licensed under either of

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.

Commit count: 21

cargo fmt