# 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

- `refraction` property
- `shininess` property
- `fresnelBias` property
- `fresnelPower` property
- `refractionEnvironment` property
- `reflectionEnvironment` property
- `normalMap` property

### Initializing a CCEffectGlass object

- `– init`
- `– initWithShininess:refraction:refractionEnvironment:reflectionEnvironment:`
- `– initWithShininess:refraction:refractionEnvironment:reflectionEnvironment:normalMap:`

### Creating a CCEffectGlass object

- `+ effectWithShininess:refraction:refractionEnvironment:reflectionEnvironment:`
- `+ effectWithShininess:refraction:refractionEnvironment:reflectionEnvironment:normalMap:`

## 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 fresnelBias`

#### Declared In

`CCEffectGlass.h`

### fresnelPower

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 fresnelPower`

#### Declared In

`CCEffectGlass.h`

### normalMap

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 *normalMap`

#### Declared In

`CCEffectGlass.h`

### reflectionEnvironment

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 *reflectionEnvironment`

#### Declared In

`CCEffectGlass.h`

### refraction

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 refraction`

#### Declared In

`CCEffectGlass.h`

### refractionEnvironment

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 *refractionEnvironment`

#### Declared In

`CCEffectGlass.h`

### shininess

The overall shininess of the attached sprite. This value is in the range [0..1] and it controls how much of the reflected environment contributes to the final color of the affected pixels.

`@property (nonatomic) float shininess`

#### Declared In

`CCEffectGlass.h`

## Class 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 *)reflectionEnvironment`

#### Parameters

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.h`

### effectWithShininess: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 *)normalMap`

#### Parameters

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`

## Instance 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)init`

#### Return Value

The CCEffectGlass object.

#### Declared In

`CCEffectGlass.h`

### initWithShininess: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 *)reflectionEnvironment`

#### Parameters

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.h`

### initWithShininess: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 *)normalMap`

#### Parameters

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`