mirror of
https://github.com/brunoherbelin/vimix.git
synced 2025-12-05 15:30:00 +01:00
Add Luminance parameter to Lumakey filter
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
* (C) 2019-2022 Bruno Herbelin <bruno.herbelin@gmail.com>
|
||||
* Distributed under GNU GPL3+ License
|
||||
**/
|
||||
uniform float Luminance;
|
||||
uniform float Threshold;
|
||||
uniform float Tolerance;
|
||||
|
||||
@@ -43,5 +44,5 @@ void mainImage( out vec4 fragColor, in vec2 fragCoord )
|
||||
float L = dot(RGB, vec3(0.299, 0.587, 0.114));
|
||||
// float L = lightness( RGB );
|
||||
|
||||
fragColor = vec4( RGB, smoothstep( Threshold, Threshold + Tolerance * Tolerance, L ) );
|
||||
fragColor = vec4( RGB, smoothstep( Threshold, Threshold + Tolerance * Tolerance, abs(Luminance - L) ) );
|
||||
}
|
||||
|
||||
@@ -1358,6 +1358,34 @@ void ImGuiVisitor::visit (AlphaFilter& f)
|
||||
Action::manager().store(oss.str());
|
||||
}
|
||||
}
|
||||
// Luminance extra parameter
|
||||
else {
|
||||
float v = filter_parameters["Luminance"];
|
||||
ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN);
|
||||
if (ImGui::SliderFloat( "##Luminance", &v, 0.f, 1.f, "%.2f")) {
|
||||
f.setProgramParameter("Luminance", v);
|
||||
}
|
||||
if (ImGui::IsItemHovered() && io.MouseWheel != 0.f ){
|
||||
v = CLAMP( v + 0.01f * io.MouseWheel, 0.f, 1.f);
|
||||
f.setProgramParameter("Luminance", v);
|
||||
oss << AlphaFilter::operation_label[ f.operation() ];
|
||||
oss << " : " << "Luminance" << " " << std::setprecision(3) << v;
|
||||
Action::manager().store(oss.str());
|
||||
}
|
||||
if (ImGui::IsItemDeactivatedAfterEdit()) {
|
||||
oss << AlphaFilter::operation_label[ f.operation() ];
|
||||
oss << " : " << "Luminance" << " " << std::setprecision(3) << v;
|
||||
Action::manager().store(oss.str());
|
||||
}
|
||||
ImGui::SameLine(0, IMGUI_SAME_LINE);
|
||||
if (ImGuiToolkit::TextButton("Luminance")) {
|
||||
v = 0.f;
|
||||
f.setProgramParameter("Luminance", v);
|
||||
oss << AlphaFilter::operation_label[ f.operation() ];
|
||||
oss << " : " << "Luminance" << " " << std::setprecision(3) << v;
|
||||
Action::manager().store(oss.str());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -806,7 +806,7 @@ const char* AlphaFilter::operation_label[AlphaFilter::ALPHA_INVALID] = {
|
||||
|
||||
std::vector< FilteringProgram > AlphaFilter::programs_ = {
|
||||
FilteringProgram("Chromakey","shaders/filters/chromakey.glsl", "", { { "Red", 0.0}, { "Green", 1.0}, { "Blue", 0.0}, { "Threshold", 0.5}, { "Tolerance", 0.5} }),
|
||||
FilteringProgram("Lumakey", "shaders/filters/lumakey.glsl", "", { { "Threshold", 0.5}, { "Tolerance", 0.5} } ),
|
||||
FilteringProgram("Lumakey", "shaders/filters/lumakey.glsl", "", { { "Luminance", 0.0}, { "Threshold", 0.5}, { "Tolerance", 0.5} } ),
|
||||
FilteringProgram("coloralpha","shaders/filters/coloralpha.glsl", "", { { "Red", 0.0}, { "Green", 1.0}, { "Blue", 0.0} })
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user