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

Side by Side Diff: src/core/SkRadialShadowMapShader.cpp

Issue 2323383002: made point lights linear attenuation; also fixed point light depth bug (Closed)
Patch Set: added comments! Created 4 years, 3 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 unified diff | Download patch
« no previous file with comments | « samplecode/SampleShadowing.cpp ('k') | src/core/SkShadowShader.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2016 Google Inc. 2 * Copyright 2016 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 "SkLights.h" 8 #include "SkLights.h"
9 #include "SkPoint3.h" 9 #include "SkPoint3.h"
10 #include "SkRadialShadowMapShader.h" 10 #include "SkRadialShadowMapShader.h"
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 kInt_GrSLType, 135 kInt_GrSLType,
136 kDefault_GrSLPrecision, 136 kDefault_GrSLPrecision,
137 "height", &heightUniName); 137 "height", &heightUniName);
138 138
139 139
140 SkString occluder("occluder"); 140 SkString occluder("occluder");
141 this->emitChild(0, nullptr, &occluder, args); 141 this->emitChild(0, nullptr, &occluder, args);
142 142
143 // Modify the input texture coordinates to index into our 1D output 143 // Modify the input texture coordinates to index into our 1D output
144 fragBuilder->codeAppend("float distHere;"); 144 fragBuilder->codeAppend("float distHere;");
145 fragBuilder->codeAppend("float closestDistHere = 0;"); 145
146 // we use a max shadow distance of 2 times the max of width/height
147 fragBuilder->codeAppend("float closestDistHere = 2;");
146 fragBuilder->codeAppend("vec2 coords = vMatrixCoord_0_0_Stage0;"); 148 fragBuilder->codeAppend("vec2 coords = vMatrixCoord_0_0_Stage0;");
147 fragBuilder->codeAppend("coords.y = 0;"); 149 fragBuilder->codeAppend("coords.y = 0;");
148 fragBuilder->codeAppend("vec2 destCoords = vec2(0,0);"); 150 fragBuilder->codeAppend("vec2 destCoords = vec2(0,0);");
149 fragBuilder->codeAppendf("float step = 1.0 / %s;", heightUniName); 151 fragBuilder->codeAppendf("float step = 1.0 / %s;", heightUniName);
150 152
151 // assume that we are at 0, 0 light pos 153 // assume that we are at 0, 0 light pos
152 // TODO use correct light positions 154 // TODO use correct light positions
153 155
154 // this goes through each depth value in the final output buffer, 156 // this goes through each depth value in the final output buffer,
155 // basically raycasting outwards, and finding the first collision. 157 // basically raycasting outwards, and finding the first collision.
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 422
421 /////////////////////////////////////////////////////////////////////////////// 423 ///////////////////////////////////////////////////////////////////////////////
422 424
423 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkRadialShadowMapShader) 425 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkRadialShadowMapShader)
424 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkRadialShadowMapShaderImpl) 426 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkRadialShadowMapShaderImpl)
425 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END 427 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END
426 428
427 /////////////////////////////////////////////////////////////////////////////// 429 ///////////////////////////////////////////////////////////////////////////////
428 430
429 #endif 431 #endif
OLDNEW
« 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