Skip to content

Commit 06def95

Browse files
larochjdoug-walker
authored andcommitted
Enable to draw the curve eval only for a specific hue curve. (#11)
(cherry picked from commit d658e70) Signed-off-by: Doug Walker <[email protected]>
1 parent ffcffe9 commit 06def95

File tree

6 files changed

+47
-7
lines changed

6 files changed

+47
-7
lines changed

include/OpenColorIO/OpenColorTransforms.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1308,6 +1308,18 @@ class OCIOEXPORT GradingHueCurveTransform : public Transform
13081308
virtual bool getBypassLinToLog() const = 0;
13091309
virtual void setBypassLinToLog(bool bypass) = 0;
13101310

1311+
/**
1312+
* Enable drawCurveOnly mode to return the output value of a spline curve without any of the
1313+
* other associated processing of the RGB values. This is useful when the curves need to be
1314+
* graphed independently in a user interface. To use this, set the curve parameters on the
1315+
* Hue-Sat curve. The R, G, and B values will be sent through that curve but with the interpretation
1316+
* that they are the input axis to the curve (which would be hue, sat, or luma) rather than RGB.
1317+
* This mode ignores the setting of BypassLinToLog, so for scene-linear curves the luma values are
1318+
* interpreted as already being in the logarithmic (f-stop) space.
1319+
*/
1320+
virtual bool getDrawCurveOnly() const = 0;
1321+
virtual void setDrawCurveOnly( bool drawCurveOnly ) = 0;
1322+
13111323
///**
13121324
// * Parameters can be made dynamic so the values can be changed through the CPU or GPU processor,
13131325
// * but if there are several GradingHueCurveTransform only one can have dynamic parameters.

src/OpenColorIO/ops/gradinghuecurve/GradingHueCurveOpData.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ GradingHueCurveOpData & GradingHueCurveOpData::operator=(const GradingHueCurveOp
6868
m_direction = rhs.m_direction;
6969
m_style = rhs.m_style;
7070
m_bypassLinToLog = rhs.m_bypassLinToLog;
71+
m_drawCurveOnly = rhs.m_drawCurveOnly;
7172

7273
// Copy dynamic properties. Sharing happens when needed, with CPUOp for instance.
7374
m_value->setValue(rhs.m_value->getValue());
@@ -76,6 +77,7 @@ GradingHueCurveOpData & GradingHueCurveOpData::operator=(const GradingHueCurveOp
7677
m_value->makeDynamic();
7778
}
7879

80+
7981
return *this;
8082
}
8183

@@ -228,6 +230,7 @@ bool GradingHueCurveOpData::equals(const OpData & other) const
228230
if (m_direction != rop->m_direction ||
229231
m_style != rop->m_style ||
230232
m_bypassLinToLog != rop->m_bypassLinToLog ||
233+
m_drawCurveOnly != rop->m_drawCurveOnly ||
231234
!m_value->equals( *(rop->m_value) ))
232235
{
233236
return false;

src/OpenColorIO/ops/gradinghuecurve/GradingHueCurveOpData.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@ class GradingHueCurveOpData : public OpData
6666
bool getBypassLinToLog() const noexcept { return m_bypassLinToLog; }
6767
void setBypassLinToLog(bool bypass) noexcept { m_bypassLinToLog = bypass; }
6868

69+
bool getDrawCurveOnly() const noexcept { return m_drawCurveOnly; }
70+
void setDrawCurveOnly(bool drawCurveOnly) noexcept { m_drawCurveOnly = drawCurveOnly; }
71+
6972
TransformDirection getDirection() const noexcept;
7073
void setDirection(TransformDirection dir) noexcept;
7174

@@ -85,6 +88,7 @@ class GradingHueCurveOpData : public OpData
8588
GradingStyle m_style;
8689
DynamicPropertyGradingHueCurveImplRcPtr m_value;
8790
bool m_bypassLinToLog{ false };
91+
bool m_drawCurveOnly{ false };
8892
TransformDirection m_direction{ TRANSFORM_DIR_FORWARD };
8993
};
9094

src/OpenColorIO/ops/gradinghuecurve/GradingHueCurveOpGPU.cpp

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -256,8 +256,18 @@ void AddGCForwardShader(GpuShaderCreatorRcPtr & shaderCreator,
256256
const GCProperties & props,
257257
bool dyn,
258258
bool doLinToLog,
259+
bool drawCurveOnly,
259260
GradingStyle style)
260261
{
262+
const std::string pix(shaderCreator->getPixelName());
263+
if(drawCurveOnly)
264+
{
265+
st.newLine() << pix << ".r = " << props.m_eval << "(1, " << pix << ".r, 1.);"; // HUE-SAT
266+
st.newLine() << pix << ".g = " << props.m_eval << "(1, " << pix << ".g, 1.);"; // HUE-SAT
267+
st.newLine() << pix << ".b = " << props.m_eval << "(1, " << pix << ".b, 1.);"; // HUE-SAT
268+
return;
269+
}
270+
261271
if (dyn)
262272
{
263273
st.newLine() << "if (!" << props.m_localBypass << ")";
@@ -299,8 +309,6 @@ void AddGCForwardShader(GpuShaderCreatorRcPtr & shaderCreator,
299309
st.newLine() << "";
300310
}
301311

302-
const std::string pix(shaderCreator->getPixelName());
303-
304312
st.newLine() << "";
305313
st.newLine() << "float hueSatGain = max(0., " << props.m_eval << "(1, " << pix << ".r, 1.));"; // HUE-SAT
306314
st.newLine() << "float hueLumGain = max(0., " << props.m_eval << "(2, " << pix << ".r, 1.));"; // HUE-LUM
@@ -463,25 +471,25 @@ void GetHueCurveGPUShaderProgram(GpuShaderCreatorRcPtr & shaderCreator,
463471
shaderCreator->addDynamicProperty(newProp);
464472

465473
// Add uniforms only if needed.
466-
AddGCPropertiesUniforms(shaderCreator, shaderProp, properties); // _addAttributeTextToShaderProgram
474+
AddGCPropertiesUniforms(shaderCreator, shaderProp, properties);
467475

468476
// Add helper function plus global variables if they are not dynamic.
469-
AddCurveEvalMethodTextToShaderProgram(shaderCreator, gcData, properties, dyn); // _addHelperMethodTextToShaderProgram
477+
AddCurveEvalMethodTextToShaderProgram(shaderCreator, gcData, properties, dyn);
470478
}
471479
else
472480
{
473481
// Declare the op specific helper function.
474482
AddCurveEvalMethodTextToShaderProgram(shaderCreator, gcData, properties, dyn);
475483
}
476484

477-
const bool bypassLinToLog = (style == GRADING_LIN) && !gcData->getBypassLinToLog();
485+
const bool doLinToLog = (style == GRADING_LIN) && !gcData->getBypassLinToLog();
478486
switch (dir)
479487
{
480488
case TRANSFORM_DIR_FORWARD:
481-
AddGCForwardShader(shaderCreator, st, properties, dyn, bypassLinToLog, style); // _addProcessingTextToShaderProgram
489+
AddGCForwardShader(shaderCreator, st, properties, dyn, doLinToLog, gcData->getDrawCurveOnly(), style);
482490
break;
483491
case TRANSFORM_DIR_INVERSE: // TODO: Implement the inverse shader.
484-
//AddGCInverseShader(shaderCreator, st, properties, dyn, bypassLinToLog, style); // _addProcessingTextToShaderProgram
492+
//AddGCInverseShader(shaderCreator, st, properties, dyn, bypassLinToLog, style);
485493
break;
486494
}
487495

src/OpenColorIO/transforms/GradingHueCurveTransform.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,16 @@ void GradingHueCurveTransformImpl::setBypassLinToLog(bool bypass) noexcept
121121
data().setBypassLinToLog(bypass);
122122
}
123123

124+
bool GradingHueCurveTransformImpl::getDrawCurveOnly() const noexcept
125+
{
126+
return data().getDrawCurveOnly();
127+
}
128+
129+
void GradingHueCurveTransformImpl::setDrawCurveOnly( bool drawCurveOnly ) noexcept
130+
{
131+
data().setDrawCurveOnly( drawCurveOnly );
132+
}
133+
124134
bool GradingHueCurveTransformImpl::isDynamic() const noexcept
125135
{
126136
return data().isDynamic();

src/OpenColorIO/transforms/GradingHueCurveTransform.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ class GradingHueCurveTransformImpl : public GradingHueCurveTransform
4848

4949
bool getBypassLinToLog() const noexcept override;
5050
void setBypassLinToLog(bool bypass) noexcept override;
51+
52+
bool getDrawCurveOnly() const noexcept override;
53+
void setDrawCurveOnly(bool drawCurveOnly) noexcept override;
5154

5255
bool isDynamic() const noexcept override;
5356
void makeDynamic() noexcept override;

0 commit comments

Comments
 (0)