Lenia: remove texture sampler, reduce gpu usage by ~45%
This commit is contained in:
parent
13b30711ca
commit
6e1fe4d9fc
9 changed files with 94 additions and 97 deletions
|
@ -10,18 +10,23 @@ fn main() {
|
|||
let radius = args[0].parse().unwrap();
|
||||
let k_offset = 0.435;
|
||||
let k_sharpness = 28.0;
|
||||
let precision = 50.0; // for rounding
|
||||
|
||||
let mut img = image::RgbImage::new(radius * 2 + 1, radius * 2 + 1);
|
||||
|
||||
let mut total_max = 0.0;
|
||||
let mut total_lookups = 0;
|
||||
println!("// generated by the rust program");
|
||||
println!("#define RADIUS {}", radius);
|
||||
println!("const half Kernel[{}][{}] = {{", radius + 1, radius);
|
||||
for y in 0..=radius {
|
||||
print!(" {{");
|
||||
for x in 1..=radius {
|
||||
let k = (k(x, y, radius, k_offset, k_sharpness) * 50.0).floor() / 50.0;
|
||||
let k = (k(x, y, radius, k_offset, k_sharpness) * precision).floor() / precision;
|
||||
total_max += k * 4.0;
|
||||
if k > 0.0 {
|
||||
total_lookups += 1;
|
||||
}
|
||||
print!("{:.2}, ", k);
|
||||
{
|
||||
let pixel = image::Rgb([0, (k * 255.0) as u8, 0]);
|
||||
|
@ -36,6 +41,12 @@ fn main() {
|
|||
}
|
||||
println!("}};");
|
||||
println!("const float total_max = {};", total_max);
|
||||
println!(
|
||||
"// Total texture lookups: {} * 4 + 1 = {}",
|
||||
total_lookups,
|
||||
total_lookups * 4 + 1
|
||||
);
|
||||
println!("// (lookups multiplied by 0.0 get optimised away by the shader compiler, and this giant table generally only exists at compile time)");
|
||||
img.save("kernel.png").unwrap();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue