mirror of
https://github.com/brunoherbelin/vimix.git
synced 2025-12-08 00:40:02 +01:00
Updated Image Processing shader and GUI: gamma color processing follows
HSV transform. new Shader assignment operator.
This commit is contained in:
@@ -187,16 +187,15 @@ void ImGuiVisitor::visit(ImageProcessingShader &n)
|
||||
{
|
||||
ImGui::PushID(n.id());
|
||||
|
||||
if (ImGuiToolkit::ButtonIcon(4, 0)) n.gamma = glm::vec4(1.f, 1.f, 1.f, 1.f);
|
||||
float g[3] = { n.gamma.x, n.gamma.y, n.gamma.z};
|
||||
if (ImGuiToolkit::ButtonIcon(6, 2)) n.gamma = glm::vec4(1.f, 1.f, 1.f, 1.f);
|
||||
ImGui::SameLine(0, 10);
|
||||
ImGui::ColorEdit3("GammaColor", glm::value_ptr(n.gamma), ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_NoLabel) ;
|
||||
ImGui::SameLine(0, 5);
|
||||
ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN);
|
||||
if ( ImGui::SliderFloat3("RGB", g, 1.0, 10.0) )
|
||||
{
|
||||
n.gamma.x = g[0];
|
||||
n.gamma.y = g[1];
|
||||
n.gamma.z = g[2];
|
||||
}
|
||||
ImGui::SliderFloat("Gamma", &n.gamma.w, 0.5f, 10.f, "%.2f", 2.f);
|
||||
|
||||
// ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN);
|
||||
// ImGui::SliderFloat4("Levels", glm::value_ptr(n.levels), 0.0, 1.0);
|
||||
|
||||
if (ImGuiToolkit::ButtonIcon(4, 1)) {
|
||||
n.brightness = 0.f;
|
||||
@@ -216,7 +215,6 @@ void ImGuiVisitor::visit(ImageProcessingShader &n)
|
||||
ImGui::SetNextItemWidth(IMGUI_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(IMGUI_RIGHT_ALIGN);
|
||||
@@ -248,7 +246,7 @@ void ImGuiVisitor::visit(ImageProcessingShader &n)
|
||||
ImGui::Combo("Invert", &n.invert, "None\0Invert Color\0Invert Luminance\0");
|
||||
|
||||
if (ImGuiToolkit::ButtonIcon(13, 4)) {
|
||||
n.chromakey = glm::vec4(0.f, 1.f, 0.f, 1.f);
|
||||
n.chromakey = glm::vec4(0.f, 0.8f, 0.f, 1.f);
|
||||
n.chromadelta = 0.f;
|
||||
}
|
||||
ImGui::SameLine(0, 10);
|
||||
@@ -295,9 +293,9 @@ void ImGuiVisitor::visit (MediaSource& s)
|
||||
void ImGuiVisitor::visit (SessionSource& s)
|
||||
{
|
||||
ImGui::Text("Session File");
|
||||
if ( ImGui::Button("Make Current", ImVec2(IMGUI_RIGHT_ALIGN, 0)) )
|
||||
if ( ImGui::Button( ICON_FA_FILE_UPLOAD " Make Current", ImVec2(IMGUI_RIGHT_ALIGN, 0)) )
|
||||
Mixer::manager().set( s.detach() );
|
||||
if ( ImGui::Button( ICON_FA_FILE_IMPORT " Merge", ImVec2(IMGUI_RIGHT_ALIGN, 0)) )
|
||||
if ( ImGui::Button( ICON_FA_FILE_EXPORT " Import", ImVec2(IMGUI_RIGHT_ALIGN, 0)) )
|
||||
Mixer::manager().merge( s.detach() );
|
||||
|
||||
ImGuiToolkit::ButtonOpenUrl( SystemToolkit::path_filename(s.path()).c_str(), ImVec2(IMGUI_RIGHT_ALIGN, 0) );
|
||||
|
||||
@@ -59,11 +59,31 @@ void ImageProcessingShader::reset()
|
||||
filterid = 0;
|
||||
gamma = glm::vec4(1.f, 1.f, 1.f, 1.f);
|
||||
levels = glm::vec4(0.f, 1.f, 0.f, 1.f);
|
||||
chromakey = glm::vec4(0.f, 1.f, 0.f, 0.f);
|
||||
chromakey = glm::vec4(0.f, 0.8f, 0.f, 0.f);
|
||||
chromadelta = 0.f;
|
||||
|
||||
}
|
||||
|
||||
void ImageProcessingShader::operator = (const ImageProcessingShader &S )
|
||||
{
|
||||
Shader::operator =(S);
|
||||
|
||||
brightness = S.brightness;
|
||||
contrast = S.contrast;
|
||||
saturation = S.saturation;
|
||||
hueshift = S.hueshift;
|
||||
threshold = S.threshold;
|
||||
lumakey = S.lumakey;
|
||||
nbColors = S.nbColors;
|
||||
invert = S.invert;
|
||||
filterid = S.filterid;
|
||||
gamma = S.gamma;
|
||||
levels = S.levels;
|
||||
chromakey = S.chromakey;
|
||||
chromadelta = S.chromadelta;
|
||||
}
|
||||
|
||||
|
||||
void ImageProcessingShader::accept(Visitor& v) {
|
||||
// Shader::accept(v);
|
||||
v.visit(*this);
|
||||
|
||||
@@ -17,6 +17,8 @@ public:
|
||||
void reset() override;
|
||||
void accept(Visitor& v) override;
|
||||
|
||||
void operator = (const ImageProcessingShader &S);
|
||||
|
||||
// // textures resolution
|
||||
// glm::vec3 iChannelResolution[1];
|
||||
|
||||
|
||||
@@ -37,15 +37,20 @@ void ImageShader::use()
|
||||
program_->setUniform("stipple", stipple);
|
||||
|
||||
glActiveTexture(GL_TEXTURE1);
|
||||
if ( mask < 9 )
|
||||
if ( mask < 9 ) {
|
||||
glBindTexture(GL_TEXTURE_2D, mask_presets[mask]);
|
||||
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
}
|
||||
else
|
||||
glBindTexture(GL_TEXTURE_2D, custom_textureindex);
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
|
||||
}
|
||||
|
||||
|
||||
void ImageShader::reset()
|
||||
{
|
||||
Shader::reset();
|
||||
@@ -57,6 +62,16 @@ void ImageShader::reset()
|
||||
stipple = 0.f;
|
||||
}
|
||||
|
||||
void ImageShader::operator = (const ImageShader &S )
|
||||
{
|
||||
Shader::operator =(S);
|
||||
|
||||
mask = S.mask;
|
||||
custom_textureindex = S.custom_textureindex;
|
||||
stipple = S.stipple;
|
||||
}
|
||||
|
||||
|
||||
void ImageShader::accept(Visitor& v) {
|
||||
Shader::accept(v);
|
||||
v.visit(*this);
|
||||
|
||||
@@ -22,6 +22,7 @@ public:
|
||||
void reset() override;
|
||||
void accept(Visitor& v) override;
|
||||
|
||||
void operator = (const ImageShader &S);
|
||||
|
||||
uint mask;
|
||||
uint custom_textureindex;
|
||||
|
||||
@@ -180,6 +180,13 @@ Shader::Shader() : blending(BLEND_OPACITY)
|
||||
reset();
|
||||
}
|
||||
|
||||
|
||||
void Shader::operator = (const Shader &S )
|
||||
{
|
||||
color = S.color;
|
||||
blending = S.blending;
|
||||
}
|
||||
|
||||
void Shader::accept(Visitor& v) {
|
||||
v.visit(*this);
|
||||
}
|
||||
|
||||
3
Shader.h
3
Shader.h
@@ -41,7 +41,6 @@ class Shader
|
||||
|
||||
public:
|
||||
Shader();
|
||||
// virtual ~Shader() {}
|
||||
|
||||
// unique identifyer generated at instanciation
|
||||
inline int id () const { return id_; }
|
||||
@@ -50,6 +49,8 @@ public:
|
||||
virtual void reset();
|
||||
virtual void accept(Visitor& v);
|
||||
|
||||
void operator = (const Shader &D );
|
||||
|
||||
glm::mat4 projection;
|
||||
glm::mat4 modelview;
|
||||
glm::vec4 color;
|
||||
|
||||
@@ -1128,9 +1128,9 @@ void Navigator::RenderSourcePannel(Source *s)
|
||||
// delete button
|
||||
ImGui::Text(" ");
|
||||
// Action on source
|
||||
if ( ImGui::Button("Clone", ImVec2(ImGui::GetContentRegionAvail().x, 0)) )
|
||||
if ( ImGui::Button( ICON_FA_SHARE_SQUARE " Clone", ImVec2(ImGui::GetContentRegionAvail().x, 0)) )
|
||||
Mixer::manager().cloneCurrentSource();
|
||||
if ( ImGui::Button("Delete", ImVec2(ImGui::GetContentRegionAvail().x, 0)) ) {
|
||||
if ( ImGui::Button( ICON_FA_BACKSPACE " Delete", ImVec2(ImGui::GetContentRegionAvail().x, 0)) ) {
|
||||
Mixer::manager().deleteSource(s);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ void main()
|
||||
float maskIntensity = (maskColor.r + maskColor.g + maskColor.b) / 3.0;
|
||||
|
||||
float A = textureColor.a * vertexColor.a * color.a * maskIntensity;
|
||||
A -= stipple * ( int(gl_FragCoord.x + gl_FragCoord.y) % 2 > 0 ? 0.0 : 9.0 );
|
||||
A -= stipple * ( int(gl_FragCoord.x + gl_FragCoord.y) % 2 > 0 ? 0.05 : 0.95 );
|
||||
|
||||
// output RGBA
|
||||
FragColor = vec4(RGB, clamp(A, 0.0, 1.0) );
|
||||
|
||||
@@ -326,9 +326,8 @@ void main(void)
|
||||
// chromakey
|
||||
alpha -= mix( 0.0, 1.0 - alphachromakey( transformedRGB, chromakey.rgb, chromadelta), float(chromadelta > 0.0001) );
|
||||
|
||||
// color transformation
|
||||
// brightness and contrast transformation
|
||||
transformedRGB = mix(vec3(0.62), transformedRGB, contrast + 1.0) + brightness;
|
||||
transformedRGB = LevelsControl(transformedRGB, levels.x, gamma.rgb * gamma.a, levels.y, levels.z, levels.w);
|
||||
|
||||
// RGB invert
|
||||
transformedRGB = vec3(float(invert==1)) + ( transformedRGB * vec3(1.0 - 2.0 * float(invert==1)) );
|
||||
@@ -352,11 +351,14 @@ void main(void)
|
||||
alpha -= mix( 0.0, step( transformedHSL.z, lumakey ), float(lumakey > EPSILON));
|
||||
|
||||
// level threshold
|
||||
transformedHSL = mix( transformedHSL, vec3(0.0, 0.0, step( transformedHSL.z, threshold )), float(threshold > EPSILON));
|
||||
transformedHSL = mix( transformedHSL, vec3(0.0, 0.0, 0.95 - step( transformedHSL.z, threshold )), float(threshold > EPSILON));
|
||||
|
||||
// after operations on HSL, convert back to RGB
|
||||
transformedRGB = HSV2RGB(transformedHSL);
|
||||
|
||||
// apply gamma correction
|
||||
transformedRGB = LevelsControl(transformedRGB, levels.x, gamma.rgb * gamma.a, levels.y, levels.z, levels.w);
|
||||
|
||||
// apply base color and alpha for final fragment color
|
||||
FragColor = vec4(transformedRGB * vertexColor.rgb * color.rgb, clamp(alpha, 0.0, 1.0) );
|
||||
|
||||
|
||||
Reference in New Issue
Block a user