CCEffectGlass Class Reference
| Inherits from | CCEffect : NSObject |
| Declared in | CCEffectGlass.h |
Overview
CCEffectGlass uses reflection and refraction to simulate the appearance of a transparent object contained within an environment. Refraction is controlled with a single refraction strength value, the normal map, and a refraction environment sprite. Reflection is controlled with two fresnel reflectance values, the normal map, and a reflection environment sprite (which may be different from the refraction environment).
Tasks
Accessing Effect Attributes
-
refractionproperty -
shininessproperty -
fresnelBiasproperty -
fresnelPowerproperty -
refractionEnvironmentproperty -
reflectionEnvironmentproperty -
normalMapproperty
Initializing a CCEffectGlass object
-
– init -
– initWithShininess:refraction:refractionEnvironment:reflectionEnvironment: -
– initWithShininess:refraction:refractionEnvironment:reflectionEnvironment:normalMap:
Creating a CCEffectGlass object
Properties
fresnelBias
The bias term in the fresnel reflectance equation: reflectance = max(0.0, fresnelBias + (1 - fresnelBias) * pow((1 - nDotV), fresnelPower)) This value is in the range [0..1] and it controls the constant (view angle independent) contribution to the reflectance equation.
@property (nonatomic) float fresnelBiasDeclared In
CCEffectGlass.hfresnelPower
The power term in the fresnel reflectance equation: reflectance = max(0.0, fresnelBias + (1 - fresnelBias) * pow((1 - nDotV), fresnelPower)) This value is in the range [0..inf] and it controls the view angle dependent contribution to the reflectance equation.
@property (nonatomic) float fresnelPowerDeclared In
CCEffectGlass.hnormalMap
The normal map that encodes the normal vectors of the affected node. Each pixel in the normal map is a 3 component vector that is perpendicular to the surface of the sprite at that point.
@property (nonatomic, strong) CCSpriteFrame *normalMapDeclared In
CCEffectGlass.hreflectionEnvironment
The environment that will be reflected by the affected node. Typically this is a sprite that is not visible in the scene as it is conceptually “behind the viewer” and only visible where reflected by the affected node.
@property (nonatomic, strong) CCSprite *reflectionEnvironmentDeclared In
CCEffectGlass.hrefraction
The refraction strength value. This value is in the range [-1..1] with -1 resulting in maximum minification of the refracted image, 0 resulting in no refraction, and 1 resulting in maximum magnification of the refracted image.
@property (nonatomic) float refractionDeclared In
CCEffectGlass.hrefractionEnvironment
The environment that will be refracted by the affected node. Typically this is a sprite that serves as the background for the affected node so it appears that the viewer is seeing the refracted environment through the refracting node.
@property (nonatomic, strong) CCSprite *refractionEnvironmentDeclared In
CCEffectGlass.hClass Methods
effectWithShininess:refraction:refractionEnvironment:reflectionEnvironment:
Creates a CCEffectGlass object with the supplied parameters and a nil normal map.
+ (id)effectWithShininess:(float)shininess refraction:(float)refraction refractionEnvironment:(CCSprite *)refractionEnvironment reflectionEnvironment:(CCSprite *)reflectionEnvironmentParameters
- shininess
The overall shininess.
- refraction
The refraction strength.
- refractionEnvironment
The environment image that will be refracted by the affected node.
- reflectionEnvironment
The environment image that will be reflected by the affected node.
Return Value
The CCEffectGlass object.
Declared In
CCEffectGlass.heffectWithShininess:refraction:refractionEnvironment:reflectionEnvironment:normalMap:
Creates a CCEffectGlass object with the supplied parameters.
+ (id)effectWithShininess:(float)shininess refraction:(float)refraction refractionEnvironment:(CCSprite *)refractionEnvironment reflectionEnvironment:(CCSprite *)reflectionEnvironment normalMap:(CCSpriteFrame *)normalMapParameters
- shininess
The overall shininess.
- refraction
The refraction strength.
- refractionEnvironment
The environment image that will be refracted by the affected node.
- reflectionEnvironment
The environment image that will be reflected by the affected node.
- normalMap
The normal map of the affected node. This can also be specified as a property of the affected sprite.
Return Value
The CCEffectGlass object.
Declared In
CCEffectGlass.hInstance Methods
init
Initializes a CCEffectGlass object with the following default parameters: refraction = 1.0, fresnelBias = 0.1, fresnelPower = 2.0, refractionEnvironment = nil, reflectionEnvironment = nil, normalMap = nil
- (id)initReturn Value
The CCEffectGlass object.
Declared In
CCEffectGlass.hinitWithShininess:refraction:refractionEnvironment:reflectionEnvironment:
Initializes a CCEffectGlass object with the supplied parameters and a nil normal map.
- (id)initWithShininess:(float)shininess refraction:(float)refraction refractionEnvironment:(CCSprite *)refractionEnvironment reflectionEnvironment:(CCSprite *)reflectionEnvironmentParameters
- shininess
The overall shininess.
- refraction
The refraction strength.
- refractionEnvironment
The environment image that will be refracted by the affected node.
- reflectionEnvironment
The environment image that will be reflected by the affected node.
Return Value
The CCEffectGlass object.
Declared In
CCEffectGlass.hinitWithShininess:refraction:refractionEnvironment:reflectionEnvironment:normalMap:
Initializes a CCEffectGlass object with the supplied parameters.
- (id)initWithShininess:(float)shininess refraction:(float)refraction refractionEnvironment:(CCSprite *)refractionEnvironment reflectionEnvironment:(CCSprite *)reflectionEnvironment normalMap:(CCSpriteFrame *)normalMapParameters
- shininess
The overall shininess.
- refraction
The refraction strength.
- refractionEnvironment
The environment image that will be refracted by the affected node.
- reflectionEnvironment
The environment image that will be reflected by the affected node.
- normalMap
The normal map of the affected node. This can also be specified as a property of the affected sprite.
Return Value
The CCEffectGlass object.
Declared In
CCEffectGlass.h