mirror of
https://github.com/storytold/materialcraft.git
synced 2026-11-28 17:19:17 +01:00
Preserve bound image resources on SBS input bridges
This commit is contained in:
1 parent
a4c792859c
commit
d30917484c
14 files changed
+182
-35
No files matched your search
@@ -69,6 +69,9 @@ pub struct Graph {
|
||||
pub input_images: BTreeMap<String, String>,
|
||||
#[serde(default, skip_serializing_if = "BTreeSet::is_empty")]
|
||||
pub input_images_linear: BTreeSet<String>,
|
||||
/// SBS image bindings without an explicit preview interpretation use the resource's file transfer.
|
||||
#[serde(default, skip_serializing_if = "BTreeSet::is_empty")]
|
||||
pub input_images_from_file: BTreeSet<String>,
|
||||
#[serde(default)]
|
||||
pub attributes: Attributes,
|
||||
/// The id the next node, frame, comment or pin gets
|
||||
@@ -119,6 +122,7 @@ impl Graph {
|
||||
presets: Vec::new(),
|
||||
input_images: BTreeMap::new(),
|
||||
input_images_linear: BTreeSet::new(),
|
||||
input_images_from_file: BTreeSet::new(),
|
||||
attributes: Attributes::default(),
|
||||
next_id: 1,
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ pub fn session(session: &Session, requested_graph: Option<usize>) -> J {
|
||||
"inputs": graph.inputs,
|
||||
"inputImages": graph.input_images,
|
||||
"inputImagesLinear": graph.input_images_linear,
|
||||
"inputImagesFromFile": graph.input_images_from_file,
|
||||
"nodes": graph.nodes.iter().map(|node| {
|
||||
let entry = cooked.and_then(|cooked| cooked.nodes.get(&node.id));
|
||||
let (inputs, outputs) = materialcraft_eval::ports(&session.pkg, graph, node);
|
||||
|
||||
@@ -236,6 +236,7 @@ fn bind(s: &mut Session, p: &J) -> Result<J> {
|
||||
let linear = p.get("linear").and_then(J::as_bool).unwrap_or(false);
|
||||
let g = s.graph_mut()?;
|
||||
g.input_images.insert(id.clone(), res.clone());
|
||||
g.input_images_from_file.remove(&id);
|
||||
if linear {
|
||||
g.input_images_linear.insert(id.clone());
|
||||
} else {
|
||||
@@ -261,8 +262,10 @@ fn read_image_file(cmd: &str, _: &str) -> Result<(String, Vec<u8>)> {
|
||||
fn unbind(s: &mut Session, p: &J) -> Result<J> {
|
||||
let id = strp(p, "identifier").ok_or_else(|| bad("graph.input.unbind", "`identifier` is required"))?.to_string();
|
||||
s.edit("Clear input preview image", |s| {
|
||||
s.graph_mut()?.input_images_linear.remove(&id);
|
||||
Ok(J::Bool(s.graph_mut()?.input_images.remove(&id).is_some()))
|
||||
let graph = s.graph_mut()?;
|
||||
graph.input_images_linear.remove(&id);
|
||||
graph.input_images_from_file.remove(&id);
|
||||
Ok(J::Bool(graph.input_images.remove(&id).is_some()))
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -42,6 +42,9 @@ fn bitmap_nodes_read_default_colors_from_the_file_and_keep_explicit_data_reads()
|
||||
graph.format = OutputFormat::U8;
|
||||
let bitmap = graph.add_node("bitmap", [0.0; 2]);
|
||||
let data = graph.add_node("bitmap", [0.0, 80.0]);
|
||||
let input = graph.add_node("input_color", [0.0, 160.0]);
|
||||
graph.input_images.insert("input".into(), "field".into());
|
||||
graph.input_images_from_file.insert("input".into());
|
||||
for id in [bitmap, data] {
|
||||
graph.node_mut(id).unwrap().params.insert("resource".into(), Value::Text("field".into()));
|
||||
}
|
||||
@@ -52,6 +55,11 @@ fn bitmap_nodes_read_default_colors_from_the_file_and_keep_explicit_data_reads()
|
||||
let pixel = |id| cook.image(id, 0).unwrap().get(0, 0, false).map(|v| (v * 255.0).round() as u8);
|
||||
assert_eq!(pixel(bitmap), expected);
|
||||
assert_eq!(pixel(data), [64, 128, 192, 97]);
|
||||
assert_eq!(pixel(input), expected);
|
||||
crate::execute(&mut session, "graph.input.bind", &serde_json::json!({"identifier":"input", "resource":"field", "linear":true})).unwrap();
|
||||
assert!(!session.graph().unwrap().input_images_from_file.contains("input"));
|
||||
let rebound = session.cook().image(input, 0).unwrap().get(0, 0, false).map(|v| (v * 255.0).round() as u8);
|
||||
assert_eq!(rebound, [64, 128, 192, 97]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ use crate::{
|
||||
};
|
||||
use craft_texture::{Image, Kind};
|
||||
use materialcraft_core::{Node, OutputFormat, Package, Value};
|
||||
use materialcraft_nodes::{CookContext, GraphVariables, find};
|
||||
use materialcraft_nodes::{BitmapColorSpace, CookContext, GraphVariables, find};
|
||||
use std::{
|
||||
collections::BTreeMap,
|
||||
sync::{Arc, Mutex},
|
||||
@@ -226,7 +226,14 @@ pub(crate) fn cook_node(
|
||||
}
|
||||
let graph = package.graphs.get(graph_index)?;
|
||||
let binding = graph.input_images.get(&name)?;
|
||||
let image = (options.resource)(&craft_texture::resource_key(binding, graph.input_images_linear.contains(&name)))?;
|
||||
let space = if graph.input_images_from_file.contains(&name) {
|
||||
BitmapColorSpace::FromFile
|
||||
} else if graph.input_images_linear.contains(&name) {
|
||||
BitmapColorSpace::Linear
|
||||
} else {
|
||||
BitmapColorSpace::Srgb
|
||||
};
|
||||
let image = (options.resource)(&space.resource_key(binding))?;
|
||||
let bitmap =
|
||||
if image.integer_sampling() { package.resource(binding).and_then(|r| materialcraft_core::png_sample_format(r.bytes.as_slice())) } else { None };
|
||||
Some((image, None, bitmap, false))
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
use super::{
|
||||
LayoutFrame, LayoutItem,
|
||||
filter_map::FILTERS,
|
||||
xml::{child_element, child_value, children_named, parse_floats},
|
||||
xml::{child_element, child_value, children_named, parse_floats, string_parameter},
|
||||
};
|
||||
use crate::{FormatError, Result};
|
||||
use roxmltree::Node as XmlNode;
|
||||
@@ -189,16 +189,6 @@ fn function_item(node: XmlNode, dependencies: &HashMap<&str, String>) -> Option<
|
||||
Some(LayoutItem::FunctionInstance { package, graph })
|
||||
}
|
||||
|
||||
/// Read a named static string parameter from an atomic filter.
|
||||
fn string_parameter<'a>(filter: XmlNode<'a, '_>, name: &str) -> Option<&'a str> {
|
||||
child_element(filter, "parameters")
|
||||
.into_iter()
|
||||
.flat_map(|parameters| children_named(parameters, "parameter"))
|
||||
.find(|parameter| child_value(*parameter, "name") == Some(name))
|
||||
.and_then(|parameter| child_element(parameter, "paramValue"))
|
||||
.and_then(|value| child_value(value, "constantValueString"))
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
#[allow(clippy::unwrap_used, clippy::expect_used)]
|
||||
mod tests {
|
||||
|
||||
@@ -11,6 +11,11 @@ pub(super) fn text_param(node: &Node, key: &str, default: &str) -> String {
|
||||
pub(super) fn param_xml(name: &str, value: &Value) -> Option<String> {
|
||||
Some(format!("<parameter><name v=\"{}\"/><relativeTo v=\"0\"/><paramValue>{}</paramValue></parameter>", xml_escape(name), constant_xml(value)?))
|
||||
}
|
||||
|
||||
pub(super) fn resource_parameter_xml(parameter: &str, name: &str, self_uid: u64, package: &materialcraft_core::Package) -> String {
|
||||
let path = package.resource(name).map_or_else(|| format!("Resources/{name}"), |resource| resource.sbs_path());
|
||||
param_xml(parameter, &Value::Text(format!("pkg:///{path}?dependency={self_uid}"))).unwrap_or_default()
|
||||
}
|
||||
pub(super) fn special_filter_params_xml<'a>(
|
||||
filter: &str,
|
||||
value_of: &dyn Fn(&str) -> Option<&'a Value>,
|
||||
@@ -19,14 +24,9 @@ pub(super) fn special_filter_params_xml<'a>(
|
||||
) -> String {
|
||||
match filter {
|
||||
"bitmap" | "svg" => match value_of("resource") {
|
||||
Some(Value::Text(name)) if !name.is_empty() => param_xml(
|
||||
if filter == "svg" { "vectorresourcepath" } else { "bitmapresourcepath" },
|
||||
&Value::Text(format!(
|
||||
"pkg:///{}?dependency={self_uid}",
|
||||
package.resource(name).map_or_else(|| format!("Resources/{name}"), |resource| resource.sbs_path())
|
||||
)),
|
||||
)
|
||||
.unwrap_or_default(),
|
||||
Some(Value::Text(name)) if !name.is_empty() => {
|
||||
resource_parameter_xml(if filter == "svg" { "vectorresourcepath" } else { "bitmapresourcepath" }, name, self_uid, package)
|
||||
}
|
||||
_ => String::new(),
|
||||
},
|
||||
_ => String::new(),
|
||||
|
||||
@@ -8,6 +8,9 @@ const LINEAR_PREFIX: &str = "materialcraft.previewLinear.";
|
||||
|
||||
pub(super) fn write(out: &mut String, graph: &Graph) {
|
||||
for (identifier, resource) in &graph.input_images {
|
||||
if graph.input_images_from_file.contains(identifier) {
|
||||
continue;
|
||||
}
|
||||
let _ = write!(out, "<option><name v=\"{IMAGE_PREFIX}{}\"/><value v=\"{}\"/></option>", xml_escape(identifier), xml_escape(resource));
|
||||
if graph.input_images_linear.contains(identifier) {
|
||||
let _ = write!(out, "<option><name v=\"{LINEAR_PREFIX}{}\"/><value v=\"1\"/></option>", xml_escape(identifier));
|
||||
@@ -15,6 +18,21 @@ pub(super) fn write(out: &mut String, graph: &Graph) {
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) fn read_resource(graph: &mut Graph, identifier: &str, resource: Option<String>) {
|
||||
// A matching preview option retains the interpretation explicitly chosen for this resource.
|
||||
if resource.is_some() && graph.input_images.get(identifier) == resource.as_ref() {
|
||||
return;
|
||||
}
|
||||
graph.input_images_linear.remove(identifier);
|
||||
if let Some(name) = resource {
|
||||
graph.input_images.insert(identifier.to_string(), name);
|
||||
graph.input_images_from_file.insert(identifier.to_string());
|
||||
} else {
|
||||
graph.input_images.remove(identifier);
|
||||
graph.input_images_from_file.remove(identifier);
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) fn read(option: XmlNode, graph: &mut Graph) {
|
||||
let Some(name) = child_value(option, "name") else { return };
|
||||
let Some(value) = child_value(option, "value") else { return };
|
||||
@@ -27,3 +45,79 @@ pub(super) fn read(option: XmlNode, graph: &mut Graph) {
|
||||
graph.input_images_linear.insert(identifier.to_string());
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::sbs::{read_sbs, write_sbs};
|
||||
use materialcraft_core::{Graph, Package, Resource, ResourceBytes, Value};
|
||||
|
||||
#[test]
|
||||
fn image_bridges_write_the_bound_package_resource() {
|
||||
let mut package = Package::new("Input images");
|
||||
let mut resource = Resource::new("grain", "grain.png", ResourceBytes::default());
|
||||
resource.folder = "Inputs/Maps".into();
|
||||
resource.source = "grain.png".into();
|
||||
package.resources.push(resource);
|
||||
let mut graph = Graph::new("Paint");
|
||||
for (definition, identifier) in [("input_grayscale", "height"), ("input_color", "paint"), ("input_color", "open")] {
|
||||
let id = graph.add_node(definition, [0.0; 2]);
|
||||
graph.node_mut(id).unwrap().params.insert("identifier".into(), Value::Text(identifier.into()));
|
||||
}
|
||||
for identifier in ["height", "paint"] {
|
||||
graph.input_images.insert(identifier.into(), "grain".into());
|
||||
}
|
||||
package.graphs.push(graph);
|
||||
|
||||
let bytes = write_sbs(&package).unwrap();
|
||||
let doc = roxmltree::Document::parse(std::str::from_utf8(&bytes).unwrap()).unwrap();
|
||||
let own = doc.descendants().find(|node| node.has_tag_name("dependency") && super::child_value(*node, "filename") == Some("?himself")).unwrap();
|
||||
let url = format!("pkg:///Inputs/Maps/grain?dependency={}", super::child_value(own, "uid").unwrap());
|
||||
let bindings: Vec<_> = doc
|
||||
.descendants()
|
||||
.filter(|node| node.has_tag_name("compInputBridge"))
|
||||
.map(|bridge| {
|
||||
bridge
|
||||
.descendants()
|
||||
.find(|p| p.has_tag_name("parameter") && super::child_value(*p, "name") == Some("bitmapresourcepath"))
|
||||
.and_then(|p| p.descendants().find(|v| v.has_tag_name("constantValueString")))
|
||||
.and_then(|v| v.attribute("v"))
|
||||
})
|
||||
.collect();
|
||||
assert_eq!(bindings, [Some(url.as_str()), Some(url.as_str()), None]);
|
||||
let reopened = read_sbs(&bytes, "input.sbs", &|_| None).unwrap().pkg;
|
||||
assert_eq!(reopened.graphs[0].input_images, package.graphs[0].input_images);
|
||||
assert!(reopened.graphs[0].input_images_from_file.is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn image_bridge_binding_takes_precedence_over_a_legacy_preview_name() {
|
||||
let xml = br#"<package><dependencies><dependency><filename v="?himself"/><uid v="1"/></dependency></dependencies>
|
||||
<content><group><identifier v="Masks"/><content><resource><identifier v="grain"/><type v="bitmap"/>
|
||||
<format v="png"/><filepath v="grain.png"/></resource></content></group>
|
||||
<graph><identifier v="Paint"/><paraminputs><paraminput><identifier v="height"/><uid v="12"/><type v="2"/></paraminput></paraminputs>
|
||||
<options><option><name v="materialcraft.previewImage.height"/><value v="old"/></option></options>
|
||||
<compNodes><compNode><uid v="13"/><compImplementation><compInputBridge><entry v="12"/><parameters>
|
||||
<parameter><name v="bitmapresourcepath"/><relativeTo v="0"/><paramValue><constantValueString v="pkg:///Masks/grain?dependency=1"/>
|
||||
</paramValue></parameter></parameters></compInputBridge></compImplementation></compNode></compNodes></graph></content></package>"#;
|
||||
let package = read_sbs(xml, "paint.sbs", &|_| None).unwrap().pkg;
|
||||
assert_eq!(package.graphs[0].input_images.get("height").map(String::as_str), Some("grain"));
|
||||
assert!(package.graphs[0].input_images_from_file.contains("height"));
|
||||
let reopened = read_sbs(&write_sbs(&package).unwrap(), "again.sbs", &|_| None).unwrap().pkg;
|
||||
assert_eq!(package.graphs[0].input_images_from_file, reopened.graphs[0].input_images_from_file);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn clearing_the_bridge_resource_clears_its_preview_interpretation() {
|
||||
let mut graph = Graph::new("Paint");
|
||||
graph.input_images.insert("height".into(), "grain".into());
|
||||
graph.input_images_linear.insert("height".into());
|
||||
super::read_resource(&mut graph, "height", Some("grain".into()));
|
||||
assert!(graph.input_images_linear.contains("height"));
|
||||
super::read_resource(&mut graph, "height", Some("different".into()));
|
||||
assert!(graph.input_images_linear.is_empty());
|
||||
assert!(graph.input_images_from_file.contains("height"));
|
||||
super::read_resource(&mut graph, "height", None);
|
||||
assert!(graph.input_images.is_empty());
|
||||
assert!(graph.input_images_from_file.is_empty());
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,7 @@ use super::read_node::ReadNode;
|
||||
use super::sbs_value::{SbsValue, exposed_default, sbs_constant, to_natural_value, to_param_value};
|
||||
use super::type_code;
|
||||
use super::warnings::Warnings;
|
||||
use super::xml::{child_element, child_value, children_named, parse_floats};
|
||||
use super::xml::{child_element, child_value, children_named, parse_floats, string_parameter};
|
||||
use materialcraft_core::{
|
||||
BaseParameter, ComponentUsage, Connection, ExposedParameter, Graph, MAX_SIZE_LOG2, MIN_SIZE_LOG2, MISSING_NODE, Node, NodeId, OutputFormat, Package,
|
||||
ParameterInheritance, Resource, ResourceBytes, Value,
|
||||
@@ -446,6 +446,7 @@ impl<'text> SbsReader<'text, '_> {
|
||||
"compInputBridge" => {
|
||||
let entry = child_value(implementation, "entry").unwrap_or("");
|
||||
let input = image_inputs.get(entry);
|
||||
let identifier = input.map_or("input", |input| input.identifier.as_str());
|
||||
let code = input.map_or(1, |input| input.type_code);
|
||||
let definition = match code {
|
||||
1 => "input_color",
|
||||
@@ -453,9 +454,14 @@ impl<'text> SbsReader<'text, '_> {
|
||||
_ => "input_value",
|
||||
};
|
||||
|
||||
if matches!(code, 1 | 2)
|
||||
&& let Some(url) = string_parameter(implementation, "bitmapresourcepath")
|
||||
{
|
||||
let resource = if url.is_empty() { None } else { self.resource_binding(url, &graph.name) };
|
||||
super::preview_binding::read_resource(graph, identifier, resource);
|
||||
}
|
||||
let (id, index, node) = push_node(graph, definition, pos);
|
||||
if let Some(node) = node {
|
||||
let identifier = input.map_or("input", |input| input.identifier.as_str());
|
||||
node.params.insert("identifier".into(), Value::Text(identifier.to_string()));
|
||||
node.params.insert("usage".into(), Value::Enum(input.map_or(ComponentUsage::ANY_INDEX, |input| input.usage)));
|
||||
if let Some(input) = input {
|
||||
|
||||
@@ -5,7 +5,7 @@ use super::constant::NODE_HALF_SIZE;
|
||||
use super::filter_map::filter_by_def;
|
||||
use super::function_graph;
|
||||
use super::node_identifiers::NodeIdentifiers;
|
||||
use super::node_parameter::{param_xml, special_filter_params_xml, text_param};
|
||||
use super::node_parameter::{param_xml, resource_parameter_xml, special_filter_params_xml, text_param};
|
||||
use super::output::output_type;
|
||||
use super::sbs_value::{exposed_type_code, input_default_xml};
|
||||
use super::type_code;
|
||||
@@ -143,7 +143,7 @@ impl SbsWriter {
|
||||
|
||||
out.push_str("<compImplementation>");
|
||||
let ids = NodeIdentifiers { input_entry: input_entries.get(&node.id).copied(), graph_output: output_uids.get(&node.id).copied(), self_uid };
|
||||
self.write_implementation(out, node, outputs, ids, pkg)?;
|
||||
self.write_implementation(out, node, outputs, ids, graph, pkg)?;
|
||||
out.push_str("</compImplementation></compNode>");
|
||||
}
|
||||
|
||||
@@ -272,6 +272,7 @@ impl SbsWriter {
|
||||
node: &Node,
|
||||
outputs: &[(String, u32, u64)],
|
||||
ids: NodeIdentifiers,
|
||||
graph: &Graph,
|
||||
package: &Package,
|
||||
) -> Result<()> {
|
||||
// The reader assigns a native default when a processor omits format
|
||||
@@ -282,7 +283,14 @@ impl SbsWriter {
|
||||
let _ = write!(out, "<compOutputBridge><output v=\"{}\"/></compOutputBridge>", ids.graph_output.unwrap_or(0));
|
||||
}
|
||||
"input_color" | "input_grayscale" | "input_value" => {
|
||||
let _ = write!(out, "<compInputBridge><entry v=\"{}\"/><parameters>{base}</parameters></compInputBridge>", ids.input_entry.unwrap_or(0));
|
||||
let _ = write!(out, "<compInputBridge><entry v=\"{}\"/><parameters>{base}", ids.input_entry.unwrap_or(0));
|
||||
if node.def != "input_value"
|
||||
&& let Some(name) = graph.input_images.get(&text_param(node, "identifier", "input"))
|
||||
&& !name.is_empty()
|
||||
{
|
||||
out.push_str(&resource_parameter_xml("bitmapresourcepath", name, ids.self_uid, package));
|
||||
}
|
||||
out.push_str("</parameters></compInputBridge>");
|
||||
}
|
||||
"graph_instance" => {
|
||||
let sub_graph = node.instance.as_ref().map(|instance| instance.graph.clone()).unwrap_or_else(|| text_param(node, "graph", ""));
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
use roxmltree::Node as XmlNode;
|
||||
|
||||
pub(super) fn string_parameter<'a>(implementation: XmlNode<'a, '_>, name: &str) -> Option<&'a str> {
|
||||
let parameters = child_element(implementation, "parameters")?;
|
||||
let parameter = children_named(parameters, "parameter").find(|p| child_value(*p, "name") == Some(name))?;
|
||||
child_value(child_element(parameter, "paramValue")?, "constantValueString")
|
||||
}
|
||||
|
||||
pub(super) fn parse_floats(text: &str) -> Vec<f32> {
|
||||
text.split_whitespace().take(16).map(|t| t.parse::<f32>().ok().filter(|v| v.is_finite()).unwrap_or(0.0)).collect()
|
||||
}
|
||||
|
||||
@@ -415,10 +415,11 @@ pass `merge: true` to continue one gesture; an ordinary request ends that merge.
|
||||
still coalesce until release. `material_export` uses the headless write-root capability and does not
|
||||
expose unrestricted engine file paths.
|
||||
|
||||
Bitmap Color space selects sRGB or Linear. `graph.input.bind` accepts `linear: true` for normal,
|
||||
height and other data maps. Input preview bindings persist in native SBS graph options with the
|
||||
`materialcraft.previewImage.` and `materialcraft.previewLinear.` prefixes; these options describe
|
||||
MaterialCraft editor previews and do not establish external application interoperability.
|
||||
SBS image inputs store the package resource URL in the input bridge's `bitmapresourcepath`.
|
||||
On import, an image bound by this field uses the resource file's color interpretation.
|
||||
`graph.input.bind` accepts `linear: true` to keep the original levels of normal, height and other
|
||||
data maps, or `linear: false` for sRGB color. MaterialCraft preserves its explicit preview
|
||||
interpretations in graph options and reads bindings from older files that use those options.
|
||||
|
||||
### Shared graph items and classification metadata
|
||||
|
||||
|
||||
@@ -59,6 +59,25 @@ The first pass classifies all 546 roots: 166 Parity and 380 Too hard. These meas
|
||||
|
||||
## 2026-11-27 root comparisons
|
||||
|
||||
### Saved image inputs and automatic filtering in Tile Random
|
||||
|
||||
Bind generated gray and color images to graph inputs and use an ordinary **Save As**. The two tile roots previously stored the resource names only in editor options. Opening the saved 32² F32 files in the reference app gave 0/4,096 exact pixels across the four files. For a 1 × 1 grid with both images connected, the maximum errors were .501960814 grayscale and .937254906 color. With only the pattern connected to a regular 2 × 2 grid, they were .694605947 and .854413688. An independently authored one-input package shows the resource URL on the image bridge's `bitmapresourcepath` parameter. Adding that field to the four test files recovered 4,096/4,096 on one and eight processors, maximum zero.
|
||||
|
||||
MaterialCraft now reads and writes this bridge parameter with the package resource path and dependency UID. To test a file-authored binding, connect an image input directly to an output at 16² U8. Use `u(x,y) = x + 16y` for gray and `(u(x,y), u(y,x), 255−u(x,y), u((x−3) mod 16,y))` for RGBA. Write PNGs with no transfer tag, an sRGB tag and gAMA values 100000, 45455 and 220000. Open the ten SBS files directly, save them normally and reopen them in both applications. The previous reader matched 5/2,560 pixels with a maximum error of 255 byte levels. The corrected reader matches 2,560/2,560 on one processor, eight and on ordinary reopen, maximum zero. At gray level 128 the three gamma-tagged files read back as 186, 128 and 221 respectively. Alpha retains its original levels. The 549 tracked SBS files contain 2,495 input bridges and zero authored `bitmapresourcepath` bindings on those bridges.
|
||||
|
||||
Run the [145 grayscale and 76 color settings](#integer-assignments-read-by-pattern-seeds) with a separate path to the same original procedural bitmap for each connected input in each setting. Read the whole output on one reference processor, on eight and after opening an ordinary MaterialCraft save and reapplying those inputs. Every setting matches on all three routes. Each cell gives exact pixels per route. Maximum error is zero throughout.
|
||||
|
||||
| Root | U8 | U16 | F16 | F32 | Total |
|
||||
|---|---:|---:|---:|---:|---:|
|
||||
| Tile Random | 9,728/9,728 | 124,928/124,928 | 11,776/11,776 | 131,328/131,328 | 277,760/277,760 |
|
||||
| Tile Random Color | 9,728/9,728 | 124,928/124,928 | 11,776/11,776 | 60,672/60,672 | 207,104/207,104 |
|
||||
|
||||
For a file handoff, configure each root in MaterialCraft before saving. Use the defaults at 128² with seeds 0 and 42 and both procedural inputs. At 32² F32 and seed zero, use a 1 × 1 grid with both inputs and the regular 2 × 2 grid with only the pattern. Include the four formats at 32 × 64/530371, 64 × 32/89027 and 16 × 32/2747 from the [rectangular parameter matrix](#integer-assignments-read-by-pattern-seeds). Open each of the 32 files directly. Read the reference output without setting any property, verify its stored seed and compare it with the original configured image and the MaterialCraft reopen. On one and eight processors, all three images match **106,496/106,496 pixels** each. Per root this is 4,608 U8, 37,376 U16, 4,608 F16 and 6,656 F32, maximum zero in every format.
|
||||
|
||||
For the outstanding live edit, keep the 128² pattern connected while removing the background and selecting the regular 2 × 2 grid at 32², seed zero. The sequential result matches 4/1,024 grayscale pixels (maximum .267032921) and 0/1,024 color pixels (.416119799). Giving the same pattern a fresh binding restores 1,024/1,024 each. Insert identity Levels at U8 between the pattern input and its first consumer. Automatic filtering then reproduces the sequential reference result, while explicit bilinear reproduces the fresh result. All six independent comparisons with the Levels graph, including nearest filtering, match 6,144/6,144 F32 pixels in total. These results distinguish the two filtering outcomes even when the input bridge has identical pixel values.
|
||||
|
||||
For a standalone reproduction, generate 128² byte fields `(13x + 7y + 3xy) mod 253` and `(31x + 19y + 5xy) mod 251`. Connect the first to a centered half-size image stamp, with unit opacity and a black background. At 32² F32, adding the second field as background while retaining the pattern gives 833/1,024 exact pixels with automatic filtering, maximum .001968503. Removing it gives 833/1,024, maximum .001968443. Rebinding the pattern or changing to 16² and back restores all 1,024. Explicit bilinear matches 12,544/12,544 across the 13 settings on one processor, eight and after ordinary reopen. Both tile roots retain their open live-edit comparison.
|
||||
|
||||
### Integer assignments read by pattern seeds
|
||||
|
||||
The two roots in `tile_random.sbs` each match **142,592/142,592 pixels in all 19 established settings** on one reference processor, on eight and after reopening an ordinary MaterialCraft save. The previous grayscale and color totals were 111,207 and 111,194. The same 1,702,705-byte save was reproduced with the tested build. Both roots also match at 32² with a freshly connected image in the edit-order control described below. [Previous comparison](#returned-vectors-in-pattern-properties)
|
||||
|
||||
@@ -41,7 +41,7 @@ Writable quadrant tints now match 16,896/16,896 pixels in 44 settings across fou
|
||||
|
||||
Six upstream filters now match 27,648/27,648 original and 27,648/27,648 reopened pixels across four output formats, up from 24,192 on each side. Both directions of an image connection through a graph instance also match 4,608/4,608 F32 pixels on each side. [Published filter properties, fixed controls and raw errors](parity-fixes.md#published-filter-properties-upstream-of-a-quadrant-draw)
|
||||
|
||||
The older roots in `tile_random.sbs` each match 142,592/142,592 pixels in their 19 established settings. The wider sequential comparison matches 144/145 grayscale and 75/76 color images. Rebinding a byte-identical pattern input changes the reference result in the remaining setting. [Raw counts, probe and edit sequence](parity-fixes.md#integer-assignments-read-by-pattern-seeds)
|
||||
The two roots in `tile_random.sbs` match all 484,864 pixels across 221 freshly bound settings. All 32 configured files reopened directly with 106,496/106,496 pixels exact on one and eight reference processors. Keeping the pattern connected while changing the background still gives a different result in one setting per root. [Per-format counts, filter controls and exact edit sequence](parity-fixes.md#saved-image-inputs-and-automatic-filtering-in-tile-random)
|
||||
|
||||
The two roots in `pattern_tile_random.sbs` match all 425,216 grayscale pixels in 104 settings and all 728,832 color pixels in 179 settings. Each output format matched on one processor, eight processors and ordinary reopen. [Whole-root settings and the shared pattern property correction](parity-fixes.md#returned-vectors-in-pattern-properties)
|
||||
|
||||
@@ -753,8 +753,8 @@ Creased matches 10,947,840/10,947,840 pixels across 100 distinct settings throug
|
||||
| [threshold.sbs/threshold](../assets/sbs/threshold.sbs) | 1 | No | [Parity: 4 cases](parity-fixes.md#verified-cases) |
|
||||
| [tile_generator.sbs/tile_generator](../assets/sbs/tile_generator.sbs) | 2 | Yes | [Parity · 284,416/284,416 across 55 settings and 81,920/81,920 in the 24 new settings, including reopen](parity-fixes.md#selected-channels-in-pattern-expressions) · [Earlier measurements](parity-fixes.md#tile-weave-splatter-and-fiber-stage-comparisons) · [Stamp-width recheck](parity-fixes.md#pixel-reciprocals-for-stamp-edge-widths) · [Bricks 01 tile and noise stages](parity-fixes.md#tile-luminance-variation-in-bricks-01) |
|
||||
| [tile_generator_color.sbs/tile_generator_color](../assets/sbs/tile_generator_color.sbs) | 2 | Yes | [Parity · 284,416/284,416 pixels across 55 distinct settings](parity-fixes.md#reopened-starburst-symmetry-tile-and-waveform-graphs) · [Earlier measurements](parity-fixes.md#tile-weave-splatter-and-fiber-stage-comparisons) · [Stamp-width recheck](parity-fixes.md#pixel-reciprocals-for-stamp-edge-widths) |
|
||||
| [tile_random.sbs/tile_random](../assets/sbs/tile_random.sbs) | 2 | Yes | [In progress · 276,740/277,760 pixels in 145 settings, one edit-order difference](parity-fixes.md#integer-assignments-read-by-pattern-seeds) · [Previous comparison · 111,207/142,592 pixels across 19 settings on both processor counts and ordinary reopen](parity-fixes.md#returned-vectors-in-pattern-properties) · [Previous comparison · 111,364/142,592 across 19 established settings, four ordinary saves compared](parity-fixes.md#whole-caustic-scratch-splatter-tile-and-vertical-noise-comparisons) · [Earlier comparison · 111,364/142,592 whole pixels, first differing stages measured](parity-fixes.md#tile-weave-splatter-and-fiber-stage-comparisons) · [saved authored and disc branches each match 4,864/4,864](parity-fixes.md#tile-weave-splatter-and-fiber-stage-comparisons) · [Stamp-width recheck](parity-fixes.md#pixel-reciprocals-for-stamp-edge-widths) · [Seed offsets on the initial iterator branch](parity-fixes.md#the-incoming-seed-on-the-initial-branch-of-an-iterate) |
|
||||
| [tile_random.sbs/tile_random_color](../assets/sbs/tile_random.sbs) | 2 | Yes | [In progress · 206,080/207,104 pixels in 76 settings, one edit-order difference](parity-fixes.md#integer-assignments-read-by-pattern-seeds) · [Previous comparison · 111,194/142,592 pixels across 19 settings on both processor counts and ordinary reopen](parity-fixes.md#returned-vectors-in-pattern-properties) · [Previous comparison · 111,228/142,592 across 19 established settings, four ordinary saves compared](parity-fixes.md#whole-caustic-scratch-splatter-tile-and-vertical-noise-comparisons) · [Earlier comparison · 111,228/142,592 whole pixels, first differing stages measured](parity-fixes.md#tile-weave-splatter-and-fiber-stage-comparisons) · [saved authored and disc branches each match 4,864/4,864](parity-fixes.md#tile-weave-splatter-and-fiber-stage-comparisons) · [Stamp-width recheck](parity-fixes.md#pixel-reciprocals-for-stamp-edge-widths) · [Seed offsets on the initial iterator branch](parity-fixes.md#the-incoming-seed-on-the-initial-branch-of-an-iterate) |
|
||||
| [tile_random.sbs/tile_random](../assets/sbs/tile_random.sbs) | 2 | Yes | [In progress · 277,760/277,760 grayscale pixels in 145 freshly bound settings, one live edit differs](parity-fixes.md#saved-image-inputs-and-automatic-filtering-in-tile-random) · [Previous comparison · 111,207/142,592 pixels across 19 settings on both processor counts and ordinary reopen](parity-fixes.md#returned-vectors-in-pattern-properties) · [Previous comparison · 111,364/142,592 across 19 established settings, four ordinary saves compared](parity-fixes.md#whole-caustic-scratch-splatter-tile-and-vertical-noise-comparisons) · [Earlier comparison · 111,364/142,592 whole pixels, first differing stages measured](parity-fixes.md#tile-weave-splatter-and-fiber-stage-comparisons) · [saved authored and disc branches each match 4,864/4,864](parity-fixes.md#tile-weave-splatter-and-fiber-stage-comparisons) · [Stamp-width recheck](parity-fixes.md#pixel-reciprocals-for-stamp-edge-widths) · [Seed offsets on the initial iterator branch](parity-fixes.md#the-incoming-seed-on-the-initial-branch-of-an-iterate) |
|
||||
| [tile_random.sbs/tile_random_color](../assets/sbs/tile_random.sbs) | 2 | Yes | [In progress · 207,104/207,104 color pixels in 76 freshly bound settings, one live edit differs](parity-fixes.md#saved-image-inputs-and-automatic-filtering-in-tile-random) · [Previous comparison · 111,194/142,592 pixels across 19 settings on both processor counts and ordinary reopen](parity-fixes.md#returned-vectors-in-pattern-properties) · [Previous comparison · 111,228/142,592 across 19 established settings, four ordinary saves compared](parity-fixes.md#whole-caustic-scratch-splatter-tile-and-vertical-noise-comparisons) · [Earlier comparison · 111,228/142,592 whole pixels, first differing stages measured](parity-fixes.md#tile-weave-splatter-and-fiber-stage-comparisons) · [saved authored and disc branches each match 4,864/4,864](parity-fixes.md#tile-weave-splatter-and-fiber-stage-comparisons) · [Stamp-width recheck](parity-fixes.md#pixel-reciprocals-for-stamp-edge-widths) · [Seed offsets on the initial iterator branch](parity-fixes.md#the-incoming-seed-on-the-initial-branch-of-an-iterate) |
|
||||
| [tile_sampler.sbs/arrow](../assets/sbs/tile_sampler.sbs) | 0 | Yes | [Parity · seven 512×512 runs, four formats](parity-fixes.md#transform-edges-and-floating-point-filtering) |
|
||||
| [tileable_material_to_mesh_material.sbs/tileable_material_to_mesh_material](../assets/sbs/tileable_material_to_mesh_material.sbs) | 5 | No | [Parity · both outputs, 358,912 exact pixels in 42 renders](parity-fixes.md#diffuse-and-specular-outputs-of-the-mesh-material-graph) |
|
||||
| [trapezoid_transform.sbs/trapezoid_transform](../assets/sbs/trapezoid_transform.sbs) | 1 | No | [Parity · 848,384 exact pixels in 68 renders across four formats](parity-fixes.md#trapezoid-coordinates-under-fixed-clipping) |
|
||||
|
||||
Reference in new issue
Block a user