https://github.com/codybloemhard/frag
Fragment shaders in Rust.
https://github.com/codybloemhard/frag
boilerplate fragment-shader opengl raymarching shaders
Last synced: 2 months ago
JSON representation
Fragment shaders in Rust.
- Host: GitHub
- URL: https://github.com/codybloemhard/frag
- Owner: codybloemhard
- License: gpl-3.0
- Created: 2021-03-08T18:51:49.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2024-05-24T00:36:41.000Z (about 2 years ago)
- Last Synced: 2026-03-27T22:40:51.976Z (3 months ago)
- Topics: boilerplate, fragment-shader, opengl, raymarching, shaders
- Language: Rust
- Homepage:
- Size: 53.7 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Frag
Fragment shaders in Rust.
Let's you skip the boilerplate and just write a fragment shader.
Useful when for example, writing a raymarching shader.
## Features
* Compose shader of multiple part or files
* Live coding: updates when a file is updated
* Keyboard controls for time
* Resolution independent: separate resolutions for rendering and displaying. Can be used to stretch, pixelate or anti alias
* MP4 rendering with FFMPEG
* Save current frame as PNG image
## Controls
* Space: Pause/Resume time and rendering
* Left(hold): go back in time
* Right(hold): go forward in time
* Down: set time to 0
* PageDown: jump backward in time with 5 seconds
* PageUp: jump forward in time with 5 seconds
## Todo
* Post process fragment shader accessable
## Examples
### Example live coding, with pixel art like style
```rust
use frag::*;
let streamer = shader::ShaderStreamer::new()
.with_file("lib.glsl")
.with_file("shader.glsl");
FragConf::new()
.with_window_width(1600)
.with_window_height(900)
.with_canvas_width(320)
.with_canvas_height(180)
.with_pixelate(true)
.with_streamer(streamer)
.run_live().expect("Could not run.");
```
### Example rendering to video
```rust
use frag::*;
let streamer = shader::ShaderStreamer::new()
.with_file("lib.glsl")
.with_file("shader.glsl");
FragConf::new()
.with_window_width(1600)
.with_window_height(900)
.with_streamer(streamer)
.into_ffmpeg_renderer()
.with_framerate(30)
.with_crf(20)
.with_preset(Preset::Slow)
.with_tune(Tune::Animation)
.with_length(600)
.with_output("render.mp4")
.render().expect("Could not render.");
```
## License
```
Copyright (C) 2024 Cody Bloemhard
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
```