mirror of
https://github.com/brunoherbelin/vimix.git
synced 2025-12-12 02:40:00 +01:00
Gui visitor for image procesing shader
This commit is contained in:
@@ -14,6 +14,8 @@
|
||||
#include "imgui.h"
|
||||
#include "ImGuiToolkit.h"
|
||||
|
||||
#define RIGHT_ALIGN -100
|
||||
|
||||
ImGuiVisitor::ImGuiVisitor()
|
||||
{
|
||||
|
||||
@@ -110,13 +112,25 @@ void ImGuiVisitor::visit(MediaPlayer &n)
|
||||
|
||||
void ImGuiVisitor::visit(Shader &n)
|
||||
{
|
||||
float width = ImGui::GetContentRegionAvail().x;
|
||||
|
||||
ImGui::PushID(n.id());
|
||||
|
||||
if (ImGuiToolkit::ButtonIcon(14, 8)) {
|
||||
// if (ImGuiToolkit::ButtonIcon(14, 8)) n.color = glm::vec4(1.f, 1.f, 1.f, 1.f);
|
||||
// ImGui::SameLine(0, 10);
|
||||
// ImGui::ColorEdit3("Color", glm::value_ptr(n.color) ) ;
|
||||
|
||||
if (ImGuiToolkit::ButtonIcon(10, 2)) {
|
||||
n.blending = Shader::BLEND_OPACITY;
|
||||
n.color = glm::vec4(1.f, 1.f, 1.f, 1.f);
|
||||
}
|
||||
ImGui::SameLine(0, 10);
|
||||
ImGui::ColorEdit3("Color", glm::value_ptr(n.color) ) ;
|
||||
ImGui::ColorEdit3("Color", glm::value_ptr(n.color), ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_NoLabel ) ;
|
||||
ImGui::SameLine(0, 5);
|
||||
ImGui::SetNextItemWidth(RIGHT_ALIGN);
|
||||
int mode = n.blending;
|
||||
if (ImGui::Combo("Blending", &mode, "Normal\0Screen\0Inverse\0Addition\0Subtract\0") )
|
||||
n.blending = Shader::BlendMode(mode);
|
||||
|
||||
ImGui::PopID();
|
||||
}
|
||||
@@ -130,6 +144,7 @@ void ImGuiVisitor::visit(ImageShader &n)
|
||||
n.contrast = 0.f;
|
||||
}
|
||||
ImGui::SameLine(0, 10);
|
||||
ImGui::SetNextItemWidth(RIGHT_ALIGN);
|
||||
float bc[2] = { n.brightness, n.contrast};
|
||||
if ( ImGui::SliderFloat2("B & C", bc, -1.0, 1.0) )
|
||||
{
|
||||
@@ -148,6 +163,7 @@ void ImGuiVisitor::visit(ImageProcessingShader &n)
|
||||
n.contrast = 0.f;
|
||||
}
|
||||
ImGui::SameLine(0, 10);
|
||||
ImGui::SetNextItemWidth(RIGHT_ALIGN);
|
||||
float bc[2] = { n.brightness, n.contrast};
|
||||
if ( ImGui::SliderFloat2("B & C", bc, -1.0, 1.0) )
|
||||
{
|
||||
@@ -157,41 +173,51 @@ void ImGuiVisitor::visit(ImageProcessingShader &n)
|
||||
|
||||
if (ImGuiToolkit::ButtonIcon(2, 1)) n.saturation = 0.f;
|
||||
ImGui::SameLine(0, 10);
|
||||
ImGui::SetNextItemWidth(RIGHT_ALIGN);
|
||||
ImGui::SliderFloat("Saturation", &n.saturation, -1.0, 1.0);
|
||||
|
||||
if (ImGuiToolkit::ButtonIcon(12, 4)) n.hueshift = 0.f;
|
||||
ImGui::SameLine(0, 10);
|
||||
ImGui::SetNextItemWidth(RIGHT_ALIGN);
|
||||
ImGui::SliderFloat("Hue shift", &n.hueshift, 0.0, 1.0);
|
||||
|
||||
if (ImGuiToolkit::ButtonIcon(8, 1)) n.threshold = 0.f;
|
||||
ImGui::SameLine(0, 10);
|
||||
ImGui::SetNextItemWidth(RIGHT_ALIGN);
|
||||
ImGui::SliderFloat("Threshold", &n.threshold, 0.0, 1.0);
|
||||
|
||||
if (ImGuiToolkit::ButtonIcon(3, 1)) n.lumakey = 0.f;
|
||||
ImGui::SameLine(0, 10);
|
||||
ImGui::SetNextItemWidth(RIGHT_ALIGN);
|
||||
ImGui::SliderFloat("Lumakey", &n.lumakey, 0.0, 1.0);
|
||||
|
||||
if (ImGuiToolkit::ButtonIcon(18, 1)) n.nbColors = 0;
|
||||
ImGui::SameLine(0, 10);
|
||||
ImGui::SliderInt("Posterize", &n.nbColors, 0, 16);
|
||||
ImGui::SetNextItemWidth(RIGHT_ALIGN);
|
||||
ImGui::SliderInt("Posterize", &n.nbColors, 0, 16, "%d colors");
|
||||
|
||||
if (ImGuiToolkit::ButtonIcon(1, 7)) n.filter = 0;
|
||||
ImGui::SameLine(0, 10);
|
||||
ImGui::SetNextItemWidth(RIGHT_ALIGN);
|
||||
ImGui::Combo("Filter", &n.filter, "None\0Blur\0Sharpen\0Edge\0Emboss\0Erode 3x3\0Erode 5x5\0Erode 7x7\0Dilate 3x3\0Dilate 5x5\0Dilate 7x7\0");
|
||||
|
||||
if (ImGuiToolkit::ButtonIcon(7, 1)) n.invert = 0;
|
||||
ImGui::SameLine(0, 10);
|
||||
ImGui::Combo("Invert", &n.invert, "None\0Invert color\0Invert Luminance\0");
|
||||
ImGui::SetNextItemWidth(RIGHT_ALIGN);
|
||||
// static const char* invert_names[3] = { "None", "Color", "Luminance" };
|
||||
// const char* current_invert_name = invert_names[n.invert];
|
||||
// ImGui::SliderInt("Invert", &n.invert, 0, 2, current_invert_name);
|
||||
ImGui::Combo("Invert", &n.invert, "None\0Invert Color\0Invert Luminance\0");
|
||||
|
||||
if (ImGuiToolkit::ButtonIcon(14, 4)) n.chromadelta = 0.f;
|
||||
ImGui::SameLine(0, 10);
|
||||
ImGui::SliderFloat("Chromakey", &n.chromadelta, 0.0, 1.0);
|
||||
|
||||
if (ImGuiToolkit::ButtonIcon(6, 4))
|
||||
if (ImGuiToolkit::ButtonIcon(13, 4)) {
|
||||
n.chromakey = glm::vec4(0.f, 1.f, 0.f, 1.f);
|
||||
n.chromadelta = 0.f;
|
||||
}
|
||||
ImGui::SameLine(0, 10);
|
||||
ImGui::ColorEdit3("Chroma color", glm::value_ptr(n.chromakey) ) ;
|
||||
|
||||
ImGui::ColorEdit3("Chroma color", glm::value_ptr(n.chromakey), ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_NoLabel ) ;
|
||||
ImGui::SameLine(0, 5);
|
||||
ImGui::SetNextItemWidth(RIGHT_ALIGN);
|
||||
ImGui::SliderFloat("Chromakey", &n.chromadelta, 0.0, 1.0, "%.2f tolerance");
|
||||
|
||||
ImGui::PopID();
|
||||
}
|
||||
|
||||
@@ -24,8 +24,8 @@ ShadingProgram simpleShadingProgram("shaders/simple.vs", "shaders/simple.fs");
|
||||
|
||||
// Blending presets for matching with Shader::BlendMode
|
||||
GLenum blending_equation[6] = { GL_FUNC_ADD, GL_FUNC_ADD, GL_FUNC_REVERSE_SUBTRACT, GL_FUNC_ADD, GL_FUNC_REVERSE_SUBTRACT, GL_FUNC_ADD};
|
||||
GLenum blending_source_function[6] = { GL_SRC_ALPHA,GL_SRC_ALPHA,GL_SRC_ALPHA,GL_SRC_ALPHA,GL_SRC_ALPHA,GL_SRC_ALPHA,};
|
||||
GLenum blending_destination_function[6] = {GL_ONE, GL_ONE, GL_ONE, GL_DST_COLOR, GL_DST_COLOR, GL_ONE_MINUS_SRC_ALPHA};
|
||||
GLenum blending_source_function[6] = { GL_SRC_ALPHA,GL_SRC_ALPHA,GL_SRC_ALPHA,GL_SRC_ALPHA,GL_SRC_ALPHA,GL_SRC_ALPHA};
|
||||
GLenum blending_destination_function[6] = {GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE, GL_DST_COLOR, GL_DST_COLOR, GL_ONE_MINUS_SRC_ALPHA};
|
||||
|
||||
|
||||
|
||||
@@ -198,7 +198,7 @@ void Shader::use()
|
||||
program_->setUniform("iResolution", iResolution);
|
||||
|
||||
// Blending Function
|
||||
if ( blending != BLEND_NONE) {
|
||||
if ( blending != BLEND_CUSTOM) {
|
||||
glEnable(GL_BLEND);
|
||||
glBlendEquation(blending_equation[blending]);
|
||||
glBlendFunc(blending_source_function[blending], blending_destination_function[blending]);
|
||||
|
||||
Reference in New Issue
Block a user