| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 #ifndef SkLightingShader_DEFINED | 8 #ifndef SkLightingShader_DEFINED |
| 9 #define SkLightingShader_DEFINED | 9 #define SkLightingShader_DEFINED |
| 10 | 10 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 | 62 |
| 63 /** Returns a shader that lights the diffuse and normal maps with a single l
ight. | 63 /** Returns a shader that lights the diffuse and normal maps with a single l
ight. |
| 64 | 64 |
| 65 It returns a shader with a reference count of 1. | 65 It returns a shader with a reference count of 1. |
| 66 The caller should decrement the shader's reference count when done with
the shader. | 66 The caller should decrement the shader's reference count when done with
the shader. |
| 67 It is an error for count to be < 2. | 67 It is an error for count to be < 2. |
| 68 @param diffuse the diffuse bitmap | 68 @param diffuse the diffuse bitmap |
| 69 @param normal the normal map | 69 @param normal the normal map |
| 70 @param light the light applied to the normal map | 70 @param light the light applied to the normal map |
| 71 @param ambient the linear (unpremul) ambient light color. Range is
0..1/channel. | 71 @param ambient the linear (unpremul) ambient light color. Range is
0..1/channel. |
| 72 @param localMatrix the matrix mapping the textures to the dest rect | 72 @param localMatrix the matrix mapping the textures to the dest rect |
| 73 | 73 |
| 74 nullptr will be returned if: | 74 nullptr will be returned if: |
| 75 either 'diffuse' or 'normal' are empty | 75 either 'diffuse' or 'normal' are empty |
| 76 either 'diffuse' or 'normal' are too big (> 65535 on a side) | 76 either 'diffuse' or 'normal' are too big (> 65535 on a side) |
| 77 'diffuse' and 'normal' aren't the same size | 77 'diffuse' and 'normal' aren't the same size |
| 78 | 78 |
| 79 The lighting equation is currently: | 79 The lighting equation is currently: |
| 80 result = LightColor * DiffuseColor * (Normal * LightDir) + AmbientCo
lor | 80 result = LightColor * DiffuseColor * (Normal * LightDir) + AmbientCo
lor |
| 81 | 81 |
| 82 The normal map is currently assumed to be an 8888 image where the normal
at a texel | 82 The normal map is currently assumed to be an 8888 image where the normal
at a texel |
| 83 is retrieved by: | 83 is retrieved by: |
| 84 N.x = R-127; | 84 N.x = R-127; |
| 85 N.y = G-127; | 85 N.y = G-127; |
| 86 N.z = B-127; | 86 N.z = B-127; |
| 87 N.normalize(); | 87 N.normalize(); |
| 88 The +Z axis is thus encoded in RGB as (127, 127, 255) while the -Z axis
is | 88 The +Z axis is thus encoded in RGB as (127, 127, 255) while the -Z axis
is |
| 89 (127, 127, 0). | 89 (127, 127, 0). |
| 90 */ | 90 */ |
| 91 static sk_sp<SkShader> Make(const SkBitmap& diffuse, const SkBitmap& normal, | 91 static sk_sp<SkShader> Make(const SkBitmap& diffuse, const SkBitmap& normal, |
| 92 const Lights* lights, const SkVector& invNormRot
ation, | 92 const Lights* lights, const SkVector& invNormRot
ation, |
| 93 const SkMatrix* diffLocalMatrix, const SkMatrix*
normLocalMatrix); | 93 const SkMatrix* diffLocalMatrix, const SkMatrix*
normLocalMatrix); |
| 94 | 94 |
| 95 SK_DECLARE_FLATTENABLE_REGISTRAR_GROUP() | 95 SK_DECLARE_FLATTENABLE_REGISTRAR_GROUP() |
| 96 }; | 96 }; |
| 97 | 97 |
| 98 #endif | 98 #endif |
| OLD | NEW |