Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make ColorCorrection clamped by default, add Boolean setting #121

Merged
merged 1 commit into from
Jun 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
}
}