aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu
diff options
context:
space:
mode:
authorGravatar Brian Salomon <bsalomon@google.com>2017-07-17 16:44:32 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-07-18 12:40:16 +0000
commitcda20154b611c33b8fc8abf1f01d888166e19dcb (patch)
treed482dd7f4728d321b3700cc1132b0f025699c473 /src/gpu
parent0aa492d0f47d7becbd87c582a61591bdf2d17fa7 (diff)
Make dither range symmetric about 0
Change-Id: I0c2eec60beb665c7dca9b9fddc00ac112a1ff2e1 Reviewed-on: https://skia-review.googlesource.com/24121 Reviewed-by: Robert Phillips <robertphillips@google.com> Commit-Queue: Brian Salomon <bsalomon@google.com>
Diffstat (limited to 'src/gpu')
-rw-r--r--src/gpu/effects/GrDitherEffect.cpp2
-rw-r--r--src/gpu/effects/GrDitherEffect.fp4
2 files changed, 3 insertions, 3 deletions
diff --git a/src/gpu/effects/GrDitherEffect.cpp b/src/gpu/effects/GrDitherEffect.cpp
index 370e0eedd1..052ed4e36d 100644
--- a/src/gpu/effects/GrDitherEffect.cpp
+++ b/src/gpu/effects/GrDitherEffect.cpp
@@ -23,7 +23,7 @@ public:
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
const GrDitherEffect& _outer = args.fFp.cast<GrDitherEffect>();
(void) _outer;
- fragBuilder->codeAppendf("float r = fract(sin(dot(sk_FragCoord.xy, vec2(12.989800000000001, 78.233000000000004))) * 43758.545299999998);\n%s = clamp(0.0039215686274509803 * vec4(r) + %s, 0.0, 1.0);\n", args.fOutputColor, args.fInputColor ? args.fInputColor : "vec4(1)");
+ fragBuilder->codeAppendf("float r = fract(sin(dot(sk_FragCoord.xy, vec2(12.989800000000001, 78.233000000000004))) * 43758.545299999998) - 0.5;\n%s = clamp(0.0039215686274509803 * vec4(r) + %s, 0.0, 1.0);\n", args.fOutputColor, args.fInputColor ? args.fInputColor : "vec4(1)");
}
private:
void onSetData(const GrGLSLProgramDataManager& pdman, const GrFragmentProcessor& _proc) override {
diff --git a/src/gpu/effects/GrDitherEffect.fp b/src/gpu/effects/GrDitherEffect.fp
index 77ff009113..1c35b38cd2 100644
--- a/src/gpu/effects/GrDitherEffect.fp
+++ b/src/gpu/effects/GrDitherEffect.fp
@@ -8,8 +8,8 @@ void main() {
// For each channel c, add the random offset to the pixel to either bump
// it up or let it remain constant during quantization.
- float r = fract(sin(dot(sk_FragCoord.xy, vec2(12.9898, 78.233))) * 43758.5453);
- sk_OutColor = clamp(1.0 / 255.0 * vec4(r) + sk_InColor, 0, 1);
+ float r = fract(sin(dot(sk_FragCoord.xy, vec2(12.9898, 78.233))) * 43758.5453) - .5;
+ sk_OutColor = clamp(1 / 255.0 * vec4(r) + sk_InColor, 0, 1);
}
@test(testData) {