 
 
 #else
-
-	float dotNL = max(dot(N,L), 0.0 );
+	float NdotL = dot(N,L);
+	float cNdotL = max(NdotL, 0.0); // clamped NdotL
+	float NdotV = dot(N, V);
+	float cNdotV = max(NdotV, 0.0);
 
 #if defined(DIFFUSE_OREN_NAYAR)
-	vec3 light_amount;
-#else
-	float light_amount;
+	vec3 diffuse_brdf_NL;
+#else
+	float diffuse_brdf_NL; // BRDF times N.L for calculating diffuse radiance
 #endif
 
 
 #if defined(DIFFUSE_LAMBERT_WRAP)
 	//energy conserving lambert wrap shader
-	light_amount = max(0.0,(dot(N,L) + roughness) / ((1.0 + roughness) * (1.0 + roughness)));
+	diffuse_brdf_NL = max(0.0,(NdotL + roughness) / ((1.0 + roughness) * (1.0 + roughness)));
 
 #elif defined(DIFFUSE_OREN_NAYAR)
 
 	{
 		// see http://mimosa-pudica.net/improved-oren-nayar.html
 		float LdotV = dot(L, V);
-		float NdotL = dot(L, N);
-		float NdotV = dot(N, V);
+
 
 		float s = LdotV - NdotL * NdotV;
 		float t = mix(1.0, max(NdotL, NdotV), step(0.0, s));
 
-		float sigma2 = roughness * roughness;
+		float sigma2 = roughness * roughness; // TODO: this needs checking
 		vec3 A = 1.0 + sigma2 * (- 0.5 / (sigma2 + 0.33) + 0.17*diffuse_color / (sigma2 + 0.13) );
 		float B = 0.45 * sigma2 / (sigma2 + 0.09);
 
-		light_amount = dotNL * (A + vec3(B) * s / t) / M_PI;
+		diffuse_brdf_NL = cNdotL * (A + vec3(B) * s / t) * (1.0 / M_PI);
 	}
 
 #elif defined(DIFFUSE_TOON)
 
-	light_amount = smoothstep(-roughness,max(roughness,0.01),dot(N,L));
+	diffuse_brdf_NL = smoothstep(-roughness,max(roughness,0.01),NdotL);
 
 #elif defined(DIFFUSE_BURLEY)
 

	avg+=textureProj(shadow,vec4(pos+vec2(0.0,-shadow_pixel_size.y*2.0),depth,1.0));
	return avg*(1.0/13.0);

#endif

#ifdef SHADOW_MODE_PCF_5

	float avg=textureProj(shadow,vec4(pos,depth,1.0));
	avg+=textureProj(shadow,vec4(pos+vec2(shadow_pixel_size.x,0.0),depth,1.0));

#if defined(SPECULAR_BLINN)

		vec3 H = normalize(V + L);
		float cNdotH = max(dot(N,H), 0.0 );
		float intensity = pow( cNdotH, (1.0-roughness) * 256.0);
		specular_light += light_color * intensity * specular_blob_intensity * attenuation;

#elif defined(SPECULAR_PHONG)

		 vec3 R = normalize(-reflect(L,N));
		 float cRdotV = max(0.0,dot(R,V));
		 float intensity = pow( cRdotV, (1.0-roughness) * 256.0);
		 specular_light += light_color * intensity * specular_blob_intensity * attenuation;

#elif defined(SPECULAR_TOON)

		vec3 R = normalize(-reflect(L,N));
		float RdotV = dot(R,V);
		float mid = 1.0-roughness;
		mid*=mid;
		float intensity = smoothstep(mid-roughness*0.5, mid+roughness*0.5, RdotV) * mid;
		diffuse_light += light_color * intensity * specular_blob_intensity * attenuation; // write to diffuse_light, as in toon shading you generally want no reflection

#elif defined(SPECULAR_DISABLED)
		//none..
