Make Upload Texture node resolution-aware (#2018)

* Make UploadTextureNode resolution aware

* Add TextureFrame implementations for MonitorNode

* Add TextureFrame implementation to TransformNode
This commit is contained in:
Dennis Kobert 2024-10-03 19:32:34 +02:00 committed by GitHub
parent 2d86fb24ab
commit d2f791cfb3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 14 additions and 2 deletions

View File

@ -1777,11 +1777,12 @@ fn static_nodes() -> Vec<DocumentNodeDefinition> {
}, },
DocumentNode { DocumentNode {
inputs: vec![NodeInput::network(concrete!(ImageFrame<Color>), 0), NodeInput::node(NodeId(0), 0)], inputs: vec![NodeInput::network(concrete!(ImageFrame<Color>), 0), NodeInput::node(NodeId(0), 0)],
manual_composition: Some(generic!(T)),
implementation: DocumentNodeImplementation::ProtoNode(ProtoNodeIdentifier::new("wgpu_executor::UploadTextureNode")), implementation: DocumentNodeImplementation::ProtoNode(ProtoNodeIdentifier::new("wgpu_executor::UploadTextureNode")),
..Default::default() ..Default::default()
}, },
DocumentNode { DocumentNode {
manual_composition: Some(concrete!(Footprint)), manual_composition: Some(generic!(T)),
inputs: vec![NodeInput::node(NodeId(1), 0)], inputs: vec![NodeInput::node(NodeId(1), 0)],
implementation: DocumentNodeImplementation::ProtoNode(ProtoNodeIdentifier::new("graphene_core::memo::ImpureMemoNode")), implementation: DocumentNodeImplementation::ProtoNode(ProtoNodeIdentifier::new("graphene_core::memo::ImpureMemoNode")),
..Default::default() ..Default::default()

View File

@ -1,3 +1,4 @@
use crate::application_io::TextureFrame;
use crate::raster::bbox::AxisAlignedBbox; use crate::raster::bbox::AxisAlignedBbox;
use crate::raster::{ImageFrame, Pixel}; use crate::raster::{ImageFrame, Pixel};
use crate::vector::VectorData; use crate::vector::VectorData;
@ -216,6 +217,7 @@ async fn transform<I: Into<Footprint> + 'n + ApplyTransform + Clone + Send + Syn
(), (),
(), (),
(), (),
(),
Footprint, Footprint,
)] )]
mut input: I, mut input: I,
@ -223,9 +225,11 @@ async fn transform<I: Into<Footprint> + 'n + ApplyTransform + Clone + Send + Syn
() -> VectorData, () -> VectorData,
() -> GraphicGroup, () -> GraphicGroup,
() -> ImageFrame<Color>, () -> ImageFrame<Color>,
() -> TextureFrame,
Footprint -> VectorData, Footprint -> VectorData,
Footprint -> GraphicGroup, Footprint -> GraphicGroup,
Footprint -> ImageFrame<Color>, Footprint -> ImageFrame<Color>,
Footprint -> TextureFrame,
)] )]
transform_target: impl Node<I, Output = T>, transform_target: impl Node<I, Output = T>,
translate: DVec2, translate: DVec2,

View File

@ -175,6 +175,8 @@ fn node_registry() -> HashMap<ProtoNodeIdentifier, HashMap<NodeIOTypes, NodeCons
), ),
async_node!(graphene_core::memo::MonitorNode<_, _, _>, input: Footprint, fn_params: [Footprint => ImageFrame<Color>]), async_node!(graphene_core::memo::MonitorNode<_, _, _>, input: Footprint, fn_params: [Footprint => ImageFrame<Color>]),
async_node!(graphene_core::memo::MonitorNode<_, _, _>, input: (), params: [ImageFrame<Color>]), async_node!(graphene_core::memo::MonitorNode<_, _, _>, input: (), params: [ImageFrame<Color>]),
async_node!(graphene_core::memo::MonitorNode<_, _, _>, input: Footprint, fn_params: [Footprint => TextureFrame]),
async_node!(graphene_core::memo::MonitorNode<_, _, _>, input: (), params: [TextureFrame]),
async_node!(graphene_core::memo::MonitorNode<_, _, _>, input: Footprint, fn_params: [Footprint => VectorData]), async_node!(graphene_core::memo::MonitorNode<_, _, _>, input: Footprint, fn_params: [Footprint => VectorData]),
async_node!(graphene_core::memo::MonitorNode<_, _, _>, input: (), fn_params: [() => VectorData]), async_node!(graphene_core::memo::MonitorNode<_, _, _>, input: (), fn_params: [() => VectorData]),
async_node!(graphene_core::memo::MonitorNode<_, _, _>, input: Footprint, fn_params: [Footprint => graphene_core::GraphicGroup]), async_node!(graphene_core::memo::MonitorNode<_, _, _>, input: Footprint, fn_params: [Footprint => graphene_core::GraphicGroup]),

View File

@ -911,8 +911,13 @@ async fn render_texture<'a: 'n>(_: (), footprint: Footprint, image: impl Node<Fo
} }
#[node_macro::node(category(""))] #[node_macro::node(category(""))]
async fn upload_texture<'a: 'n>(_: (), input: ImageFrame<Color>, executor: &'a WgpuExecutor) -> TextureFrame { async fn upload_texture<'a: 'n, F: Copy + Send + Sync + 'n>(
#[implementations((), Footprint)] footprint: F,
#[implementations(() -> ImageFrame<Color>, Footprint -> ImageFrame<Color>)] input: impl Node<F, Output = ImageFrame<Color>>,
executor: &'a WgpuExecutor,
) -> TextureFrame {
// let new_data: Vec<RGBA16F> = input.image.data.into_iter().map(|c| c.into()).collect(); // let new_data: Vec<RGBA16F> = input.image.data.into_iter().map(|c| c.into()).collect();
let input = input.eval(footprint).await;
let new_data = input.image.data.into_iter().map(SRGBA8::from).collect(); let new_data = input.image.data.into_iter().map(SRGBA8::from).collect();
let new_image = Image { let new_image = Image {
width: input.image.width, width: input.image.width,