Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ You will notice a large swath of the `wgsl` code from the Bevy codebase here, _w
- Tips and Tools to format your `wgsl` work, so it looks more rusty (which will help you quickly get up to speed with the existing `wgsl` in the Bevy codebase).
- Scripts to pull _all_ the functions from the Bevy codebase's shader code so you can easily lookup what's available for import. (See `scripts/README.md`)
- Scripts to search the Bevy source code (opening your browser) for specific keywords. (See `scripts/README.md`)
- Continious image capture to create .gifs! (Currently only supporting a maximum framerate of 20FPS for capture.)
- Continious image capture to create .gifs! (Currently only supporting a maximum framerate of 20FPS for capture.) For the finest quality GIFs, we recommend [this guide on using ffmpeg](https://blog.pkh.me/p/21-high-quality-gif-with-ffmpeg.html).
- 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).
Expand Down
10 changes: 10 additions & 0 deletions src/system/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,14 @@ pub struct UserSession {
/// RenderTarget for when we're making a gif out of
#[serde(skip)]
pub gif_buffer: Option<Handle<Image>>,
#[serde(default = "default_gif_framerate")]
pub gif_framerate: f64,
}

fn default_gif_framerate() -> f64 {
0.05
}

// Provide a default function for window_dims
fn default_window_dims() -> (u32, u32) {
(800, 600) // Default window dimensions
Expand Down Expand Up @@ -210,6 +217,7 @@ impl Default for UserSession {
.unwrap_or_default()
.as_secs(),
gif_buffer: None,
gif_framerate: 0.05,
}
}
}
Expand All @@ -227,6 +235,7 @@ mod tests {
always_on_top: false,
last_updated: 1635900000,
gif_buffer: None,
gif_framerate: 0.05,
};

let temp_path = "./temp_config.toml";
Expand All @@ -250,6 +259,7 @@ mod tests {
always_on_top: true,
last_updated: 1635900000,
gif_buffer: None,
gif_framerate: 0.05,
};
test_config.save_to_toml(p).unwrap();
}
Expand Down
6 changes: 4 additions & 2 deletions src/system/gif_maker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use bevy::{
// use bevy::render::view::RenderLayers; // Not currently used, commented out for now
use bevy::window::{PrimaryWindow, WindowResized};

use crate::prelude::AppState;
use crate::{prelude::AppState, system::config::UserSession};

//NOTE: new strategy, take_screenshot exists on the screenshot manager so let's just use that pushing images into an ordered stack of images.
// On enter/exit we move into gif mode.
Expand All @@ -41,7 +41,9 @@ impl Plugin for GifMakerPlugin {
app.add_systems(Update, gif_capture_toggle.run_if(on_message::<KeyboardInput>));

// Limit timestep we can snap for our gif to 20 FPS
app.insert_resource(Time::<Fixed>::from_seconds(0.05));
let user_config = app.world().get_resource::<UserSession>();
let framerate = user_config.map_or(0.05, |c| c.gif_framerate);
app.insert_resource(Time::<Fixed>::from_seconds(framerate));
app.add_systems(
FixedUpdate,
(continous_capture.run_if(resource_exists_and_equals(Shooting(true))),),
Expand Down