diff options
-rw-r--r-- | gm/lighting.cpp | 12 | ||||
-rw-r--r-- | src/effects/SkLightingImageFilter.cpp | 3 |
2 files changed, 14 insertions, 1 deletions
diff --git a/gm/lighting.cpp b/gm/lighting.cpp index 46474abc35..9db34fde3d 100644 --- a/gm/lighting.cpp +++ b/gm/lighting.cpp @@ -47,6 +47,18 @@ protected: make_bitmap(); fInitialized = true; } + canvas->clear(0xFF101010); + SkPaint checkPaint; + checkPaint.setColor(0xFF202020); + for (int y = 0; y < HEIGHT; y += 16) { + for (int x = 0; x < WIDTH; x += 16) { + canvas->save(); + canvas->translate(SkIntToScalar(x), SkIntToScalar(y)); + canvas->drawRect(SkRect::MakeXYWH(8, 0, 8, 8), checkPaint); + canvas->drawRect(SkRect::MakeXYWH(0, 8, 8, 8), checkPaint); + canvas->restore(); + } + } SkPoint3 pointLocation(0, 0, SkIntToScalar(10)); SkScalar azimuthRad = SkDegreesToRadians(SkIntToScalar(225)); SkScalar elevationRad = SkDegreesToRadians(SkIntToScalar(5)); diff --git a/src/effects/SkLightingImageFilter.cpp b/src/effects/SkLightingImageFilter.cpp index a83fe58250..f17318cecf 100644 --- a/src/effects/SkLightingImageFilter.cpp +++ b/src/effects/SkLightingImageFilter.cpp @@ -1286,7 +1286,8 @@ void GrGLSpecularLightingEffect::emitLightFunc(GrGLShaderBuilder* builder, SkStr SkString lightBody; lightBody.appendf("\tvec3 halfDir = vec3(normalize(surfaceToLight + vec3(0, 0, 1)));\n"); lightBody.appendf("\tfloat colorScale = %s * pow(dot(normal, halfDir), %s);\n", ks, shininess); - lightBody.appendf("\treturn vec4(lightColor * clamp(colorScale, 0.0, 1.0), 1.0);\n"); + lightBody.appendf("\tvec3 color = lightColor * clamp(colorScale, 0.0, 1.0);\n"); + lightBody.appendf("\treturn vec4(color, max(max(color.r, color.g), color.b));\n"); builder->emitFunction(GrGLShaderBuilder::kFragment_ShaderType, kVec4f_GrSLType, "light", |