|
8 | 8 |
|
9 | 9 | #import "CCEffect.h"
|
10 | 10 |
|
| 11 | +/** |
| 12 | + * CCEffectGlass uses reflection and refraction to simulate the appearance of a transparent object |
| 13 | + * contained within an environment. Refraction is controlled with a single refraction strength value, |
| 14 | + * the normal map, and a refraction environment sprite. Reflection is controlled with two fresnel |
| 15 | + * reflectance values, the normal map, and a reflection environment sprite (which may be different |
| 16 | + * from the refraction environment). |
| 17 | + * |
| 18 | + */ |
11 | 19 | @interface CCEffectGlass : CCEffect
|
12 | 20 |
|
| 21 | +/// ----------------------------------------------------------------------- |
| 22 | +/// @name Accessing Effect Attributes |
| 23 | +/// ----------------------------------------------------------------------- |
| 24 | + |
| 25 | +/** The refraction strength value. This value is in the range [-1..1] with -1 |
| 26 | + * resulting in maximum minification of the refracted image, 0 resulting in no |
| 27 | + * refraction, and 1 resulting in maximum magnification of the refracted image. |
| 28 | + */ |
13 | 29 | @property (nonatomic) float refraction;
|
| 30 | + |
| 31 | +/** The bias term in the fresnel reflectance equation: |
| 32 | + * reflectance = max(0.0, fresnelBias + (1 - fresnelBias) * pow((1 - nDotV), fresnelPower)) |
| 33 | + * This value is in the range [0..1] and it controls the constant (view angle independent) contribution |
| 34 | + * to the reflectance equation. |
| 35 | + */ |
14 | 36 | @property (nonatomic) float fresnelBias;
|
| 37 | + |
| 38 | +/** The power term in the fresnel reflectance equation: |
| 39 | + * reflectance = max(0.0, fresnelBias + (1 - fresnelBias) * pow((1 - nDotV), fresnelPower)) |
| 40 | + * This value is in the range [0..inf] and it controls the view angle dependent contribution |
| 41 | + * to the reflectance equation. |
| 42 | + */ |
15 | 43 | @property (nonatomic) float fresnelPower;
|
| 44 | + |
| 45 | +/** The environment that will be refracted by the affected node. Typically this is a |
| 46 | + * sprite that serves as the background for the affected node so it appears that the viewer |
| 47 | + * is seeing the refracted environment through the refracting node. |
| 48 | + */ |
16 | 49 | @property (nonatomic) CCSprite *refractionEnvironment;
|
| 50 | + |
| 51 | +/** The environment that will be refracted by the affected node. Typically this is a sprite |
| 52 | + * that is not visible in the scene as it is conceptually "behind the viewer" and only visible |
| 53 | + * where reflected by the affected node. |
| 54 | + */ |
17 | 55 | @property (nonatomic) CCSprite *reflectionEnvironment;
|
| 56 | + |
| 57 | +/** The normal map that encodes the normal vectors of the affected node. Each pixel in the normal |
| 58 | + * map is a 3 component vector that is perpendicular to the surface of the sprite at that point. |
| 59 | + */ |
18 | 60 | @property (nonatomic) CCSpriteFrame *normalMap;
|
19 | 61 |
|
| 62 | + |
| 63 | +/// ----------------------------------------------------------------------- |
| 64 | +/// @name Initializing a CCEffectGlass object |
| 65 | +/// ----------------------------------------------------------------------- |
| 66 | + |
| 67 | +/** |
| 68 | + * Initializes a CCEffectGlass object with the following default parameters: |
| 69 | + * refraction : 1.0 |
| 70 | + * refractionEnvironment : nil |
| 71 | + * reflectionEnvironment : nil |
| 72 | + * normalMap : nil |
| 73 | + * |
| 74 | + * @return The CCEffectGlass object. |
| 75 | + */ |
20 | 76 | -(id)init;
|
| 77 | + |
| 78 | +/** |
| 79 | + * Initializes a CCEffectGlass object with the supplied parameters. |
| 80 | + * |
| 81 | + * @param refraction The refraction strength. |
| 82 | + * @param refractionEnvironment The environment image that will be refracted by the affected node. |
| 83 | + * @param reflectionEnvironment The environment image that will be reflected by the affected node. |
| 84 | + * @param normalMap The normal map of the affected node. This can also be specified as a property of the affected sprite. |
| 85 | + * |
| 86 | + * @return The CCEffectGlass object. |
| 87 | + */ |
21 | 88 | -(id)initWithRefraction:(float)refraction refractionEnvironment:(CCSprite *)refractionEnvironment reflectionEnvironment:(CCSprite *)reflectionEnvironment normalMap:(CCSpriteFrame *)normalMap;
|
| 89 | + |
| 90 | + |
| 91 | +/// ----------------------------------------------------------------------- |
| 92 | +/// @name Creating a CCEffectGlass object |
| 93 | +/// ----------------------------------------------------------------------- |
| 94 | + |
| 95 | +/** |
| 96 | + * Creates a CCEffectGlass object with the supplied parameters. |
| 97 | + * |
| 98 | + * @param refraction The refraction strength. |
| 99 | + * @param refractionEnvironment The environment image that will be refracted by the affected node. |
| 100 | + * @param reflectionEnvironment The environment image that will be reflected by the affected node. |
| 101 | + * @param normalMap The normal map of the affected node. This can also be specified as a property of the affected sprite. |
| 102 | + * |
| 103 | + * @return The CCEffectGlass object. |
| 104 | + */ |
22 | 105 | +(id)effectWithRefraction:(float)refraction refractionEnvironment:(CCSprite *)refractionEnvironment reflectionEnvironment:(CCSprite *)reflectionEnvironment normalMap:(CCSpriteFrame *)normalMap;
|
23 | 106 |
|
24 | 107 | @end
|
0 commit comments