OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "SkBitmapProcShader.h" | 8 #include "SkBitmapProcShader.h" |
9 #include "SkBitmapProcState.h" | 9 #include "SkBitmapProcState.h" |
10 #include "SkColor.h" | 10 #include "SkColor.h" |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
169 fAmbientColorUni = uniformHandler->addUniform(kFragment_GrShaderFlag , | 169 fAmbientColorUni = uniformHandler->addUniform(kFragment_GrShaderFlag , |
170 kVec3f_GrSLType, kDefa ult_GrSLPrecision, | 170 kVec3f_GrSLType, kDefa ult_GrSLPrecision, |
171 "AmbientColor", &ambie ntColorUniName); | 171 "AmbientColor", &ambie ntColorUniName); |
172 | 172 |
173 fragBuilder->codeAppendf("vec4 diffuseColor = %s;", args.fInputColor ); | 173 fragBuilder->codeAppendf("vec4 diffuseColor = %s;", args.fInputColor ); |
174 | 174 |
175 SkString dstNormalName("dstNormal"); | 175 SkString dstNormalName("dstNormal"); |
176 this->emitChild(0, nullptr, &dstNormalName, args); | 176 this->emitChild(0, nullptr, &dstNormalName, args); |
177 | 177 |
178 fragBuilder->codeAppendf("vec3 normal = %s.xyz;", dstNormalName.c_st r()); | 178 fragBuilder->codeAppendf("vec3 normal = %s.xyz;", dstNormalName.c_st r()); |
179 | |
jvanverth1
2016/07/07 19:08:35
Nit: if you remove this line, then this file doesn
vjiaoblack
2016/07/07 19:17:56
Done.
| |
179 fragBuilder->codeAppendf("float NdotL = clamp(dot(normal, %s), 0.0, 1.0);", | 180 fragBuilder->codeAppendf("float NdotL = clamp(dot(normal, %s), 0.0, 1.0);", |
180 lightDirUniName); | 181 lightDirUniName); |
181 // diffuse light | 182 // diffuse light |
182 fragBuilder->codeAppendf("vec3 result = %s*diffuseColor.rgb*NdotL;", lightColorUniName); | 183 fragBuilder->codeAppendf("vec3 result = %s*diffuseColor.rgb*NdotL;", lightColorUniName); |
183 // ambient light | 184 // ambient light |
184 fragBuilder->codeAppendf("result += %s;", ambientColorUniName); | 185 fragBuilder->codeAppendf("result += %s;", ambientColorUniName); |
185 fragBuilder->codeAppendf("%s = vec4(result.rgb, diffuseColor.a);", a rgs.fOutputColor); | 186 fragBuilder->codeAppendf("%s = vec4(result.rgb, diffuseColor.a);", a rgs.fOutputColor); |
186 } | 187 } |
187 | 188 |
188 static void GenKey(const GrProcessor& proc, const GrGLSLCaps&, | 189 static void GenKey(const GrProcessor& proc, const GrGLSLCaps&, |
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
501 std::move(lights)); | 502 std::move(lights)); |
502 } | 503 } |
503 | 504 |
504 /////////////////////////////////////////////////////////////////////////////// | 505 /////////////////////////////////////////////////////////////////////////////// |
505 | 506 |
506 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkLightingShader) | 507 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkLightingShader) |
507 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkLightingShaderImpl) | 508 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkLightingShaderImpl) |
508 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END | 509 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END |
509 | 510 |
510 /////////////////////////////////////////////////////////////////////////////// | 511 /////////////////////////////////////////////////////////////////////////////// |
OLD | NEW |