|
@@ -9,19 +9,23 @@ vLightFront = vec3( 0.0 );
|
|
|
vec3 normal = normalize( transformedNormal );
|
|
|
vec3 diffuse = vec3( 1.0 );
|
|
|
|
|
|
+IncidentLight incidentLight;
|
|
|
+ReflectedLight frontReflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ) );
|
|
|
+ReflectedLight backReflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ) );
|
|
|
+
|
|
|
+vec3 backNormal = -normal;
|
|
|
|
|
|
#if MAX_POINT_LIGHTS > 0
|
|
|
|
|
|
for ( int i = 0; i < MAX_POINT_LIGHTS; i ++ ) {
|
|
|
|
|
|
- IncidentLight incidentLight;
|
|
|
- getPointLightDirect( pointLights[ i ], mvPosition.xyz, incidentLight );
|
|
|
+ getPointIncidentLight( pointLights[ i ], mvPosition.xyz, incidentLight );
|
|
|
|
|
|
- vLightFront += BRDF_Lambert( incidentLight, normal, diffuse );
|
|
|
+ BRDF_Lambert( incidentLight, normal, diffuse, frontReflectedLight );
|
|
|
|
|
|
#ifdef DOUBLE_SIDED
|
|
|
|
|
|
- vLightBack += BRDF_Lambert( incidentLight, -normal, diffuse );
|
|
|
+ BRDF_Lambert( incidentLight, backNormal, diffuse, backReflectedLight );
|
|
|
|
|
|
#endif
|
|
|
|
|
@@ -33,14 +37,13 @@ vec3 diffuse = vec3( 1.0 );
|
|
|
|
|
|
for ( int i = 0; i < MAX_SPOT_LIGHTS; i ++ ) {
|
|
|
|
|
|
- IncidentLight incidentLight;
|
|
|
- getSpotLightDirect( spotLights[ i ], mvPosition.xyz, incidentLight );
|
|
|
+ getSpotIncidentLight( spotLights[ i ], mvPosition.xyz, incidentLight );
|
|
|
|
|
|
- vLightFront += BRDF_Lambert( incidentLight, normal, diffuse );
|
|
|
+ BRDF_Lambert( incidentLight, normal, diffuse, frontReflectedLight );
|
|
|
|
|
|
#ifdef DOUBLE_SIDED
|
|
|
|
|
|
- vLightBack += BRDF_Lambert( incidentLight, -normal, diffuse );
|
|
|
+ BRDF_Lambert( incidentLight, backNormal, diffuse, backReflectedLight );
|
|
|
|
|
|
#endif
|
|
|
|
|
@@ -52,14 +55,13 @@ vec3 diffuse = vec3( 1.0 );
|
|
|
|
|
|
for ( int i = 0; i < MAX_DIR_LIGHTS; i ++ ) {
|
|
|
|
|
|
- IncidentLight incidentLight;
|
|
|
- getDirLightDirect( directionalLights[ i ], incidentLight );
|
|
|
+ getDirIncidentLight( directionalLights[ i ], incidentLight );
|
|
|
|
|
|
- vLightFront += BRDF_Lambert( incidentLight, normal, diffuse );
|
|
|
+ vLightFront += BRDF_Lambert( incidentLight, normal, diffuse, frontReflectedLight );
|
|
|
|
|
|
#ifdef DOUBLE_SIDED
|
|
|
|
|
|
- vLightBack += BRDF_Lambert( incidentLight, -normal, diffuse );
|
|
|
+ BRDF_Lambert( incidentLight, backNormal, diffuse, backReflectedLight );
|
|
|
|
|
|
#endif
|
|
|
|
|
@@ -71,16 +73,15 @@ vec3 diffuse = vec3( 1.0 );
|
|
|
|
|
|
for ( int i = 0; i < MAX_HEMI_LIGHTS; i ++ ) {
|
|
|
|
|
|
- IncidentLight incidentLight;
|
|
|
getHemisphereLightIndirect( hemisphereLights[ i ], normal, incidentLight );
|
|
|
|
|
|
- vLightFront += BRDF_Lambert( incidentLight, normal, diffuse );
|
|
|
+ BRDF_Lambert( incidentLight, normal, diffuse, frontReflectedLight );
|
|
|
|
|
|
#ifdef DOUBLE_SIDED
|
|
|
|
|
|
- incidentLight = getHemisphereLightIndirect( hemisphereLights[ i ], -normal );
|
|
|
+ getHemisphereIncidentLight( hemisphereLights[ i ], backNormal, incidentLight );
|
|
|
|
|
|
- vLightBack += BRDF_Lambert( incidentLight, -normal, diffuse );
|
|
|
+ BRDF_Lambert( incidentLight, backNormal, diffuse, backReflectedLight );
|
|
|
|
|
|
#endif
|
|
|
|
|
@@ -88,10 +89,10 @@ vec3 diffuse = vec3( 1.0 );
|
|
|
|
|
|
#endif
|
|
|
|
|
|
-vLightFront += ambientLightColor;
|
|
|
+vLightFront += ambientLightColor + frontReflectedLight.diffuse;
|
|
|
|
|
|
#ifdef DOUBLE_SIDED
|
|
|
|
|
|
- vLightBack += ambientLightColor;
|
|
|
+ vLightBack += ambientLightColor + backReflectedLight.diffuse;
|
|
|
|
|
|
#endif
|