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

Unified Diff: src/core/SkLights.cpp

Issue 2246463004: Added distance attenuation and diffuse shading to PointLights (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: disabled shadows: 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 | « samplecode/SampleShadowing.cpp ('k') | src/core/SkShadowShader.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkLights.cpp
diff --git a/src/core/SkLights.cpp b/src/core/SkLights.cpp
index a172de4fabb52316e0c7c330170f3b6d6aec90e9..7d8f9ed7a58407c7a877d4089ae0741d0107a10c 100644
--- a/src/core/SkLights.cpp
+++ b/src/core/SkLights.cpp
@@ -29,6 +29,10 @@ sk_sp<SkLights> SkLights::MakeFromBuffer(SkReadBuffer& buf) {
if (!buf.readScalarArray(&dirOrPos.fX, 3)) {
return nullptr;
}
+ SkScalar intensity = 0.0f;
+ if (isPoint) {
+ intensity = buf.readScalar();
+ }
sk_sp<SkImage> depthMap;
bool hasShadowMap = buf.readBool();
@@ -39,7 +43,7 @@ sk_sp<SkLights> SkLights::MakeFromBuffer(SkReadBuffer& buf) {
}
if (isPoint) {
- Light light = Light::MakePoint(color, dirOrPos);
+ Light light = Light::MakePoint(color, dirOrPos, intensity);
light.setShadowMap(depthMap);
builder.add(light);
} else {
@@ -66,7 +70,12 @@ void SkLights::flatten(SkWriteBuffer& buf) const {
buf.writeBool(isPoint);
buf.writeScalarArray(&light.color().fX, 3);
if (!isAmbient) {
- buf.writeScalarArray(&light.dir().fX, 3);
+ if (isPoint) {
+ buf.writeScalarArray(&light.pos().fX, 3);
+ buf.writeScalar(light.intensity());
+ } else {
+ buf.writeScalarArray(&light.dir().fX, 3);
+ }
bool hasShadowMap = light.getShadowMap() != nullptr;
buf.writeBool(hasShadowMap);
if (hasShadowMap) {
« no previous file with comments | « samplecode/SampleShadowing.cpp ('k') | src/core/SkShadowShader.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698