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