mirror of
https://github.com/storytold/materialcraft.git
synced 2026-11-28 17:19:17 +01:00
Merge latest SBS branch improvements
Preserve resource and rendering fixes alongside updated library previews, node UI, and function input support. Reconcile evaluator state and loop caching while retaining both sets of regression tests.
This commit is contained in:
commit
46802a44fc
38 files changed
+1162
-96
No files matched your search
@@ -12,7 +12,9 @@ pub(crate) fn evaluate(
|
||||
) -> Result<Value, String> {
|
||||
let program = compile(function, seed)?;
|
||||
let scalar_channel = allow_scalar && expected == ValueType::Float4 && program.output_type() == ValueType::Float as u32;
|
||||
if program.output_type() != expected as u32 && !scalar_channel {
|
||||
// A color parameter also takes a gray level or an opaque RGB triple.
|
||||
let widened = expected == ValueType::Float4 && [ValueType::Float as u32, ValueType::Float3 as u32].contains(&program.output_type());
|
||||
if program.output_type() != expected as u32 && !scalar_channel && !widened {
|
||||
return Err(format!("output must be {}", expected.label()));
|
||||
}
|
||||
|
||||
@@ -30,6 +32,12 @@ pub(crate) fn evaluate(
|
||||
return Err("function returned a non-finite value".into());
|
||||
}
|
||||
|
||||
let value = match value {
|
||||
Value::Float(level) if !scalar_channel && widened => Value::Float4([level, level, level, 1.0]),
|
||||
Value::Float3([red, green, blue]) if widened => Value::Float4([red, green, blue, 1.0]),
|
||||
value => value,
|
||||
};
|
||||
|
||||
variables.extend(state.assignments().clone());
|
||||
|
||||
Ok(value)
|
||||
|
||||
Reference in new issue
Block a user