OLD | NEW |
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 Loading... |
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 Loading... |
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 |
OLD | NEW |