Fix PR comments and generate mask
This commit is contained in:
@@ -22,8 +22,14 @@ namespace olive {
|
||||
|
||||
#define super OCIOBaseNode
|
||||
|
||||
const QString ChromaKeyNode::kColorInput = QStringLiteral("color_key");
|
||||
const QString ChromaKeyNode::kMaskOnlyInput = QStringLiteral("mask_only_in");
|
||||
|
||||
ChromaKeyNode::ChromaKeyNode()
|
||||
{
|
||||
AddInput(kColorInput, NodeValue::kColor, QVariant::fromValue(Color(0.0f, 1.0f, 0.0f, 1.0f)));
|
||||
|
||||
AddInput(kMaskOnlyInput, NodeValue::kBoolean, false);
|
||||
}
|
||||
|
||||
QString ChromaKeyNode::Name() const
|
||||
@@ -52,11 +58,11 @@ void ChromaKeyNode::Retranslate()
|
||||
SetInputName(kTextureInput, tr("Input"));
|
||||
//SetInputName(kGarbageMatteInput, tr("Garbage Matte"));
|
||||
//SetInputName(kCoreMatteInput, tr("Core Matte"));
|
||||
//SetInputName(kColorInput, tr("Key Color"));
|
||||
SetInputName(kColorInput, tr("Key Color"));
|
||||
//SetComboBoxStrings(kColorInput, {tr("Green"), tr("Blue")});
|
||||
//SetInputName(kShadowsInput, tr("Shadows"));
|
||||
//SetInputName(kHighlightsInput, tr("Highlights"));
|
||||
//SetInputName(kMaskOnlyInput, tr("Show Mask Only"));
|
||||
SetInputName(kMaskOnlyInput, tr("Show Mask Only"));
|
||||
}
|
||||
|
||||
void ChromaKeyNode::InputValueChangedEvent(const QString &input, int element)
|
||||
@@ -84,10 +90,11 @@ void ChromaKeyNode::Value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
ColorTransformJob job;
|
||||
|
||||
job.InsertValue(value);
|
||||
job.SetInputAlphaAssociation(AlphaAssociated::kAlphaAssociated);
|
||||
job.SetColorProcessor(processor());
|
||||
job.SetInputTexture(value[kTextureInput].data().value<TexturePtr>());
|
||||
job.SetNeedsCustomShader(this);
|
||||
job.SetFunctionName(QString("SceneLinearToCIEXYZ_d65"));
|
||||
job.SetFunctionName(QStringLiteral("SceneLinearToCIEXYZ_d65"));
|
||||
|
||||
table->Push(NodeValue::kColorTransformJob, QVariant::fromValue(job), this);
|
||||
}
|
||||
|
||||
@@ -42,6 +42,9 @@ class ChromaKeyNode : public OCIOBaseNode {
|
||||
|
||||
virtual void ConfigChanged() override {};
|
||||
|
||||
static const QString kColorInput;
|
||||
static const QString kMaskOnlyInput;
|
||||
|
||||
private:
|
||||
void GenerateProcessor();
|
||||
|
||||
|
||||
@@ -71,7 +71,7 @@ public:
|
||||
const QMatrix4x4 &GetCropMatrix() const { return crop_matrix_; }
|
||||
void SetCropMatrix(const QMatrix4x4 &m) { crop_matrix_ = m; }
|
||||
|
||||
const QString &FunctionName() const { return function_name_; }
|
||||
const QString &GetFunctionName() const { return function_name_; }
|
||||
void SetFunctionName(const QString &function_name = QString()) { function_name_ = function_name; };
|
||||
|
||||
private:
|
||||
|
||||
@@ -107,14 +107,14 @@ bool Renderer::GetColorContext(const ColorTransformJob &color_job, Renderer::Col
|
||||
} else {
|
||||
// Create shader description
|
||||
QString ocio_func_name;
|
||||
if (color_job.FunctionName().isEmpty()) {
|
||||
if (color_job.GetFunctionName().isEmpty()) {
|
||||
ocio_func_name = "OCIODisplay";
|
||||
} else {
|
||||
ocio_func_name = color_job.FunctionName();
|
||||
ocio_func_name = color_job.GetFunctionName();
|
||||
}
|
||||
auto shader_desc = OCIO::GpuShaderDesc::CreateShaderDesc();
|
||||
shader_desc->setLanguage(OCIO::GPU_LANGUAGE_GLSL_ES_3_0);
|
||||
shader_desc->setFunctionName(ocio_func_name.toStdString().c_str());
|
||||
shader_desc->setFunctionName(ocio_func_name.toUtf8());
|
||||
shader_desc->setResourcePrefix("ocio_");
|
||||
|
||||
// Generate shader
|
||||
@@ -220,6 +220,10 @@ void Renderer::BlitColorManaged(const ColorTransformJob &color_job, Texture *des
|
||||
job.InsertValue(QStringLiteral("ove_maintex_alpha"), NodeValue(NodeValue::kInt, color_job.GetInputAlphaAssociation()));
|
||||
job.InsertValue(color_job.GetValues());
|
||||
|
||||
//if (color_job.GetInputAlphaAssociation() == AlphaAssociated::kAlphaAssociated) {
|
||||
job.SetAlphaChannelRequired(GenerateJob::kAlphaForceOn);
|
||||
//}
|
||||
|
||||
foreach (const ColorContext::LUT& l, color_ctx.lut3d_textures) {
|
||||
job.InsertValue(l.name, NodeValue(NodeValue::kTexture, QVariant::fromValue(l.texture)));
|
||||
job.SetInterpolation(l.name, l.interpolation);
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
// Main texture input
|
||||
uniform sampler2D tex_in;
|
||||
uniform vec4 color_key;
|
||||
uniform bool mask_only_in;
|
||||
|
||||
|
||||
// Main texture coordinate
|
||||
@@ -33,6 +35,14 @@ vec4 CIExyz_to_Lab(vec4 CIE) {
|
||||
return lab;
|
||||
}
|
||||
|
||||
float colorclose(vec4 col, vec4 key, float tola,float tolb) {
|
||||
/*decides if a color is close to the specified hue*/
|
||||
float temp = sqrt(((key.g-col.g)*(key.g-col.g))+((key.b-col.b)*(key.b-col.b)));
|
||||
if (temp < tola) {return (0.0);}
|
||||
if (temp < tolb) {return ((temp-tola)/(tolb-tola));}
|
||||
return (1.0);
|
||||
}
|
||||
|
||||
|
||||
void main() {
|
||||
|
||||
@@ -42,5 +52,17 @@ void main() {
|
||||
vec4 cie_xyz = SceneLinearToCIEXYZ_d65(col);
|
||||
vec4 lab = CIExyz_to_Lab(cie_xyz);
|
||||
|
||||
frag_color = vec4(lab.r);
|
||||
vec4 cie_xyz_key = SceneLinearToCIEXYZ_d65(color_key);
|
||||
vec4 lab_key = CIExyz_to_Lab(cie_xyz_key);
|
||||
|
||||
float mask = colorclose(lab, lab_key, 5.0, 25.0);
|
||||
|
||||
col.rgb *= mask;
|
||||
col.w = mask;
|
||||
|
||||
if (!mask_only_in) {
|
||||
frag_color = col;
|
||||
} else {
|
||||
frag_color = vec4(vec3(mask), 1.0);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user