{"record":{"id":"da9fae9b77d858d3","repo":"bevyengine/bevy","slug":"discontinuity-found-between-curve-segments","errorCode":null,"errorMessage":"discontinuity found between curve segments","messagePattern":"discontinuity found between curve segments","errorType":"exception","errorClass":"AutoExposureCompensationCurveError","httpStatus":null,"severity":"error","filePath":"crates/bevy_post_process/src/auto_exposure/compensation_curve.rs","lineNumber":49,"sourceCode":"    /// The lookup table for the curve. Uploaded to the GPU as a 1D texture.\n    /// Each value in the LUT is a `u8` representing a normalized exposure compensation value:\n    /// * `0` maps to `min_compensation`\n    /// * `255` maps to `max_compensation`\n    ///\n    /// The position in the LUT corresponds to the normalized log luminance value.\n    /// * `0` maps to `min_log_lum`\n    /// * `LUT_SIZE - 1` maps to `max_log_lum`\n    lut: [u8; LUT_SIZE],\n}\n\n/// Various errors that can occur when constructing an [`AutoExposureCompensationCurve`].\n#[derive(Error, Debug)]\npub enum AutoExposureCompensationCurveError {\n    /// The curve couldn't be built in the first place.\n    #[error(\"curve could not be constructed from the given data\")]\n    InvalidCurve,\n    /// A discontinuity was found in the curve.\n    #[error(\"discontinuity found between curve segments\")]\n    DiscontinuityFound,\n    /// The curve is not monotonically increasing on the x-axis.\n    #[error(\"curve is not monotonically increasing on the x-axis\")]\n    NotMonotonic,\n}\n\nimpl Default for AutoExposureCompensationCurve {\n    fn default() -> Self {\n        Self {\n            min_log_lum: 0.0,\n            max_log_lum: 0.0,\n            min_compensation: 0.0,\n            max_compensation: 0.0,\n            lut: [0; LUT_SIZE],\n        }\n    }\n}\n","sourceCodeStart":31,"sourceCodeEnd":67,"githubUrl":"https://github.com/bevyengine/bevy/blob/396ca727080776bd313bb892423b7d94e03b81b4/crates/bevy_post_process/src/auto_exposure/compensation_curve.rs#L31-L67","documentation":"After building the cubic curve, `from_curve` walks every segment and requires each one to start exactly where the previous sample ended (`segment.position(0.0) == previous`). A gap or jump in the log-luminance (x) domain between segments returns `AutoExposureCompensationCurveError::DiscontinuityFound` (crates/bevy_post_process/src/auto_exposure/compensation_curve.rs:120), because the LUT bake assumes a continuous curve.","triggerScenarios":"Feeding `from_points`/`from_curve` data whose consecutive segments don't chain on the x-axis: points with a gap between segment boundaries, or a custom `CubicGenerator` whose segments cover disjoint intervals.","commonSituations":"Hand-authored compensation curves from spreadsheets/JSON where an x value was skipped or mistyped; splicing two curves together without blending the junction.","solutions":["Check that x values are contiguous across the whole input — no skipped log-luminance values between segments","Rebuild the curve from a single sorted, gap-free point list","Validate the junction points programmatically before calling `from_curve`"],"exampleFix":"// before: gap between segments -> DiscontinuityFound\nlet pts = [vec2(-4.0, -2.0), vec2(-1.0, -1.0), vec2(2.0, 1.0)]; // jump 2.0 -> skipped range\n\n// after: dense, contiguous sampling of the intended function\nlet pts = (-40..=40).map(|i| vec2(i as f32 / 10.0, (i as f32 / 40.0).powi(3))).collect::<Vec<_>>();\nlet curve = AutoExposureCompensationCurve::from_points(pts)?;","handlingStrategy":"try-catch","validationCode":"let mut pts: Vec<Vec2> = points.to_vec();\npts.sort_by(|a, b| a.x.partial_cmp(&b.x).unwrap());\n// contiguity sanity check before handing to the converter\nfor w in pts.windows(2) {\n    assert!(w[1].x > w[0].x, \"duplicate/decreasing x values\");\n}","typeGuard":null,"tryCatchPattern":"match AutoExposureCompensationCurve::from_points(pts) {\n    Err(AutoExposureCompensationCurveError::DiscontinuityFound) => {\n        warn!(\"gaps in compensation curve; falling back to linear interpolation of endpoints\");\n        fallback_curve(pts)\n    }\n    other => other?,\n}","preventionTips":["Author curves as dense samples of a function rather than hand-placed sparse points","Validate junction continuity (segment end == next segment start) in asset tooling"],"tags":["bevy","auto-exposure","curve","discontinuity","post-processing"],"backgroundTag":"curve-construction-failed","analyzedSha":"396ca727080776bd313bb892423b7d94e03b81b4","analyzedAt":"2026-08-20T16:12:39.808Z","contentChangedAt":"2026-08-20T16:12:39.808Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}