Inherits from NGLObject3D : NSObject
Declared in NGLLight.h

Overview

Creates and manages a light source. (Singleton)

NGLLight is a class to deal with light effects. It is directly connected with the NinevehGL Shader API and can produce all light effects. However, for performance reasons, it’s always better to work with precalculated light on the diffuse and ambient maps instead of the real time light calculations.

In NinevehGL lights are calculated by two ways:

  • Using the half vector;
            \ V      H || N        / L
              \        ||        /
                \      ||      /
                  \    ||    /
                    \  ||  /
______________________\||/__________________

  • Using the reflection vector;
            \ V   \ R   | N        / L
              \    \    |        /
                \   \   |      /
                  \  \  |    /
                    \ \ |  /
______________________\\|/__________________

Both approaches produce great results. But using the reflection vector produces more accurated results and for some situations it’s essential, like for the bump map effect. The “Half Vector” is a vector lying exactly halfway between the V (View vector) and L (Light vector), it needs less calculation and is faster than the other approach.

On the other hand, the Reflection vector must be extract from a map like the bump map or a reflection map.

Tasks

  •   type

    The light type.

    property
  •   color

    The light’s color. The default color is white.

    property
  •   attenuation

    The attenuation factor. This floating values lies on a range from (0.001, 1000.0). The attenuation factor represents the depth necessary for the light lose around 5% of its power. For example, attenuation factor of 2.0 means that an object distant from the light 20.0 units will receive 50% of the light power.

    property
  •   values

    (Internal only) Returns a pointer to the light scalar values. You should not call this method directly.

    property
  • + defaultLight

    Returns the singleton instance of NGLLight.

Properties

attenuation

The attenuation factor. This floating values lies on a range from (0.001, 1000.0). The attenuation factor represents the depth necessary for the light lose around 5% of its power. For example, attenuation factor of 2.0 means that an object distant from the light 20.0 units will receive 50% of the light power.

@property (nonatomic) float attenuation

Discussion

The attenuation factor. This floating values lies on a range from (0.001, 1000.0). The attenuation factor represents the depth necessary for the light lose around 5% of its power. For example, attenuation factor of 2.0 means that an object distant from the light 20.0 units will receive 50% of the light power.

Attenuation: 2.0;
Distance from Light: 20.0;
                                                           ___
                                                          /   \
 + ----------------------------------------------------- |     |
  |_________||_________||_________||_________||_________| \___/

100%        90%        80%        70%        60%       50%

The default attenuation value is 1.0.

Declared In

NGLLight.h

color

The light’s color. The default color is white.

@property (nonatomic) NGLvec4 color

Discussion

The light’s color. The default color is white.

Declared In

NGLLight.h

type

The light type.

@property (nonatomic) NGLLightType type

Discussion

The light type.

Declared In

NGLLight.h

values

(Internal only) Returns a pointer to the light scalar values. You should not call this method directly.

@property (nonatomic, readonly) NGLLightValues *values

Discussion

(Internal only) Returns a pointer to the light scalar values. You should not call this method directly.

Declared In

NGLLight.h

Class Methods

defaultLight

Returns the singleton instance of NGLLight.

+ (NGLLight *)defaultLight

Return Value

The singleton instance of the main Light.

Discussion

Returns the singleton instance of NGLLight.

For performance reasons, NinevehGL makes use of only one main light, which is a sky light. By default, the main light is positioned at the {0.0, 1.0, -1.0} in world coordinates.

Declared In

NGLLight.h