Add ability to set custom OCIO function names

This commit is contained in:
Thomas Wilshaw
2022-04-27 22:48:41 +01:00
parent 3c13e32620
commit f9f8622682
5 changed files with 16 additions and 5 deletions
+1
View File
@@ -87,6 +87,7 @@ void ChromaKeyNode::Value(const NodeValueRow &value, const NodeGlobals &globals,
job.SetColorProcessor(processor());
job.SetInputTexture(value[kTextureInput].data().value<TexturePtr>());
job.SetNeedsCustomShader(this);
job.SetFunctionName(QString("SceneLinearToCIEXYZ_d65"));
table->Push(NodeValue::kColorTransformJob, QVariant::fromValue(job), this);
}
+5
View File
@@ -71,6 +71,9 @@ public:
const QMatrix4x4 &GetCropMatrix() const { return crop_matrix_; }
void SetCropMatrix(const QMatrix4x4 &m) { crop_matrix_ = m; }
const QString &FunctionName() const { return function_name_; }
void SetFunctionName(const QString &function_name = QString()) { function_name_ = function_name; };
private:
ColorProcessorPtr processor_;
@@ -87,6 +90,8 @@ private:
QMatrix4x4 crop_matrix_;
QString function_name_;
};
}
+8 -3
View File
@@ -106,10 +106,15 @@ bool Renderer::GetColorContext(const ColorTransformJob &color_job, Renderer::Col
return true;
} else {
// Create shader description
const char* ocio_func_name = "OCIODisplay";
QString ocio_func_name;
if (color_job.FunctionName().isEmpty()) {
ocio_func_name = "OCIODisplay";
} else {
ocio_func_name = color_job.FunctionName();
}
auto shader_desc = OCIO::GpuShaderDesc::CreateShaderDesc();
shader_desc->setLanguage(OCIO::GPU_LANGUAGE_GLSL_ES_3_0);
shader_desc->setFunctionName(ocio_func_name);
shader_desc->setFunctionName(ocio_func_name.toStdString().c_str());
shader_desc->setResourcePrefix("ocio_");
// Generate shader
@@ -124,7 +129,7 @@ bool Renderer::GetColorContext(const ColorTransformJob &color_job, Renderer::Col
code = FileFunctions::ReadFileAsString(QStringLiteral(":shaders/colormanage.frag"));
}
code.set_frag_code(code.frag_code().arg(shader_desc->getShaderText(), ocio_func_name));
code.set_frag_code(code.frag_code().arg(shader_desc->getShaderText()));
// Try to compile shader
color_ctx.compiled_shader = CreateNativeShader(code);
+1 -1
View File
@@ -39,7 +39,7 @@ void main() {
vec4 col = texture(tex_in, ove_texcoord);
// Perform color conversion
vec4 cie_xyz = %2(col);
vec4 cie_xyz = SceneLinearToCIEXYZ_d65(col);
vec4 lab = CIExyz_to_Lab(cie_xyz);
frag_color = vec4(lab.r);
+1 -1
View File
@@ -44,7 +44,7 @@ void main() {
}
// Perform color conversion
col = %2(col);
col = OCIODisplay(col);
// Associate or re-associate here
if (ove_maintex_alpha == ALPHA_ASSOC) {