Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(144)

Unified Diff: src/core/SkLightingShader.cpp

Issue 2287553002: Moved ambient lights out of SkLight's light array (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: added ambient light calculations to Raster renderer of LightingShader Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/core/SkCanvas.cpp ('k') | src/core/SkLights.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkLightingShader.cpp
diff --git a/src/core/SkLightingShader.cpp b/src/core/SkLightingShader.cpp
index 8fde8bfd37dedc66a244d323be8d40fa92ce87ef..9030a192b47760e10d7ca94bdc7c6d90eb4db8f2 100644
--- a/src/core/SkLightingShader.cpp
+++ b/src/core/SkLightingShader.cpp
@@ -122,11 +122,9 @@ public:
LightingFP(sk_sp<GrFragmentProcessor> normalFP, sk_sp<SkLights> lights) {
// fuse all ambient lights into a single one
- fAmbientColor.set(0.0f, 0.0f, 0.0f);
+ fAmbientColor = lights->ambientLightColor();
for (int i = 0; i < lights->numLights(); ++i) {
- if (SkLights::Light::kAmbient_LightType == lights->light(i).type()) {
- fAmbientColor += lights->light(i).color();
- } else if (SkLights::Light::kDirectional_LightType == lights->light(i).type()) {
+ if (SkLights::Light::kDirectional_LightType == lights->light(i).type()) {
fDirectionalLights.push_back(lights->light(i));
// TODO get the handle to the shadow map if there is one
} else {
@@ -386,6 +384,12 @@ void SkLightingShaderImpl::LightingShaderContext::shadeSpan(int x, int y,
}
SkColor3f accum = SkColor3f::Make(0.0f, 0.0f, 0.0f);
+
+ // Adding ambient light
+ accum.fX += lightShader.fLights->ambientLightColor().fX * SkColorGetR(diffColor);
+ accum.fY += lightShader.fLights->ambientLightColor().fY * SkColorGetG(diffColor);
+ accum.fZ += lightShader.fLights->ambientLightColor().fZ * SkColorGetB(diffColor);
+
// This is all done in linear unpremul color space (each component 0..255.0f though)
for (int l = 0; l < lightShader.fLights->numLights(); ++l) {
const SkLights::Light& light = lightShader.fLights->light(l);
« no previous file with comments | « src/core/SkCanvas.cpp ('k') | src/core/SkLights.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698