feat: Added shader loading and swapping as well as beginnings of out of the box noise generation and support for multiple render passes

This commit is contained in:
lisk77 2024-12-17 01:36:34 +01:00
parent 4ada207b3b
commit 2736d97d03
23 changed files with 1479 additions and 692 deletions

View file

@ -6,4 +6,5 @@ edition = "2021"
[dependencies]
comet_log = { path = "../comet_log" }
num-traits = "0.2.19"
chrono = "0.4.0"
chrono = "0.4.0"
rand = "0.9.0-beta.1"

View file

@ -11,4 +11,5 @@ pub mod vector;
pub mod matrix;
pub mod quaternion;
pub mod bezier;
pub mod easings;
pub mod easings;
mod noise;

View file

@ -0,0 +1,39 @@
use rand::Rng;
/// The WhiteNoise struct works a factory for generating white noise, given the size of the texture.
pub struct WhiteNoise {
size: (usize, usize)
}
impl WhiteNoise {
pub fn new(width: usize, height: usize) -> Self {
Self {
size: (width, height)
}
}
pub fn set_width(&mut self, width: usize) {
self.size.0 = width;
}
pub fn set_height(&mut self, height: usize) {
self.size.1 = height;
}
pub fn set_size(&mut self, width: usize, height: usize) {
self.size = (width, height);
}
/// Generates white noise as a `Vec<f32>`. Size of the vector is `width * height`.
pub fn generate(&self) -> Vec<f32> {
let mut rng = rand::rng();
let mut noise = Vec::with_capacity(self.size.0 * self.size.1);
for _ in 0..self.size.0 * self.size.1 {
noise.push(rng.random_range(0.0..1.0));
}
noise
}
}