iOS Developer Library

Developer

GLKit Framework Reference GLKEffectPropertyLight Class Reference

Options
Deployment Target:

On This Page
Language:

GLKEffectPropertyLight

The GLKEffectPropertyLight class defines properties for a single light applied to an effect. The lighting model implemented by GLKEffectPropertyLight is identical to the lighting model implemented in OpenGL ES 1.1; each light interacts with any material properties on the effect to determine the intensity and color that particular light contributes to the scene at a fragment. More...

Inheritance


Conforms To


Import Statement


import GLKit @import GLKit;

Availability


Available in iOS 5.0 and later.
  • enabled enabled Property

    A Boolean value that indicates whether calculations should be performed on this light.

    Declaration

    Swift

    var enabled: GLboolean

    Objective-C

    @property(nonatomic, assign) GLboolean enabled

    Discussion

    If the value of enabled is GL_TRUE, then lighting calculations are performed for this light. If the value is GL_FALSE, this light is skipped when computing the fragment color.

    Import Statement

    import GLKit

    Availability

    Available in iOS 5.0 and later.

  • position position Property

    The position of the light in world coordinates.

    Declaration

    Objective-C

    @property(nonatomic, assign) GLKVector4 position

    Discussion

    If the w component of the position is 0.0, the light is calculated using the directional light formula. The x, y, and z components of the vector specify the direction the light shines. The light is assumed to be infinitely far away; attenuation and spotlight properties are ignored.

    If the w component of the position is a non-zero value, the coordinates specify the position of the light in homogenous coordinates, and the light is either calculated as a point light or a spotlight, depending on the value of the spotCutoff property.

    The default value is [0.0, 0.0, 1.0, 0.0].

    Import Statement

    Availability

    Available in iOS 5.0 and later.

  • transform transform Property

    A transform applied to the light’s position and direction before calculating the contribution of the light.

    Declaration

    Swift

    var transform: GLKEffectPropertyTransform!

    Objective-C

    @property(nonatomic, retain) GLKEffectPropertyTransform *transform

    Discussion

    The default value is the identity matrix.

    Import Statement

    import GLKit

    Availability

    Available in iOS 5.0 and later.

  • The ambient portion of the light.

    Declaration

    Objective-C

    @property(nonatomic, assign) GLKVector4 ambientColor

    Import Statement

    Availability

    Available in iOS 5.0 and later.

  • The diffuse portion of the light.

    Declaration

    Objective-C

    @property(nonatomic, assign) GLKVector4 diffuseColor

    Import Statement

    Availability

    Available in iOS 5.0 and later.

  • The specular portion of the light.

    Declaration

    Objective-C

    @property(nonatomic, assign) GLKVector4 specularColor

    Import Statement

    Availability

    Available in iOS 5.0 and later.

  • A constant factor applied to the attenuation of a point light or spotlight.

    Declaration

    Swift

    var constantAttenuation: GLfloat

    Objective-C

    @property(nonatomic, assign) GLfloat constantAttenuation

    Discussion

    The distance attenuation factor is calculated as 1.0 / (k0 + k1 * d + k2 * d * d), where d represents the distance from the light to the point being lit. The constantAttenuation property is represented in this calculation as k0. The default value is 1.0.

    Import Statement

    import GLKit

    Availability

    Available in iOS 5.0 and later.

  • A linear factor applied to the attenuation of a point light or spotlight.

    Declaration

    Swift

    var linearAttenuation: GLfloat

    Objective-C

    @property(nonatomic, assign) GLfloat linearAttenuation

    Discussion

    The distance attenuation factor is calculated as 1.0 / (k0 + k1 * d + k2 * d * d), where d represents the distance from the light to the point being lit. The linearAttenuation property is represented in this calculation as k1. The default value is 0.0.

    Import Statement

    import GLKit

    Availability

    Available in iOS 5.0 and later.

  • A quadratic factor applied to the attenuation of a point light or spotlight.

    Declaration

    Swift

    var quadraticAttenuation: GLfloat

    Objective-C

    @property(nonatomic, assign) GLfloat quadraticAttenuation

    Discussion

    The distance attenuation factor is calculated as 1.0 / (k0 + k1 * d + k2 * d * d), where d represents the distance from the light to the point being lit. The quadraticAttenuation property is represented in this calculation as k2. The default value is 0.0.

    Import Statement

    import GLKit

    Availability

    Available in iOS 5.0 and later.

  • The angle in degrees where the spotlight is cut off.

    Declaration

    Swift

    var spotCutoff: GLfloat

    Objective-C

    @property(nonatomic, assign) GLfloat spotCutoff

    Discussion

    If the w component of the position is not equal to 0.0, the value of the spotCutoff property determines whether the light is a point light or a spotlight. A cutoff value of 180.0 indicates that the light is a point light; for a point light, the spotDirection and spotExponent properties are ignored. Otherwise, the spotCutoff property represents the maximum angle at which the light contributes lighting to the scene. The angle is measured between the vector provided by the spotDirection property and a vector drawn from the light’s position to the point being lit. If the angle exceeds this amount, then the light contributes no light to the scene.

    The default value is 180.0.

    Import Statement

    import GLKit

    Availability

    Available in iOS 5.0 and later.

  • A vector indicating the direction the spotlight is projecting.

    Declaration

    Objective-C

    @property(nonatomic, assign) GLKVector3 spotDirection

    Discussion

    The default direction is [0.0, 0.0, -1.0].

    Import Statement

    Availability

    Available in iOS 5.0 and later.

  • A value indicating how focused the spotlight is.

    Declaration

    Swift

    var spotExponent: GLfloat

    Objective-C

    @property(nonatomic, assign) GLfloat spotExponent

    Discussion

    The higher the value stored in the spotExponent property, the tighter the focus of the spotlight. The default value is 0.0.

    Import Statement

    import GLKit

    Availability

    Available in iOS 5.0 and later.

  • A constant that describes how lighting is calculated by an effect.

    Declaration

    Swift

    enum GLKLightingType : GLint { case PerVertex case PerPixel }

    Objective-C

    typedef enum { GLKLightingTypePerVertex, GLKLightingTypePerPixel } GLKLightingType;

    Constants

    • PerVertex

      GLKLightingTypePerVertex

      Indicates that the lighting calculations are performed at each vertex in a triangle and then interpolated across the triangle.

      Available in iOS 5.0 and later.

    • PerPixel

      GLKLightingTypePerPixel

      Indicates that the inputs to the lighting calculation are interpolated across a triangle and the lighting calculations are performed at each fragment.

      Available in iOS 5.0 and later.

    Discussion

    Typically, per-pixel lighting should be enabled when it provides an improvement in image quality without greatly reducing your application’s performance. Calculating the lighting equation at each fragment greatly increases the number of calculations required to calculate the lighting for a scene. However, calculating lighting only at vertices sometimes produces unusual or inaccurate results, particularly when your application uses spotlights or specular highlighting. For example, when per-pixel lighting is disabled, a narrow spotlight projected at the center of a large triangle may disappear entirely because the vertices that define the triangle all lie outside the area covered by the spotlight. That same triangle, when rendered using per-pixel lighting, would be rendered correctly.

    Import Statement

    import GLKit

    Availability

    Available in iOS 5.0 and later.