Add gamma and opacity to ColorCorrection
This commit is contained in:
@@ -19,10 +19,18 @@ class ColorCorrection : Filter(Shader.createFromCode(filterVertexCode, filterFra
|
|||||||
@DoubleParameter("hue shift", -180.0, 180.0, order = 3)
|
@DoubleParameter("hue shift", -180.0, 180.0, order = 3)
|
||||||
var hueShift: Double by parameters
|
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 {
|
init {
|
||||||
contrast = 0.0
|
contrast = 0.0
|
||||||
brightness = 0.0
|
brightness = 0.0
|
||||||
saturation = 0.0
|
saturation = 0.0
|
||||||
hueShift = 0.0
|
hueShift = 0.0
|
||||||
|
gamma = 1.0
|
||||||
|
opacity = 1.0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -6,6 +6,8 @@ uniform float brightness;
|
|||||||
uniform float saturation;
|
uniform float saturation;
|
||||||
uniform float contrast;
|
uniform float contrast;
|
||||||
uniform float hueShift;
|
uniform float hueShift;
|
||||||
|
uniform float gamma;
|
||||||
|
uniform float opacity;
|
||||||
|
|
||||||
uniform sampler2D tex0;
|
uniform sampler2D tex0;
|
||||||
in vec2 v_texCoord0;
|
in vec2 v_texCoord0;
|
||||||
@@ -56,7 +58,8 @@ vec3 shiftHue(in vec3 col, in float Shift) {
|
|||||||
void main() {
|
void main() {
|
||||||
vec4 color = texture(tex0, v_texCoord0);
|
vec4 color = texture(tex0, v_texCoord0);
|
||||||
vec4 nc = (color.a == 0.0) ? vec4(0.0) : vec4(color.rgb / color.a, color.a);
|
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));
|
nc.rgb = shiftHue(nc.rgb, (hueShift/360.0));
|
||||||
vec4 cc = brightnessMatrix(brightness) * contrastMatrix((contrast + 1)) * saturationMatrix(saturation + 1) * nc;
|
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;
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user