SolidCraft: an open-source parametric 3D CAD application built in pure Rust. Desktop, web, and automation through MCP.
Render: a preview setup with exposure renders and names what it leaves out (#5089) (#6073)
semmelrindef7233c4418d0
diff --git a/crates/engine/src/cmd/render/job_tests.rs b/crates/engine/src/cmd/render/job_tests.rsindex f81da69b59..4b83916051 100644--- a/crates/engine/src/cmd/render/job_tests.rs+++ b/crates/engine/src/cmd/render/job_tests.rs@@ -636,7 +636,7 @@ fn unsupported_intent_is_rejected_and_export_preserves_existing_files() {json!({"settings":{"mode":"final"}}),json!({"settings":{"format":"exr"}}),json!({"settings":{"backend":"missing"}}),- json!({"settings":{"exposure_ev":1}}),+ json!({"settings":{"exposure_ev":1},"integrator":"raytrace"}),json!({"unknown":true}),] {assert!(s.execute("render.preflight", ¶ms).is_err());@@ -1171,3 +1171,20 @@ fn explicit_render_camera_preserves_orientation_and_refuses_invalid_state_atomicassert!(Arc::ptr_eq(&document, &s.doc));assert_eq!(before, (s.revision, s.evaluations, s.is_dirty(), s.undo.len(), s.redo.len(), s.model.is_stale()));}++/// #5089: a setup saved with exposure (the render workspace and the other executors use it)+/// renders on the raster executor, which has no exposure, and the reply says what it left out.+#[test]+fn a_setup_saved_with_exposure_renders_and_names_the_controls_it_leaves_out() {+ let (mut s, host) = session();+ s.execute("render.settings.set", &json!({"name":"x","set":{"mode":"preview","width":16,"height":16,"exposure_ev":0.3}})).unwrap();+ let reply = s.execute("render.preflight", &json!({"setup":"x"})).unwrap();+ assert_eq!(reply["ignored_controls"], json!(["exposure_ev"]));+ let plain = s.execute("render.preflight", &request()).unwrap();+ assert_eq!(plain["ignored_controls"], json!([]));+ let started = s.execute("render.start", &json!({"setup":"x"})).unwrap();+ assert_eq!(started["ignored_controls"], json!(["exposure_ev"]));+ finish(&host);+ let id: JobId = serde_json::from_value(started["job"].clone()).unwrap();+ assert_eq!(s.execute("render.status", &json!({"job":id})).unwrap()["progress"]["phase"], "completed");+}diff --git a/crates/engine/src/cmd/render/jobs.rs b/crates/engine/src/cmd/render/jobs.rsindex 56ce1e040a..93932c9d22 100644--- a/crates/engine/src/cmd/render/jobs.rs+++ b/crates/engine/src/cmd/render/jobs.rs@@ -355,7 +355,14 @@ fn prepare(s: &Session, params: &Value, command: &str) -> Result<Prepared> {} else {settings.validate().map_err(|e| bad(command, e.to_string()))?;}- if settings.exposure_ev != 0.0 || settings.environment_rotation != 0.0 || settings.environment_intensity != 1.0 {+ // The raster image executor has no exposure or environment controls. A setup saved with them+ // (the render workspace and the other executors use them) still renders here, and the reply+ // names what this render leaves out (#5089). The raytrace path takes them only through a+ // saved job, so a raytrace request with them is still refused.+ let ignored = if input.integrator == Integrator::Raster { ignored_controls(&settings) } else { Vec::new() };+ if input.integrator != Integrator::Raster+ && (settings.exposure_ev != 0.0 || settings.environment_rotation != 0.0 || settings.environment_intensity != 1.0)+ {return Err(bad(command, "exposure and environment controls are not supported by the R4a CPU image executor"));}let mut descriptor = host.descriptor_for(input.integrator).map_err(job_error)?;@@ -422,7 +429,7 @@ fn prepare(s: &Session, params: &Value, command: &str) -> Result<Prepared> {Integrator::Raytrace if refraction => "physical_transmission",Integrator::Raytrace => "opaque_only",};- let reply = json!({"stage_panels":settings.stage.len(),"stage_transport":"CPU direct/specular only; no diffuse interreflection", "cpu_budget":budget,"cpu_limits":budget.limits(),"environment":environment_info,"retained_request_bytes":retained_request_bytes,"resolved":resolved,"admission":admission,"request":request,"scene_generation":s.revision,"host":host.kind(),"transparency":transparency,"refraction":refraction,"dielectric_boundaries":if refraction {vec!["thin_sheet","closed_box"]} else {Vec::<&str>::new()}});+ let reply = json!({"ignored_controls":ignored,"stage_panels":settings.stage.len(),"stage_transport":"CPU direct/specular only; no diffuse interreflection", "cpu_budget":budget,"cpu_limits":budget.limits(),"environment":environment_info,"retained_request_bytes":retained_request_bytes,"resolved":resolved,"admission":admission,"request":request,"scene_generation":s.revision,"host":host.kind(),"transparency":transparency,"refraction":refraction,"dielectric_boundaries":if refraction {vec!["thin_sheet","closed_box"]} else {Vec::<&str>::new()}});Ok(Prepared { replace: input.replace, scene, request, reply, environment, executor: resolved.executor, options: Default::default() })}@@ -625,6 +632,21 @@ fn prepare_progressive(Ok(Prepared { replace: input.replace, scene, request, reply, executor: resolved.executor, options, environment: None })}+/// The setup's controls the raster image executor doesn't apply: those not at their neutral value.+fn ignored_controls(settings: &RenderSetup) -> Vec<&'static str> {+ let mut ignored = Vec::new();+ if settings.exposure_ev != 0.0 {+ ignored.push("exposure_ev");+ }+ if settings.environment_rotation != 0.0 {+ ignored.push("environment_rotation");+ }+ if settings.environment_intensity != 1.0 {+ ignored.push("environment_intensity");+ }+ ignored+}+pub(super) fn preflight(s: &mut Session, params: &Value) -> Result<Value> {prepare(s, params, "render.preflight").map(|p| p.reply)}@@ -641,7 +663,11 @@ pub(super) fn start(s: &mut Session, params: &Value) -> Result<Value> {crate::render_jobs::Execution { executor: p.executor, options: p.options, environment: p.environment },).map_err(job_error)?;- Ok(json!(status))+ let mut status = json!(status);+ if let (Some(out), Some(ignored)) = (status.as_object_mut(), p.reply.get("ignored_controls")) {+ out.insert("ignored_controls".into(), ignored.clone());+ }+ Ok(status)}#[derive(Deserialize)]diff --git a/docs/render-settings.md b/docs/render-settings.mdindex cae978ed8d..cc4c94f93c 100644--- a/docs/render-settings.md+++ b/docs/render-settings.md@@ -47,6 +47,12 @@ the existing camera model. Both existing camera up axes are retained. Setup nameare trimmed, nonempty, at most 128 UTF-8 bytes, without control characters. A documenthas at most 32 setups. Validation also runs during document deserialization.+The raster product-image executor (`render.preflight` / `render.start` without `progressive`)+doesn't apply exposure or the environment controls. A setup that sets them still renders there;+the reply's `ignored_controls` lists the ones that render leaves out (for example+`["exposure_ev"]`). A raytrace request with them is refused; progressive rendering applies the+exposure, and a saved job passes it to its executor.+## Complete numerical job intent`job` is tagged by `method`. It saves the active method, rather than separate CPU