Retain sampling levels for edited image stamps

This commit is contained in:
chasse20 committed 2026-11-27 10:02:55 -05:00
1 parent fceee4d7f6
commit 19970f2e1e
13 files changed
+294 -20

No files matched your search

+24 -3
View File
@@ -2,7 +2,7 @@ use std::collections::{BTreeMap, BTreeSet};
use std::sync::{Arc, Mutex};
use materialcraft_core::Package;
use materialcraft_eval::{Cache, Cooked, Options};
use materialcraft_eval::{Cache, Cooked, Options, PreviewSampling};
/// One background result for the editor and the assigned material sources
#[derive(Default)]
@@ -14,13 +14,34 @@ pub struct PreviewCook {
impl PreviewCook {
pub fn run(package: &Package, graph: usize, materials: &BTreeSet<usize>, options: &Options<'_>, cache: &Arc<Mutex<Cache>>) -> Self {
let mut result = Self { graph, cooked: materialcraft_eval::cook(package, graph, options, cache), materials: BTreeMap::new() };
Self::with_previous(package, graph, materials, options, cache, &BTreeMap::new())
}
pub fn with_previous(
package: &Package,
graph: usize,
materials: &BTreeSet<usize>,
options: &Options<'_>,
cache: &Arc<Mutex<Cache>>,
previous: &BTreeMap<usize, Arc<PreviewSampling>>,
) -> Self {
let empty = PreviewSampling::default();
let cook = |index| {
let mut options = options.clone();
options.previous_sampling = Some(previous.get(&index).map_or(&empty, Arc::as_ref));
let mut cooked = materialcraft_eval::cook(package, index, &options, cache);
if cooked.nodes.values().any(|node| node.error.is_some()) {
cooked.preview_sampling = previous.get(&index).cloned();
}
cooked
};
let mut result = Self { graph, cooked: cook(graph), materials: BTreeMap::new() };
for &index in materials {
if result.cancelled() {
break;
}
if index != graph && package.graphs.get(index).is_some() {
result.materials.insert(index, materialcraft_eval::cook(package, index, options, cache));
result.materials.insert(index, cook(index));
}
}
result
+33 -1
View File
@@ -1,6 +1,7 @@
//! The session: the open package, the graph being edited, selection, views, snapshot undo and
//! the cook cache.
use std::collections::BTreeMap;
use std::sync::{Arc, Mutex, PoisonError};
use craft_texture::Image;
@@ -251,6 +252,7 @@ impl Session {
if let Some((snap, edited)) = self.group.take()
&& edited
{
self.reset_changed_sampling(&snap.pkg);
self.history.record(snap, None, self.history_prefs.undo_limit as usize);
self.refresh_links();
}
@@ -295,6 +297,7 @@ impl Session {
if let Some((_, edited)) = self.group.as_mut() {
*edited = true;
} else {
self.reset_changed_sampling(&snapshot.pkg);
self.history.record(snapshot, key, self.history_prefs.undo_limit as usize);
}
self.changed();
@@ -353,6 +356,7 @@ impl Session {
let s = self.history.undo(self.snapshot(""), self.history_prefs.undo_limit as usize)?;
let label = s.label.clone();
self.reset_changed_sampling(&s.pkg);
self.restore(s);
self.finish_edit();
self.dirty = true;
@@ -368,6 +372,7 @@ impl Session {
let s = self.history.redo(self.snapshot(""), self.history_prefs.undo_limit as usize)?;
let label = s.label.clone();
self.reset_changed_sampling(&s.pkg);
self.restore(s);
self.finish_edit();
self.dirty = true;
@@ -420,13 +425,40 @@ impl Session {
self.decoded = Arc::new(Mutex::new(crate::decoded_images::DecodedImages::new(16 << 20)));
}
// An extent or seed edit releases acquired input textures even if another edit restores
// the original value before the next preview. A grouped edit publishes only once.
fn reset_changed_sampling(&mut self, other: &Package) {
let context = |package: &Package, index: usize| package.graphs.get(index).map(|g| (g.size, g.seed, g.seed_mode));
let reset = |index, cooked: &mut Cooked| {
if cooked.preview_sampling.is_some() && context(&self.pkg, index) != context(other, index) {
cooked.preview_sampling = None;
}
};
if let Some(index) = self.cooked_graph {
reset(index, &mut self.cooked);
}
for (&index, cooked) in &mut self.material_cooked {
reset(index, cooked);
}
}
/// Take the sampling history from published graph previews before starting another cook.
pub fn preview_sampling(&self) -> BTreeMap<usize, Arc<materialcraft_eval::PreviewSampling>> {
self.cooked_graph
.into_iter()
.map(|graph| (graph, &self.cooked))
.chain(self.material_cooked.iter().map(|(&graph, cooked)| (graph, cooked)))
.filter_map(|(graph, cooked)| cooked.preview_sampling.clone().map(|sampling| (graph, sampling)))
.collect()
}
/// Cook the open graph now (at the preview size), on this thread.
pub fn cook(&mut self) -> &Cooked {
let dec = self.resource_decoder();
let mut opts = Options::new(&dec);
opts.environment = self.environment;
opts.max_size = self.preview_size;
let cooked = crate::PreviewCook::run(&self.pkg, self.graph, &self.material_preview.graphs(), &opts, &self.cache);
let cooked = crate::PreviewCook::with_previous(&self.pkg, self.graph, &self.material_preview.graphs(), &opts, &self.cache, &self.preview_sampling());
self.accept_preview(cooked);
self.dirty = false;
self.cook_epoch = self.cook_epoch.wrapping_add(1);
+65
View File
@@ -23,6 +23,71 @@ fn the_resource_decoder_reads_data_maps_as_stored() {
assert!((data.get(0, 0, false)[2] - 1.0).abs() < 0.01);
}
#[test]
fn preview_stamps_reuse_sampling_levels_independently() {
use materialcraft_core::{Graph, OutputFormat, PatternGraph, PatternNodeKind, ResourceBytes, SizeMode, Value};
let image = Image::gray(128, 128, |x, y| ((13 * x + 7 * y + 3 * x * y) % 253) as f32 / 255.0);
let bytes = ResourceBytes::new(encode(&image, "png", Depth::U8, false).unwrap());
let mut package = Package::new("Stamp sampling");
for name in ["Field", "Copy"] {
package.resources.push(Resource::new(name, format!("{name}.png"), bytes.clone()));
}
let mut graph = Graph::new("Shared image");
graph.size = [5; 2];
graph.format = OutputFormat::F32;
let input = graph.add_node("input_grayscale", [0.0; 2]);
let base = &mut graph.node_mut(input).unwrap().base;
base.size_mode = SizeMode::Absolute;
base.size = [5; 2];
base.format = OutputFormat::U8;
graph.input_images.insert("input".into(), "Field".into());
graph.input_images_linear.insert("input".into());
let stamps = [0.0, 80.0].map(|y| {
let id = graph.add_node("fx_map", [100.0, y]);
let mut pattern = PatternGraph::with_root(PatternNodeKind::Quadrant);
pattern.nodes[0].parameters.insert("patterntype".into(), Value::Int(1));
pattern.nodes[0].parameters.insert("patternsize".into(), Value::Float2([0.5; 2]));
let node = graph.node_mut(id).unwrap();
node.base.format = OutputFormat::F32;
node.params.insert("color_mode".into(), Value::Bool(false));
node.params.insert("roughness".into(), Value::Float(0.0));
node.params.insert("pattern".into(), Value::PatternGraph(Box::new(pattern)));
graph.connect(input, "output", id, "pattern0").unwrap();
id
});
package.graphs.push(graph);
let mut session = Session::new(package);
let base = 0x3f01_4181;
let mip = 0x3f01_8182;
let pixels = |cook: &materialcraft_eval::Cooked| {
stamps.map(|id| {
assert_eq!(cook.nodes[&id].error, None);
cook.image(id, 0).unwrap().get_gray(9, 8, false).to_bits()
})
};
assert_eq!(pixels(session.cook()), [base; 2]);
let change_precision = |session: &mut Session| {
for format in ["u16", "f32"] {
crate::execute(session, "graph.node.base", &serde_json::json!({"id":stamps[0].0,"format":format})).unwrap();
session.cook();
}
};
change_precision(&mut session);
assert_eq!(pixels(session.cook()), [mip, base], "only the edited stamp reacquires its input levels");
crate::execute(&mut session, "graph.size", &serde_json::json!({"width":32})).unwrap();
assert_eq!(pixels(session.cook()), [mip, base]);
assert_eq!(pixels(&session.cook_full(0)), [base; 2]);
for extent in [64, 32] {
crate::execute(&mut session, "graph.size", &serde_json::json!({"width":extent})).unwrap();
}
assert_eq!(pixels(session.cook()), [base; 2]);
change_precision(&mut session);
assert_eq!(pixels(session.cook()), [mip, base]);
crate::execute(&mut session, "graph.input.bind", &serde_json::json!({"identifier":"input","resource":"Copy","linear":true})).unwrap();
assert_eq!(pixels(session.cook()), [base; 2]);
}
#[test]
fn bitmap_nodes_read_default_colors_from_the_file_and_keep_explicit_data_reads() {
use materialcraft_core::{Graph, OutputFormat, ResourceBytes, Value};
+1
View File
@@ -7,6 +7,7 @@ use std::collections::BTreeMap;
#[derive(Clone, Debug, Default)]
pub struct Cooked {
pub nodes: BTreeMap<NodeId, NodeResult>,
pub preview_sampling: Option<std::sync::Arc<crate::PreviewSampling>>,
/// Total wall time of the cook in milliseconds
pub ms: f32,
pub cancelled: bool,
+7 -1
View File
@@ -26,6 +26,9 @@ pub fn cook(package: &Package, graph_index: usize, options: &Options, cache: &Mu
let variables = graph_variables(graph, options);
let prepared = PreparedGraph::new(package, graph, options, &variables);
let mut sampling = crate::PreviewSampling::default();
sampling.context = (prepared.parent_base.size, prepared.parent_base.seed, options.max_size);
let previous = options.previous_sampling.filter(|p| p.context == sampling.context);
for &id in &prepared.order {
if options.cancel.is_some_and(|cancel| cancel.load(Ordering::Relaxed)) {
cooked.cancelled = true;
@@ -34,10 +37,13 @@ pub fn cook(package: &Package, graph_index: usize, options: &Options, cache: &Mu
let Some(node) = prepared.index.node(id) else { continue };
let result = cook_node(package, graph_index, &prepared, node, &cooked, &variables, options, cache);
let result = cook_node(package, graph_index, &prepared, node, &cooked, &variables, options, cache, previous, &mut sampling);
cooked.nodes.insert(id, result);
}
cooked.ms = (now_ms() - started_ms) as f32;
if !sampling.is_empty() && !cooked.cancelled && cooked.nodes.values().all(|result| result.error.is_none()) {
cooked.preview_sampling = Some(std::sync::Arc::new(sampling));
}
cooked
}
+22 -4
View File
@@ -36,6 +36,11 @@ pub(crate) fn instances_reach(pkg: &Package, from: usize, target: usize) -> bool
false
}
pub(crate) struct CookedInstance {
pub ports: Vec<(NodeOutput, crate::ResolvedBaseParameters)>,
pub sampling: Option<(std::sync::Arc<crate::PreviewSampling>, u64)>,
}
pub(crate) fn cook_instance(
package: &Package,
graph_index: usize,
@@ -43,12 +48,14 @@ pub(crate) fn cook_instance(
input_ports: &[Port],
output_ports: &[Port],
inputs: &[Option<(&NodeOutput, crate::ResolvedBaseParameters)>],
input_keys: &[u64],
params: &BTreeMap<String, Value>,
fixed: &[String],
base: crate::resolved_base_parameters::ResolvedBaseParameters,
options: &Options,
cache: &Mutex<Cache>,
) -> Result<Vec<(NodeOutput, crate::ResolvedBaseParameters)>, String> {
previous: Option<&crate::PreviewSampling>,
) -> Result<CookedInstance, String> {
if options.depth >= MAX_DEPTH {
return Err("graph instances nest too deep (does a graph use itself?)".into());
}
@@ -73,6 +80,8 @@ pub(crate) fn cook_instance(
_ => (options.resource)(name),
};
let mut source_options = Options::new(&resource);
let empty = crate::PreviewSampling::default();
source_options.previous_sampling = options.previous_sampling.map(|_| previous.unwrap_or(&empty));
source_options.environment = options.environment;
source_options.parent_tiling = Some(base.tiling);
source_options.parent_pixel_ratio = Some(base.pixel_ratio);
@@ -92,7 +101,7 @@ pub(crate) fn cook_instance(
source_options.literal_inputs.push(name.clone());
}
}
for (port, input) in input_ports.iter().zip(inputs) {
for ((port, input), &key) in input_ports.iter().zip(inputs).zip(input_keys) {
// A stored argument drives its bridge even when the same port has a wire.
if let Some(expected) = port.value_type
&& (node.params.contains_key(&port.id) || node.bindings.contains_key(&port.id) || node.functions.contains_key(&port.id))
@@ -112,6 +121,9 @@ pub(crate) fn cook_instance(
source_options.input_bases.insert(port.id.clone(), *source_base);
if matches!(output, NodeOutput::BaseLevel(_)) {
source_options.base_level_inputs.insert(port.id.clone());
if source_options.previous_sampling.is_some() {
source_options.preview_input_keys.insert(port.id.clone(), key);
}
}
} else if let Some(value) = output.as_value() {
source_options.overrides.insert(port.id.clone(), value.clone());
@@ -127,7 +139,8 @@ pub(crate) fn cook_instance(
return Err(format!("{}: {error}", source_graph.name));
}
output_ports
let mut keys = Vec::new();
let ports = output_ports
.iter()
.map(|port| {
let result = source_graph
@@ -137,9 +150,14 @@ pub(crate) fn cook_instance(
.and_then(|node| cooked.nodes.get(&node.id))
.ok_or_else(|| format!("the source output `{}` is missing", port.id))?;
let output = result.outputs.first().ok_or_else(|| format!("the source output `{}` is empty", port.id))?;
if cooked.preview_sampling.is_some() {
keys.push(result.key);
}
// Images carry their source properties across the boundary. The caller owns the random seed.
let port_base = crate::ResolvedBaseParameters { seed: base.seed, ..result.base };
Ok((output.clone(), port_base))
})
.collect()
.collect::<Result<_, String>>()?;
let sampling = cooked.preview_sampling.map(|state| (state, crate::cache_key::hash_of(&keys)));
Ok(CookedInstance { ports, sampling })
}
+2
View File
@@ -20,6 +20,7 @@ mod parameter_function;
mod port;
mod ports;
mod prepared_graph;
mod preview_sampling;
mod resolved_base_parameters;
mod resource_decoder;
mod time;
@@ -37,6 +38,7 @@ pub use node_size::node_size;
pub use options::Options;
pub use port::Port;
pub use ports::{identifier, instance_graph, ports, ports_with_connections};
pub use preview_sampling::PreviewSampling;
pub use resolved_base_parameters::ResolvedBaseParameters;
pub use resource_decoder::ResourceDecoder;
pub use time::now_ms;
+42 -3
View File
@@ -53,6 +53,8 @@ pub(crate) fn cook_node(
graph_variables: &BTreeMap<String, Value>,
options: &Options,
cache: &Mutex<Cache>,
previous: Option<&crate::PreviewSampling>,
sampling: &mut crate::PreviewSampling,
) -> NodeResult {
let (input_ports, output_ports) = prepared.ports(node.id);
let definition = find(&node.def);
@@ -251,7 +253,7 @@ pub(crate) fn cook_node(
0
};
let key = hash_of(&(
let mut key = hash_of(&(
&node.def,
serde_json::to_string(&parameters).unwrap_or_default(),
(dynamic_blend_opacity, bound_image, background_tiling),
@@ -277,6 +279,24 @@ pub(crate) fn cook_node(
input_image.as_ref().map(|(image, upstream, bitmap, base_level)| (image_key(image, cache), upstream, bitmap, wired, base_level)),
(variable_key(node, &parameters, &bindings), &instance_literals),
));
if options.previous_sampling.is_some() && input_image.is_some() {
let name = identifier(node);
if let Some(&upstream) = options.preview_input_keys.get(&name) {
key = hash_of(&(key, upstream));
} else if let Some(graph) = package.graphs.get(graph_index)
&& let Some(binding) = graph.input_images.get(&name)
{
key = hash_of(&(key, binding, graph.input_images_linear.contains(&name), graph.input_images_from_file.contains(&name)));
}
}
let instance_input_key = key;
if options.previous_sampling.is_some() && !node.disabled {
if node.def == "graph_instance" {
key = sampling.reuse_instance(previous, node.id, key);
} else if node.def == "fx_map" && base_level_only.contains(&true) {
key = sampling.stamp(previous, node.id, key, &input_keys, &mut base_level_only);
}
}
if let Some(outputs) = lock(cache).get(key) {
inspection_parameters(node, &mut parameters);
let base = outputs.bases.as_deref().and_then(|ports| ports.first()).copied().unwrap_or(base);
@@ -326,8 +346,27 @@ pub(crate) fn cook_node(
Err(format!("unsupported node `{name}`"))
} else if node.def == "graph_instance" {
cook_instance(package, graph_index, node, input_ports, output_ports, &incoming, &parameters, &instance_literals, base, options, cache).map(|ports| {
let (values, bases): (Vec<_>, Vec<_>) = ports.into_iter().unzip();
cook_instance(
package,
graph_index,
node,
input_ports,
output_ports,
&incoming,
&input_keys,
&parameters,
&instance_literals,
base,
options,
cache,
previous.and_then(|p| p.child(node.id)),
)
.map(|instance| {
if let Some((child, outputs)) = instance.sampling {
key = hash_of(&(instance_input_key, outputs));
sampling.record_instance(node.id, instance_input_key, key, child);
}
let (values, bases): (Vec<_>, Vec<_>) = instance.ports.into_iter().unzip();
output_bases = Some(bases.into());
values
})
+6
View File
@@ -4,6 +4,7 @@ use std::collections::{BTreeMap, BTreeSet};
use std::sync::atomic::AtomicBool;
/// What to cook and how
#[derive(Clone)]
pub struct Options<'a> {
pub environment: materialcraft_core::EvaluationEnvironment,
pub parent_tiling: Option<[bool; 2]>,
@@ -21,6 +22,9 @@ pub struct Options<'a> {
pub input_bases: BTreeMap<String, crate::ResolvedBaseParameters>,
/// Caller textures which have only their base level when passed through an instance.
pub base_level_inputs: BTreeSet<String>,
/// Previously accepted samples for this editor graph. Full cooks start without editor state.
pub previous_sampling: Option<&'a crate::PreviewSampling>,
pub(crate) preview_input_keys: BTreeMap<String, u64>,
/// Original storage of decoded external files. Wired graph inputs use their upstream format.
pub bitmap_formats: BTreeMap<String, OutputFormat>,
/// Values for the graph's exposed parameters (graph instances), over the graph's own
@@ -52,6 +56,8 @@ impl<'a> Options<'a> {
input_formats: BTreeMap::new(),
input_bases: BTreeMap::new(),
base_level_inputs: BTreeSet::new(),
previous_sampling: None,
preview_input_keys: BTreeMap::new(),
bitmap_formats: BTreeMap::new(),
overrides: BTreeMap::new(),
literal_inputs: Vec::new(),
+68
View File
@@ -0,0 +1,68 @@
use crate::cache_key::hash_of;
use materialcraft_core::NodeId;
use std::{collections::BTreeMap, sync::Arc};
/// Sampling state from one accepted preview. A graph instance owns its child state.
#[derive(Clone, Debug, Default)]
pub struct PreviewSampling {
pub(crate) context: ([u32; 2], u32, Option<u32>),
stamps: BTreeMap<NodeId, Stamp>,
instances: BTreeMap<NodeId, Instance>,
}
#[derive(Clone, Debug)]
struct Stamp {
cook_key: u64,
// Each port keeps the acquired texture identity and whether it used the full mip chain.
inputs: BTreeMap<usize, (u64, bool)>,
}
#[derive(Clone, Debug)]
pub(crate) struct Instance {
input_key: u64,
pub output_key: u64,
pub sampling: Arc<PreviewSampling>,
}
impl PreviewSampling {
pub(crate) fn is_empty(&self) -> bool {
self.stamps.is_empty() && self.instances.is_empty()
}
pub(crate) fn child(&self, id: NodeId) -> Option<&PreviewSampling> {
self.instances.get(&id).map(|state| state.sampling.as_ref())
}
pub(crate) fn reuse_instance(&mut self, previous: Option<&Self>, id: NodeId, input_key: u64) -> u64 {
if let Some(state) = previous.and_then(|p| p.instances.get(&id)).filter(|s| s.input_key == input_key) {
self.instances.insert(id, state.clone());
state.output_key
} else {
// Only an instance whose previous evaluation found no retained samplers can hit this key.
hash_of(&(input_key, "preview without sampled bridges"))
}
}
pub(crate) fn record_instance(&mut self, id: NodeId, input_key: u64, output_key: u64, sampling: Arc<Self>) {
self.instances.insert(id, Instance { input_key, output_key, sampling });
}
pub(crate) fn stamp(&mut self, previous: Option<&Self>, id: NodeId, cook_key: u64, input_keys: &[u64], base_only: &mut [bool]) -> u64 {
let previous = previous.and_then(|p| p.stamps.get(&id));
let mut inputs = BTreeMap::new();
let mut full = Vec::new();
for (port, (base_only, &texture)) in base_only.iter_mut().zip(input_keys).enumerate() {
if *base_only {
let retained =
previous.is_some_and(|stamp| stamp.inputs.get(&port).is_some_and(|&(old, full)| old == texture && (full || stamp.cook_key != cook_key)));
inputs.insert(port, (texture, retained));
if retained {
*base_only = false;
full.push(port);
}
}
}
self.stamps.insert(id, Stamp { cook_key, inputs });
if full.is_empty() { cook_key } else { hash_of(&(cook_key, full)) }
}
}
+2 -1
View File
@@ -139,6 +139,7 @@ fn start(app: &mut MaterialCraftApp, now: f64) {
let (gi, max) = (s.graph, s.preview_size);
let environment = s.environment;
let materials = s.material_preview.graphs();
let sampling = s.preview_sampling();
let cache = s.cache.clone();
let epoch = s.cook_epoch;
let dec = s.resource_decoder();
@@ -151,7 +152,7 @@ fn start(app: &mut MaterialCraftApp, now: f64) {
opts.environment = environment;
opts.max_size = max;
opts.cancel = Some(&thread_flag);
let cooked = guard("cook", || Ok(PreviewCook::run(&pkg, gi, &materials, &opts, &cache)));
let cooked = guard("cook", || Ok(PreviewCook::with_previous(&pkg, gi, &materials, &opts, &cache, &sampling)));
let _ = tx.send(cooked);
});
match spawned {
+17 -2
View File
@@ -185,7 +185,22 @@ Use the two 128² procedural byte fields and half-size image stamp above. Give t
The direct reference result agrees with the base-level sample on the first render at each new extent and with the full mip chain after each precision change. Across 24 comparisons, these two paths account for **36,864/36,864 F32 pixels** and **18,432/18,432 U16 pixels**, maximum zero on one and eight processors. With the 32 × 64 bridge and 64 × 32 output, continuing to sample the base level on the second render gives 1,538/2,048 U16 pixels, maximum 23,644 levels. Temporarily setting a rectangular output to a square and back during a precision change starts a new extent and changes the result. Reapplying the same precision at the same extent before any other edit retained the initial 32² F32 output in the square control.
Selecting between the two sampling paths offline also reproduces all 484,864 pixels of the earlier 221 sequential root settings. MaterialCraft's ordinary editor preview still uses the fresh-render path for both live background edits. The two roots remain in progress.
Selecting between the two sampling paths offline also reproduces all 484,864 pixels of the earlier 221 sequential root settings. The editor at the time used the fresh-render path for both live background edits. The [live preview measurements](#live-preview-sampling-in-tile-random) record the correction.
### Live preview sampling in Tile Random
Open each root once and keep the same editing session for every render. Reuse the same imported resource whenever a procedural input path recurs. Apply the exposed values, seed, extent and storage format from the [221 whole-root settings](#integer-assignments-read-by-pattern-seeds) in sequence. For rectangular cases set the parent to the square width first, then to the requested height. Repeat the sequence after opening an ordinary MaterialCraft save. Compare whole stored pixels to independent reference captures at one and eight processors. The reference captures at those processor counts also agree with each other.
| Root | Settings | Previous exact pixels | Exact pixels after live edits | Maximum F32 error before → after |
|---|---:|---:|---:|---:|
| Tile Random | 145 | 276,740/277,760 | 277,760/277,760 | .267032921 → 0 |
| Tile Random Color | 76 | 206,080/207,104 | 207,104/207,104 | .416119799 → 0 |
The original and reopened editing sessions give the same counts. U8, U16, F16 and F32 each match every stored pixel. Repeating the sequence with a fresh resource path per setting also matches 484,864/484,864. The 32 configured files opened and read before any edit give 106,496/106,496 exact pixels. The two other qualified random-tile roots retain 180,224/180,224 across 52 independent controls. [Pixel counts by format, procedural inputs and configured-file settings](#saved-image-inputs-and-automatic-filtering-in-tile-random)
The editor records which texture each image stamp sampled in the last published preview. When an edit changes a stamp while retaining that texture, its next draw can sample the mip chain. A new binding, seed or parent extent starts a fresh acquisition. The isolated consumer gives 17,664/17,664 exact pixels, two stamps sharing a texture give 25,088/25,088 across both outputs, and fixed seed and size controls give 33,792/33,792. Maximum error is zero in all three comparisons. The regression reads F32 pixel (9,8) in two half-size stamps. Editing one stamp from F32 to U16 and back changes its word from `0x3f014181` to `0x3f018182` while the other remains at its first word. A full cook and an edit from 32² to 64² and back before preview both give the first word for both stamps. [Probe settings](#filtering-after-independent-edits-to-stamps-sharing-an-image) · [Editor regression](../crates/engine/src/session.test.rs)
A separate non-root control puts the same fixed 32² F32 child stamp inside two graph instances, wires the same 32² U8 bridge to both, and wires the background only to the first. Change the first instance’s precision while leaving its child at F32. Across 13 paired renders the editor matches 25,860/26,624, up from 25,478. Four precision edits on the first instance each give 833/1,024, maximum .00196844339. Every sibling output matches. With inherited child size and precision, 25 comparable outputs match all 25,600 U8 pixels. With a 16² parent and a 32² stamp input, the reference returns 16² for the instance with both wires and 32² for its sibling. MaterialCraft returns 32² for both.
### Filtering after independent edits to stamps sharing an image
@@ -195,7 +210,7 @@ Recomputing identical settings retains the first image. Changing the graph seed,
Add a second stamp and output to the same graph. Both stamps sample the same pattern bridge. Connect the background only to the first stamp. Change only the first stamp's output precision to U16 and back. The first stamp now matches the full chain. The second still matches the base level on all 1,024 pixels. Adding the background to the first stamp also leaves the second at the base level. The two outputs together give 23,942/25,088 for the fresh path alone. The sampling modes account for 25,088/25,088 at one and eight processors, maximum zero, across 13 paired renders.
Finally run the seed, size and precision changes in four graphs. Independently give the stamp a fixed seed of 71 and absolute size 32², and give the pattern bridge a fixed seed of 71. Use graph seeds 6621, 6622 and 6623, with parent extents 32² and 16². Changing the parent seed or extent restores base-level sampling even in the graph with both overrides, where the pattern, stamp dimensions and their own seeds stay fixed. Across 36 renders the two measured paths account for 33,792/33,792, maximum zero, compared with 30,992/33,792 from the fresh path alone. The editor comparison for the two Tile Random roots stays open.
Finally run the seed, size and precision changes in four graphs. Independently give the stamp a fixed seed of 71 and absolute size 32², and give the pattern bridge a fixed seed of 71. Use graph seeds 6621, 6622 and 6623, with parent extents 32² and 16². Changing the parent seed or extent restores base-level sampling even in the graph with both overrides, where the pattern, stamp dimensions and their own seeds stay fixed. Across 36 renders the two measured paths account for 33,792/33,792, maximum zero, compared with 30,992/33,792 from the fresh path alone. The [subsequent editor replay](#live-preview-sampling-in-tile-random) covers both whole roots.
### Integer assignments read by pattern seeds
+5 -5
View File
@@ -35,15 +35,15 @@ A graph may accept input pins and still be a root under the dependency criterion
Statuses: **Not checked**, **In progress**, **Parity** (exact pixels or typed values for the linked measured cases), or **Too hard** (reason recorded). Function calls do not count as regular graph dependencies.
The first pass covered all **546 roots**, with **166 Parity** and **380 Too hard**. The current inventory has **492 Parity (90.1%)**, **54 In progress** and **0 Too hard**. The first eleven open roots match every pixel across 1,059 recorded single-processor settings. Each still differs in at least one eight-processor capture. The November 17–27 comparisons give raw counts, output formats and remaining differences. [November 17 measurements](parity-fixes.md#2026-11-17-root-comparisons) · [November 18 measurements](parity-fixes.md#2026-11-18-root-comparisons) · [November 19 measurements](parity-fixes.md#2026-11-19-root-comparisons) · [November 20 measurements](parity-fixes.md#2026-11-20-root-comparisons) · [November 21 measurements](parity-fixes.md#2026-11-21-root-comparisons) · [November 22 measurements](parity-fixes.md#2026-11-22-root-comparisons) · [November 23 measurements](parity-fixes.md#2026-11-23-root-comparisons) · [November 24 measurements](parity-fixes.md#2026-11-24-root-comparisons) · [November 25 measurements](parity-fixes.md#2026-11-25-root-comparisons) · [November 26 measurements](parity-fixes.md#2026-11-26-root-comparisons) · [November 27 measurements](parity-fixes.md#2026-11-27-root-comparisons)
The first pass covered all **546 roots**, with **166 Parity** and **380 Too hard**. The current inventory has **494 Parity (90.5%)**, **52 In progress** and **0 Too hard**. The first eleven open roots match every pixel across 1,059 recorded single-processor settings. Each still differs in at least one eight-processor capture. The November 17–27 comparisons give raw counts, output formats and remaining differences. [November 17 measurements](parity-fixes.md#2026-11-17-root-comparisons) · [November 18 measurements](parity-fixes.md#2026-11-18-root-comparisons) · [November 19 measurements](parity-fixes.md#2026-11-19-root-comparisons) · [November 20 measurements](parity-fixes.md#2026-11-20-root-comparisons) · [November 21 measurements](parity-fixes.md#2026-11-21-root-comparisons) · [November 22 measurements](parity-fixes.md#2026-11-22-root-comparisons) · [November 23 measurements](parity-fixes.md#2026-11-23-root-comparisons) · [November 24 measurements](parity-fixes.md#2026-11-24-root-comparisons) · [November 25 measurements](parity-fixes.md#2026-11-25-root-comparisons) · [November 26 measurements](parity-fixes.md#2026-11-26-root-comparisons) · [November 27 measurements](parity-fixes.md#2026-11-27-root-comparisons)
Writable quadrant tints now match 16,896/16,896 pixels in 44 settings across four output formats, up from 4,608. Fixed and published inputs through a graph instance match 3,840/3,840 original and 3,840/3,840 reopened pixels. Connected image properties match all 18,432 original and all 18,432 reopened pixels across 32 settings, up from 15,168 on each side. Live float4 and integer initial values remain open. The earlier explicit undefined-tint controls covered 70,656 pixels across original squares, ordinary saves, Gaussian and ramp shapes and connected images. [Connected images](parity-fixes.md#connected-image-properties-and-the-first-quadrant-draw) · [Writable floats](parity-fixes.md#first-reads-of-writable-quadrant-floats) · [Explicit undefined tints](parity-fixes.md#undefined-components-in-a-computed-quadrant-tint)
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)
At least **50 of the 54 open roots** have two different reference outputs for the same graph settings on one and eight processors. This includes the first eleven open roots, 31 later noise roots and eight moisture, caustic, scratch and fiber roots. Two 64² settings also varied across repeated eight-processor reads at the same seed. MaterialCraft still misses one invariant pixel in that moisture setting and two in the fiber setting. [31-root comparison by format](parity-fixes.md#reference-repeatability-across-31-open-noise-roots) · [Eight further roots and fixed-processor repeats](parity-fixes.md#reference-variation-in-eight-further-roots)
At least **50 of the 52 open roots** have two different reference outputs for the same graph settings on one and eight processors. This includes the first eleven open roots, 31 later noise roots and eight moisture, caustic, scratch and fiber roots. Two 64² settings also varied across repeated eight-processor reads at the same seed. MaterialCraft still misses one invariant pixel in that moisture setting and two in the fiber setting. [31-root comparison by format](parity-fixes.md#reference-repeatability-across-31-open-noise-roots) · [Eight further roots and fixed-processor repeats](parity-fixes.md#reference-variation-in-eight-further-roots)
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. Four editor-bound gray and color inputs also survive a file handoff with 1,024/1,024 U8 pixels exact. Keeping the pattern connected while changing the background still gives a different result in one setting per root. At fixed stamp and bridge dimensions, 24 comparisons isolate when the reference preview starts using the retained input’s full mip chain. [Retained input comparisons](parity-fixes.md#sampling-a-retained-input-after-an-editor-change) [Per-format counts, filter controls and exact edit sequence](parity-fixes.md#saved-image-inputs-and-automatic-filtering-in-tile-random)
Both roots in `tile_random.sbs` now match 484,864/484,864 pixels across 221 settings with either live edits or freshly bound images. Each setting matches one and eight reference processors. Replaying the edits on ordinary saves also matches every pixel. All 32 preconfigured files opened directly with 106,496/106,496 pixels exact. Maximum error is zero on every route. [Whole-root counts, edit sequence and remaining instance differences](parity-fixes.md#live-preview-sampling-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)
@@ -755,8 +755,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 · 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) · [Independent filtering at two stamps sharing one image](parity-fixes.md#filtering-after-independent-edits-to-stamps-sharing-an-image) · [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) · [Independent filtering at two stamps sharing one image](parity-fixes.md#filtering-after-independent-edits-to-stamps-sharing-an-image) · [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 | [Parity · 277,760/277,760 grayscale pixels in 145 settings with live edits, fresh inputs and ordinary reopen](parity-fixes.md#live-preview-sampling-in-tile-random) · [Independent filtering at two stamps sharing one image](parity-fixes.md#filtering-after-independent-edits-to-stamps-sharing-an-image) · [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 | [Parity · 207,104/207,104 color pixels in 76 settings with live edits, fresh inputs and ordinary reopen](parity-fixes.md#live-preview-sampling-in-tile-random) · [Independent filtering at two stamps sharing one image](parity-fixes.md#filtering-after-independent-edits-to-stamps-sharing-an-image) · [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) |