@@ -513,10 +513,15 @@ class OCIOEXPORT GradingBSplineCurve
513513public:
514514 // / Create a BSpline curve with a specified number of control points.
515515 static GradingBSplineCurveRcPtr Create (size_t size);
516+ static GradingBSplineCurveRcPtr Create (size_t size, BSplineType splineType);
517+ static GradingBSplineCurveRcPtr Create (size_t size, HueCurveType curveType);
516518 // / Create a BSpline curve with a list of control points.
517519 static GradingBSplineCurveRcPtr Create (std::initializer_list<GradingControlPoint> values);
520+ static GradingBSplineCurveRcPtr Create (std::initializer_list<GradingControlPoint> values, BSplineType splineType);
521+ static GradingBSplineCurveRcPtr Create (std::initializer_list<GradingControlPoint> values, HueCurveType curveType);
518522
519523 virtual GradingBSplineCurveRcPtr createEditableCopy () const = 0;
524+ // / Get the number of ControlPoint objects (and the number of slopes).
520525 virtual size_t getNumControlPoints () const noexcept = 0;
521526 virtual void setNumControlPoints (size_t size) = 0;
522527 virtual const GradingControlPoint & getControlPoint (size_t index) const = 0;
@@ -525,6 +530,8 @@ class OCIOEXPORT GradingBSplineCurve
525530 virtual void setSlope (size_t index, float slope) = 0;
526531 virtual bool slopesAreDefault () const = 0;
527532 virtual void validate () const = 0;
533+ virtual BSplineType getSplineType () const = 0;
534+ virtual void setSplineType (BSplineType splineType) = 0;
528535
529536 GradingBSplineCurve (const GradingBSplineCurve &) = delete ;
530537 GradingBSplineCurve & operator = (const GradingBSplineCurve &) = delete ;
@@ -547,6 +554,8 @@ extern OCIOEXPORT std::ostream & operator<<(std::ostream &, const GradingBSpline
547554class OCIOEXPORT GradingRGBCurve
548555{
549556public:
557+ // / Create a GradingRGBCurve. (The style argument is not part of the object, it is simply
558+ // / used to initialize the proper default curves.)
550559 static GradingRGBCurveRcPtr Create (GradingStyle style);
551560 static GradingRGBCurveRcPtr Create (const ConstGradingRGBCurveRcPtr & rhs);
552561 static GradingRGBCurveRcPtr Create (const ConstGradingBSplineCurveRcPtr & red,
@@ -571,6 +580,58 @@ extern OCIOEXPORT bool operator==(const GradingRGBCurve & lhs, const GradingRGBC
571580extern OCIOEXPORT bool operator !=(const GradingRGBCurve & lhs, const GradingRGBCurve & rhs);
572581extern OCIOEXPORT std::ostream & operator <<(std::ostream &, const GradingRGBCurve &);
573582
583+ /* *
584+ * A set of HUE/SAT/LUM curves. It is used by GradingHueCurveTransform and can be used as
585+ * a dynamic property (see \ref DynamicPropertyGradingHueCurve).
586+ */
587+ class OCIOEXPORT GradingHueCurve
588+ {
589+ public:
590+ // / Create a GradingHueCurve. (The style argument is not part of the object, it is simply
591+ // / used to initialize the proper default curves.)
592+ static GradingHueCurveRcPtr Create (GradingStyle style);
593+ static GradingHueCurveRcPtr Create (const ConstGradingHueCurveRcPtr & rhs);
594+ static GradingHueCurveRcPtr Create (
595+ ConstGradingBSplineCurveRcPtr hueHue,
596+ ConstGradingBSplineCurveRcPtr hueSat,
597+ ConstGradingBSplineCurveRcPtr hueLum,
598+ ConstGradingBSplineCurveRcPtr lumSat,
599+ ConstGradingBSplineCurveRcPtr satSat,
600+ ConstGradingBSplineCurveRcPtr lumLum,
601+ ConstGradingBSplineCurveRcPtr satLum,
602+ ConstGradingBSplineCurveRcPtr hueFx);
603+
604+ static BSplineType GetBSplineTypeForHueCurveType (HueCurveType curveType);
605+
606+ virtual GradingHueCurveRcPtr createEditableCopy () const = 0;
607+ virtual void validate () const = 0;
608+ virtual bool isIdentity () const = 0;
609+ /* *
610+ * Enable drawCurveOnly mode to return the output value of a spline curve without any of the
611+ * other associated processing of the RGB values. This is useful when the curves need to be
612+ * graphed independently in a user interface. To use this, set the curve parameters on the
613+ * Hue-Sat curve. The R, G, and B values will be sent through that curve with the interpretation
614+ * that they are the input axis to the curve (which would be hue, sat, or luma) rather than RGB.
615+ * This mode does not apply the RGB-to-HSY or Lin-to-Log, so for scene-linear curves the luma
616+ * values are interpreted as already being in the logarithmic (f-stop) space. The forward curve
617+ * evaluation is done regardless of the transform direction.
618+ */
619+ virtual bool getDrawCurveOnly () const = 0;
620+ virtual void setDrawCurveOnly (bool drawCurveOnly) = 0;
621+ virtual ConstGradingBSplineCurveRcPtr getCurve (HueCurveType c) const = 0;
622+ virtual GradingBSplineCurveRcPtr getCurve (HueCurveType c) = 0;
623+
624+ // / Do not use (needed only for pybind11).
625+ virtual ~GradingHueCurve () = default ;
626+
627+ protected:
628+ GradingHueCurve () = default ;
629+ };
630+
631+ extern OCIOEXPORT bool operator ==(const GradingHueCurve & lhs, const GradingHueCurve & rhs);
632+ extern OCIOEXPORT bool operator !=(const GradingHueCurve & lhs, const GradingHueCurve & rhs);
633+ extern OCIOEXPORT std::ostream & operator <<(std::ostream &, const GradingHueCurve &);
634+
574635/* *
575636 * Used by the grading tone transforms to hold the red, green, blue, master, start,
576637 * and width components of a single parameter. The master component affects all three channels
@@ -734,6 +795,11 @@ extern OCIOEXPORT DynamicPropertyGradingPrimaryRcPtr AsGradingPrimary(DynamicPro
734795 * value. Will throw if property type is not DYNAMIC_PROPERTY_GRADING_RGBCURVE.
735796 */
736797extern OCIOEXPORT DynamicPropertyGradingRGBCurveRcPtr AsGradingRGBCurve (DynamicPropertyRcPtr & prop);
798+ /* *
799+ * Get the property as DynamicPropertyGradingHueCurveRcPtr to access the GradingHueCurveRcPtr
800+ * value. Will throw if property type is not DYNAMIC_PROPERTY_GRADING_HUECURVE.
801+ */
802+ extern OCIOEXPORT DynamicPropertyGradingHueCurveRcPtr AsGradingHueCurve (DynamicPropertyRcPtr & prop);
737803/* *
738804 * Get the property as DynamicPropertyGradingToneRcPtr to access the GradingTone value. Will throw
739805 * if property type is not DYNAMIC_PROPERTY_GRADING_TONE.
@@ -791,6 +857,23 @@ class OCIOEXPORT DynamicPropertyGradingRGBCurve
791857 DynamicPropertyGradingRGBCurve () = default ;
792858};
793859
860+ // / Interface used to access dynamic property ConstGradingHueCurveRcPtr value.
861+ class OCIOEXPORT DynamicPropertyGradingHueCurve
862+ {
863+ public:
864+ virtual const ConstGradingHueCurveRcPtr & getValue () const = 0;
865+ // / Will throw if value is not valid.
866+ virtual void setValue (const ConstGradingHueCurveRcPtr & value) = 0;
867+
868+ DynamicPropertyGradingHueCurve (const DynamicPropertyGradingHueCurve &) = delete ;
869+ DynamicPropertyGradingHueCurve & operator =(const DynamicPropertyGradingHueCurve &) = delete ;
870+ // / Do not use (needed only for pybind11).
871+ virtual ~DynamicPropertyGradingHueCurve () = default ;
872+
873+ protected:
874+ DynamicPropertyGradingHueCurve () = default ;
875+ };
876+
794877// / Interface used to access dynamic property GradingTone value.
795878class OCIOEXPORT DynamicPropertyGradingTone
796879{
@@ -1196,13 +1279,120 @@ class OCIOEXPORT GradingPrimaryTransform : public Transform
11961279
11971280extern OCIOEXPORT std::ostream & operator <<(std::ostream &, const GradingPrimaryTransform &) noexcept ;
11981281
1282+ /* *
1283+ * Hue curve color correction controls.
1284+ *
1285+ * This transform provides eight spline curves to make the following adjustments:
1286+ *
1287+ * - Hue-Hue: Map input hue to output hue (where a diagonal line is the identity).
1288+ * - Hue-Sat: Adjust saturation as a function of hue (a value of 1.0 is the identity).
1289+ * - Hue-Lum: Adjust luma as a function of hue (a value of 1.0 is the identity).
1290+ * - Lum-Sat: Adjust saturation as a function of luma (a value of 1.0 is the identity).
1291+ * - Sat-Sat: Adjust saturation as a function of saturation (a diagonal is the identity).
1292+ * - Lum-Lum: Adjust luma as a function of luma, maintaining hue & sat (diagonal is identity).
1293+ * - Sat-Lum: Adjust luma as a function of saturation (a value of 1.0 is the identity).
1294+ * - Hue-FX : Map input hue to delta output hue (a value of 0.0 is the identity).
1295+ *
1296+ * The algorithm is different for scene-linear, logarithmic, and video color spaces, so
1297+ * initialize the style argument appropriately before setting the curves.
1298+ *
1299+ * An RGB-to-HSY FixedFunction is used to convert RGB into a hue, saturation, luma color
1300+ * space. However, there is an option to bypass that conversion to use an outboard transform.
1301+ *
1302+ * Like the GradingRGBCurveTransform, the curves are defined by the x and y coordinates of a
1303+ * set of control points. A spline will be fit to the control points. Monotonicity is preserved
1304+ * for curves where the diagonal is the identity. For curves that take luma as input, if the
1305+ * style is scene-linear, the units are in photographic stops relative to 0.18. For log and
1306+ * video, the luma is scaled the same as the input RGB.
1307+ *
1308+ * The hue variable is [0,1] and is periodic. For example, -0.2, 0.8, and 1.8 are equivalent.
1309+ * The domain of the curves is [0,1] and control points outside that domain are mapped into it.
1310+ * A hue of 0 or 1 corresponds to a magenta hue.
1311+ *
1312+ * The control points are dynamic, so they may be adjusted even after the Transform is included
1313+ * in a Processor. However, creating a curve or setting the parameters will call the
1314+ * GradingBSplineCurveImpl::validate function, which will throw an exception if the control
1315+ * points do not meet certain requirements, for example that the X-coordinates are non-decreasing
1316+ * Please review that function for details on the validation. Applications that provide a UI to
1317+ * edit curves must ensure that they prevent users from creating control points that are not valid.
1318+ *
1319+ * The transform is invertible as long as the curves allow it. For example, if saturation is
1320+ * mapped to zero, obviously that cannot be resaturated. Care should be taken with the Hue-FX
1321+ * curve because it is possible to fold hues over on themselves, which also cannot be inverted.
1322+ * In most cases the Hue-FX curve is not necessary since the Hue-Hue curve provides similar
1323+ * functionality with the added benefit of being strictly invertible.
1324+ */
1325+ class OCIOEXPORT GradingHueCurveTransform : public Transform
1326+ {
1327+ public:
1328+ // / Creates an instance of GradingHueCurveTransform.
1329+ static GradingHueCurveTransformRcPtr Create (GradingStyle style);
1330+
1331+ TransformType getTransformType () const noexcept override { return TRANSFORM_TYPE_GRADING_HUE_CURVE; }
1332+
1333+ virtual const FormatMetadata & getFormatMetadata () const noexcept = 0;
1334+ virtual FormatMetadata & getFormatMetadata () noexcept = 0;
1335+
1336+ // / Checks if this equals other.
1337+ virtual bool equals (const GradingHueCurveTransform & other) const noexcept = 0;
1338+
1339+ // / Adjusts the behavior of the transform for log, linear, or video color space encodings.
1340+ virtual GradingStyle getStyle () const noexcept = 0;
1341+
1342+ // / Will reset value to style's defaults if style is not the current style.
1343+ virtual void setStyle (GradingStyle style) noexcept = 0;
1344+
1345+ virtual const ConstGradingHueCurveRcPtr getValue () const = 0;
1346+
1347+ // / Throws if value is not valid.
1348+ virtual void setValue (const ConstGradingHueCurveRcPtr & value) = 0;
1349+
1350+ /* *
1351+ * It is possible to provide a desired slope value for each control point. The number of slopes is
1352+ * always the same as the number of control points and so the control points must be set before
1353+ * setting the slopes. The slopes are primarily intended for use by config authors looking to match
1354+ * a specific shape with as few control points as possible, they are not intended to be exposed to
1355+ * a user interface for direct manipulation. When a curve is being generated for creative purposes
1356+ * it is better to let OCIO calculate the slopes automatically.
1357+ */
1358+ virtual float getSlope (HueCurveType c, size_t index) const = 0;
1359+ virtual void setSlope (HueCurveType c, size_t index, float slope) = 0;
1360+ virtual bool slopesAreDefault (HueCurveType c) const = 0;
1361+
1362+ /* *
1363+ * By default, the input is transformed into HSY space to apply the hue curves and then the result is
1364+ * transformed back to RGB. However, this may be set to HSY_TRANSFORM_NONE to bypass this in order to
1365+ * use other hue/sat/luma type transforms applied separately before and after this transform.
1366+ */
1367+ virtual HSYTransformStyle getRGBToHSY () const = 0;
1368+ virtual void setRGBToHSY (HSYTransformStyle style) = 0;
1369+
1370+ // /**
1371+ // * Parameters can be made dynamic so the values can be changed through the CPU or GPU processor,
1372+ // * but if there are several GradingHueCurveTransform only one can have dynamic parameters.
1373+ // */
1374+ virtual bool isDynamic () const noexcept = 0;
1375+ virtual void makeDynamic () noexcept = 0;
1376+ virtual void makeNonDynamic () noexcept = 0;
1377+
1378+ GradingHueCurveTransform (const GradingHueCurveTransform &) = delete ;
1379+ GradingHueCurveTransform & operator = (const GradingHueCurveTransform &) = delete ;
1380+
1381+ // / Do not use (needed only for pybind11).
1382+ virtual ~GradingHueCurveTransform () = default ;
1383+
1384+ protected:
1385+ GradingHueCurveTransform () = default ;
1386+ };
1387+
1388+ extern OCIOEXPORT std::ostream & operator <<(std::ostream &, const GradingHueCurveTransform &) noexcept ;
11991389
12001390/* *
12011391 * RGB curve color correction controls.
12021392 *
12031393 * This transform allows for modifying tone reproduction via B-spline curves.
12041394 *
1205- * There is an R, G, and B curve along with a Master curve (that applies to R, G, and B). Each
1395+ * There is an R, G, and B curve followed by a Master curve (that applies to R, G, and B). Each
12061396 * curve is specified via the x and y coordinates of its control points. A monotonic spline is
12071397 * fit to the control points. The x coordinates must be non-decreasing. When the grading style
12081398 * is linear, the units for the control points are photographic stops relative to 0.18.
0 commit comments