Skip to content

Commit

Permalink
Make ColorCorrection clamped by default, add Boolean setting (#121)
Browse files Browse the repository at this point in the history
  • Loading branch information
hamoid authored Jun 6, 2020
1 parent fd3b13a commit dd2bd34
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
5 changes: 5 additions & 0 deletions orx-fx/src/main/kotlin/color/ColorCorrection.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package org.openrndr.extra.fx.color

import org.openrndr.draw.*
import org.openrndr.extra.fx.filterFragmentUrl
import org.openrndr.extra.parameters.BooleanParameter
import org.openrndr.extra.parameters.Description
import org.openrndr.extra.parameters.DoubleParameter

Expand All @@ -25,12 +26,16 @@ class ColorCorrection : Filter(filterShaderFromUrl(filterFragmentUrl("color/colo
@DoubleParameter("opacity", 0.0, 1.0, order = 5)
var opacity: Double by parameters

@BooleanParameter("clamp", order = 6)
var clamped: Boolean by parameters

init {
contrast = 0.0
brightness = 0.0
saturation = 0.0
hueShift = 0.0
gamma = 1.0
opacity = 1.0
clamped = true
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ uniform float contrast;
uniform float hueShift;
uniform float gamma;
uniform float opacity;
uniform bool clamped;

uniform sampler2D tex0;
in vec2 v_texCoord0;
Expand Down Expand Up @@ -61,5 +62,9 @@ void main() {
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 * opacity;
if(clamped) {
o_color = clamp(vec4(cc.rgb, 1.0) * color.a * opacity, 0.0, 1.0);
} else {
o_color = vec4(cc.rgb, 1.0) * color.a * opacity;
}
}

0 comments on commit dd2bd34

Please sign in to comment.