Add gamma and opacity to ColorCorrection

This commit is contained in:
Edwin Jakobs
2020-02-13 17:18:46 +01:00
parent 614b205f99
commit 1d2d06daf0
2 changed files with 12 additions and 1 deletions

View File

@@ -19,10 +19,18 @@ class ColorCorrection : Filter(Shader.createFromCode(filterVertexCode, filterFra
@DoubleParameter("hue shift", -180.0, 180.0, order = 3)
var hueShift: Double by parameters
@DoubleParameter("gamma", 0.0, 5.0, order = 4)
var gamma: Double by parameters
@DoubleParameter("opacity", 0.0, 1.0, order = 5)
var opacity: Double by parameters
init {
contrast = 0.0
brightness = 0.0
saturation = 0.0
hueShift = 0.0
gamma = 1.0
opacity = 1.0
}
}

View File

@@ -6,6 +6,8 @@ uniform float brightness;
uniform float saturation;
uniform float contrast;
uniform float hueShift;
uniform float gamma;
uniform float opacity;
uniform sampler2D tex0;
in vec2 v_texCoord0;
@@ -56,7 +58,8 @@ vec3 shiftHue(in vec3 col, in float Shift) {
void main() {
vec4 color = texture(tex0, v_texCoord0);
vec4 nc = (color.a == 0.0) ? vec4(0.0) : vec4(color.rgb / color.a, color.a);
nc.rgb = pow(nc.rgb, vec3(gamma));
nc.rgb = shiftHue(nc.rgb, (hueShift/360.0));
vec4 cc = brightnessMatrix(brightness) * contrastMatrix((contrast + 1)) * saturationMatrix(saturation + 1) * nc;
o_color = vec4(cc.rgb, 1.0) * color.a;
o_color = vec4(cc.rgb, 1.0) * color.a * opacity;
}