This commit is contained in:
parent
f06f741a74
commit
912635a823
|
@ -1,9 +1,9 @@
|
||||||
extends Resource
|
extends Resource
|
||||||
@export var basenames: PackedStringArray
|
@export var basenames: PackedStringArray
|
||||||
@export var shader: ShaderInclude
|
@export var shader: ShaderInclude
|
||||||
@export var image_cow: Texture2D
|
@export var image_VA_Swallow1: Texture2D
|
||||||
@export var image_mask_cow: Texture2D
|
@export var image_mask_VA_Swallow1: Texture2D
|
||||||
|
|
||||||
func attach(mat: ShaderMaterial):
|
func attach(mat: ShaderMaterial):
|
||||||
mat.set_shader_parameter('image_cow', image_cow)
|
mat.set_shader_parameter('image_VA_Swallow1', image_VA_Swallow1)
|
||||||
mat.set_shader_parameter('image_mask_cow', image_mask_cow)
|
mat.set_shader_parameter('image_mask_VA_Swallow1', image_mask_VA_Swallow1)
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
|
|
||||||
uniform sampler2D image_cow: repeat_disable;
|
uniform sampler2D image_VA_Swallow1: repeat_disable;
|
||||||
uniform sampler2D image_mask_cow: repeat_disable;
|
uniform sampler2D image_mask_VA_Swallow1: repeat_disable;
|
||||||
uniform bool enabled_cow = false;
|
uniform bool enabled_VA_Swallow1 = false;
|
||||||
uniform int start_time_cow;
|
uniform int start_time_VA_Swallow1;
|
||||||
|
|
|
@ -16,7 +16,8 @@ use std::{error::Error, fs::File};
|
||||||
// https://github.com/vfx-rs/openexr-rs/blob/25826b4f89bc768b565ba150d6f9c76876ad6bc3/src/core/output_file.rs#L275
|
// https://github.com/vfx-rs/openexr-rs/blob/25826b4f89bc768b565ba150d6f9c76876ad6bc3/src/core/output_file.rs#L275
|
||||||
|
|
||||||
pub const MAX_IMAGE_DIM: usize = 16384;
|
pub const MAX_IMAGE_DIM: usize = 16384;
|
||||||
pub const MOVEMENT_EPSILON: f32 = 0.0000001;
|
// TODO lower this once you figure out what the fuck
|
||||||
|
pub const MOVEMENT_EPSILON: f32 = 1.0;
|
||||||
|
|
||||||
fn non_color_channel() -> Channel {
|
fn non_color_channel() -> Channel {
|
||||||
Channel {
|
Channel {
|
||||||
|
@ -28,13 +29,15 @@ fn non_color_channel() -> Channel {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Godot doesn't seem to support Uint images, using f32 instead
|
// Godot doesn't seem to support Uint images, using f32 instead
|
||||||
|
// Currently only using R channel, can squeeze more into 16k texture if use more channels
|
||||||
fn write_mask_image(
|
fn write_mask_image(
|
||||||
filename: &str,
|
filename: &str,
|
||||||
pixels: &Vec<f32>,
|
pixels: &Vec<f32>,
|
||||||
vertex_total: usize,
|
vertex_total: usize,
|
||||||
) -> Result<(), Box<dyn Error>> {
|
) -> Result<(), Box<dyn Error>> {
|
||||||
let width = vertex_total;
|
let width = vertex_total.min(MAX_IMAGE_DIM);
|
||||||
let height: usize = 1;
|
let height: usize = ((vertex_total as f32) / (MAX_IMAGE_DIM as f32)).ceil() as usize;
|
||||||
|
assert!(height <= MAX_IMAGE_DIM);
|
||||||
let mut header = Header::from_dimensions(width as i32, height as i32);
|
let mut header = Header::from_dimensions(width as i32, height as i32);
|
||||||
|
|
||||||
header.channels_mut().insert("R", &non_color_channel());
|
header.channels_mut().insert("R", &non_color_channel());
|
||||||
|
@ -200,13 +203,6 @@ fn main() {
|
||||||
.unwrap();
|
.unwrap();
|
||||||
assert_eq!(max_point_idx + 1, total_points as usize);
|
assert_eq!(max_point_idx + 1, total_points as usize);
|
||||||
|
|
||||||
let varying_count = 17;
|
|
||||||
let varied = mask_last.iter().filter(|x| match x {
|
|
||||||
Varying { count, .. } => *count > varying_count,
|
|
||||||
_ => false
|
|
||||||
}).count();
|
|
||||||
println!("There were {} points that varied more than {} times", varied, varying_count);
|
|
||||||
|
|
||||||
let pc = pc.into_iter();
|
let pc = pc.into_iter();
|
||||||
|
|
||||||
pixels.extend(pc.filter_map(|frame| {
|
pixels.extend(pc.filter_map(|frame| {
|
||||||
|
@ -216,14 +212,17 @@ fn main() {
|
||||||
match mask_last[point_idx] {
|
match mask_last[point_idx] {
|
||||||
Unseen => panic!(),
|
Unseen => panic!(),
|
||||||
OneValue { .. } => None,
|
OneValue { .. } => None,
|
||||||
Varying { .. } => Some(point)
|
Varying { .. } => Some(point),
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
assert!(pixels.len() == total_varying * (total_frames as usize));
|
assert!(pixels.len() == total_varying * (total_frames as usize));
|
||||||
|
|
||||||
|
if total_varying == 0 {
|
||||||
|
eprintln!("No varying frames, not outputting .exr image");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
write_point_image(
|
write_point_image(
|
||||||
&(basename + ".exr"),
|
&(basename + ".exr"),
|
||||||
&pixels,
|
&pixels,
|
||||||
|
@ -232,5 +231,5 @@ fn main() {
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
println!("Total {} varying points", total_varying);
|
println!("Total {} varying points of {} total points", total_varying, total_points);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue