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

Unified Diff: src/core/SkShadowShader.cpp

Issue 2298603004: added point light attenuations to raster (Closed)
Patch Set: 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkShadowShader.cpp
diff --git a/src/core/SkShadowShader.cpp b/src/core/SkShadowShader.cpp
index 09d0bcaf5080c2822b3abd9dc4e7cb17bb1efaac..372a0faee6ff1e89ac4962b05d60e53cfc4ce0ee 100644
--- a/src/core/SkShadowShader.cpp
+++ b/src/core/SkShadowShader.cpp
@@ -765,8 +765,23 @@ void SkShadowShaderImpl::ShadowShaderContext::shadeSpan(int x, int y,
totalLight.fX += light.dir().fZ * light.color().fX * lightProb;
totalLight.fY += light.dir().fZ * light.color().fY * lightProb;
totalLight.fZ += light.dir().fZ * light.color().fZ * lightProb;
- } else {
- totalLight += light.color();
+
robertphillips 2016/08/31 13:44:27 Maybe: } else { SkASSERT(light.type() == SkLig
vjiaoblack 2016/08/31 13:53:27 Done.
+ } else if (light.type() == SkLights::Light::kPoint_LightType) {
robertphillips 2016/08/31 13:44:27 Move this line out of the if-then block and share
vjiaoblack 2016/08/31 13:53:27 Done.
+ int pvDepth = SkColorGetB(povDepthColor);
+
+ SkVector3 fragToLight = SkVector3::Make(light.pos().fX - (x + i),
robertphillips 2016/08/31 13:44:27 where's this 400 coming from?
vjiaoblack 2016/08/31 13:53:27 Done.
+ light.pos().fY - (400 - y),
+ light.pos().fZ - pvDepth);
+
+ SkScalar dist = fragToLight.length();
+ SkScalar normalizedZ = fragToLight.fZ / dist;
+
+ SkScalar attenuationValue = dist / light.intensity();
jvanverth1 2016/08/31 17:18:23 This is the old lighting equation.
vjiaoblack 2016/08/31 17:58:28 Done.
+ attenuationValue = attenuationValue * attenuationValue + 1.0f;
+
robertphillips 2016/08/31 13:44:27 // assume object normals are pointing straight up
vjiaoblack 2016/08/31 13:53:27 Done.
+ totalLight.fX += normalizedZ * light.color().fX / attenuationValue;
jvanverth1 2016/08/31 17:18:22 If you precompute 1/attenuation and multiply by th
vjiaoblack 2016/08/31 17:58:28 Done.
+ totalLight.fY += normalizedZ * light.color().fY / attenuationValue;
+ totalLight.fZ += normalizedZ * light.color().fZ / attenuationValue;
}
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698