 	
 		incidentLight.color = spotLight.color;
 		incidentLight.color *= ( spotEffect * calcLightAttenuation( length( lVector ), spotLight.distance, spotLight.decay ) );
+
+	}
+
+#endif
+
+#define MAX_AREA_LIGHTS 0 
+
+#if MAX_AREA_LIGHTS > 0
+
+	struct HemisphereLight {
+	  vec3 position;
+	  vec3 width;
+	  vec3 height;
+	  vec3 color;
+	  float distance;
+	  float decay;
+	};
+
+	uniform AreaLight areaLights[ MAX_AREA_LIGHTS ];
+
+	void getAreaIncidentLight( const in AreaLight areaLight, const in GeometricContext geometry, out IncidentLight incidentLight ) {
+	
+		float widthLength = length( areaLight.width );
+		float heightLength = length( areaLight.height );
+
+		vec3 widthDir = areaLight.width / widthLength;
+		vec3 heightDir = areaLight.height / heightLength;
+		vec3 direction = normalize( cross( widthDir, heightDir ) );
+
+		// project onto plane and calculate direction from center to the projection.
+		vec3 planePosition = projectOnPlane( viewDir, areaLight.position, direction ),  // projection in plane
+		vec3 planeOffset = planePosition - areaLight.position;
+
+		// calculate distance from area:
+		vec2 planeOffsetUV = vec2( dot( planeOffset, widthDir ), dot( planeOffset, heightDir ) );
+		vec2 clampedPlaneOffsetUV = vec2( clamp( planeOffsetUV.x, -widthLength, widthLength ), clamp( planeOffsetUV.y, -heightLength, heightLength ) );
+		vec3 clampedPlanePosition = areaLight.position + ( widthDir * clampedPlaneOffsetUV.x + heightDir * clampedPlaneOffsetUV.y );
+
+		vec3 lVector = ( clampedPlanePosition - geometry.position );
+		float lLength = length( lVector );
+
+		incidentLight.color = areaLight.color[ i ] * calcLightAttenuation( lLength, areaLight.distance, areaLight.decay ) * 0.01;
+		incidentLight.direction = lVector / lLength;		
 
 	}
 

#define RECIPROCAL_PI2 0.15915494
#define LOG2 1.442695
#define EPSILON 1e-6
#define PHYSICALLY_BASED_RENDERING
#define saturate(a) clamp( a, 0.0, 1.0 )
#define whiteCompliment(a) ( 1.0 - saturate( a ) )

float luminance( const in vec3 color ) {
    const vec3 W = vec3(0.2125, 0.7154, 0.0721);
    return dot( color, W );
}

float average( const in vec3 color ) {
    const vec3 W = vec3(0.3333, 0.3333, 0.3333);
    return dot( color, W );
}

vec3 transformDirection( in vec3 normal, in mat4 matrix ) {


	uniform SpotLight spotLights[ MAX_SPOT_LIGHTS ];

	void getSpotIncidentLight( const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight incidentLight ) {
	
		vec3 lightPosition = spotLight.position;
	
		vec3 lVector = lightPosition - geometry.position;
		incidentLight.direction = normalize( lVector );
	
		float spotEffect = dot( spotLight.direction, incidentLight.direction );
