Fixed distance field interpolation for gamma correct rendering

Bug: skia:
Change-Id: I9037decfeb9b2ab673434bb3c4b7f55aca186d68
Reviewed-on: https://skia-review.googlesource.com/13872
Reviewed-by: Jim Van Verth <jvanverth@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
This commit is contained in:
Brian Osman 2017-04-19 16:08:30 -04:00 committed by Skia Commit-Bot
parent 13dddce65f
commit ab8ce1a5ae

View File

@ -163,7 +163,7 @@ public:
// mapped linearly to coverage, so use a linear step:
if (isGammaCorrect) {
fragBuilder->codeAppend(
"float val = clamp(distance + afwidth / (2.0 * afwidth), 0.0, 1.0);");
"float val = clamp((distance + afwidth) / (2.0 * afwidth), 0.0, 1.0);");
} else {
fragBuilder->codeAppend("float val = smoothstep(-afwidth, afwidth, distance);");
}
@ -419,7 +419,7 @@ public:
// mapped linearly to coverage, so use a linear step:
if (isGammaCorrect) {
fragBuilder->codeAppend(
"float val = clamp(distance + afwidth / (2.0 * afwidth), 0.0, 1.0);");
"float val = clamp((distance + afwidth) / (2.0 * afwidth), 0.0, 1.0);");
} else {
fragBuilder->codeAppend("float val = smoothstep(-afwidth, afwidth, distance);");
}
@ -713,7 +713,7 @@ public:
// mapped linearly to coverage, so use a linear step:
if (isGammaCorrect) {
fragBuilder->codeAppend("vec4 val = "
"vec4(clamp(distance + vec3(afwidth) / vec3(2.0 * afwidth), 0.0, 1.0), 1.0);");
"vec4(clamp((distance + vec3(afwidth)) / vec3(2.0 * afwidth), 0.0, 1.0), 1.0);");
} else {
fragBuilder->codeAppend(
"vec4 val = vec4(smoothstep(vec3(-afwidth), vec3(afwidth), distance), 1.0);");