{"record":{"id":"b481ab32a8f045b7","repo":"bevyengine/bevy","slug":"curve-could-not-be-constructed-from-the-given-data","errorCode":null,"errorMessage":"curve could not be constructed from the given data","messagePattern":"curve could not be constructed from the given data","errorType":"exception","errorClass":"AutoExposureCompensationCurveError","httpStatus":null,"severity":"error","filePath":"crates/bevy_post_process/src/auto_exposure/compensation_curve.rs","lineNumber":46,"sourceCode":"    min_compensation: f32,\n    /// The maximum exposure compensation value in the curve. (the y-axis)\n    max_compensation: f32,\n    /// 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        }","sourceCodeStart":28,"sourceCodeEnd":64,"githubUrl":"https://github.com/bevyengine/bevy/blob/396ca727080776bd313bb892423b7d94e03b81b4/crates/bevy_post_process/src/auto_exposure/compensation_curve.rs#L28-L64","documentation":"`AutoExposureCompensationCurve::from_curve` (crates/bevy_post_process/src/auto_exposure/compensation_curve.rs:101) first converts the input curve to a cubic curve via `CubicGenerator::to_curve`; if that conversion fails, `AutoExposureCompensationCurveError::InvalidCurve` is returned. The curve maps log luminance (x) to exposure compensation (y) and is baked into a 256-entry LUT for the auto-exposure GPU pass.","triggerScenarios":"Passing a `CubicGenerator` (e.g. `CubicBezier`, or the spline built by `from_points`) whose control points cannot form valid cubic segments — wrong point count for the generator, degenerate/empty input. `from_points` with an empty or single-point list hits the same path.","commonSituations":"Building a compensation curve from artist/editor data at asset load; hot-reloading curve settings to zero points during development; porting curve data from another tool with mismatched control-point counts.","solutions":["Ensure `from_points` receives at least two `Vec2` (log-lum, compensation) points","Match the control-point count the chosen generator requires (e.g. 4 per segment for cubic Bezier)","Log and fall back to the identity/zero curve when conversion fails, so one bad asset doesn't break scene load"],"exampleFix":"// before: malformed control points\nlet curve = AutoExposureCompensationCurve::from_curve(\n    CubicBezier::new([vec2(0.0, 0.0)])).flatten()?; // too few points\n\n// after: valid, sorted input\nlet curve = AutoExposureCompensationCurve::from_points([\n    vec2(-4.0, -2.0),\n    vec2(0.0, 0.0),\n    vec2(4.0, 2.0),\n])?;","handlingStrategy":"try-catch","validationCode":"if points.len() < 2 {\n    return Ok(AutoExposureCompensationCurve::default());\n}","typeGuard":null,"tryCatchPattern":"match AutoExposureCompensationCurve::from_points(points) {\n    Err(AutoExposureCompensationCurveError::InvalidCurve) => {\n        warn!(\"invalid compensation curve; using identity curve\");\n        AutoExposureCompensationCurve::default()\n    }\n    Err(e) => return Err(e.into()),\n    Ok(curve) => curve,\n}","preventionTips":["Require >= 2 points in asset schema validation before conversion","Log the input point count when conversion fails so bad assets are identifiable","Unit-test curve construction against golden point sets"],"tags":["bevy","auto-exposure","curve","post-processing","tone-mapping"],"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"}