 	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
+#elif defined(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));



		vec3 H = normalize(V + L);
		float NoL = max(0.0,dot(N, L));
		float LoH = max(0.0,dot(L, H));
		float NoV = max(0.0,dot(N, V));

		float FD90 = 0.5 + 2.0 * LoH * LoH * roughness;
		float FdV = 1.0 + (FD90 - 1.0) * SchlickFresnel(NoV);
		float FdL = 1.0 + (FD90 - 1.0) * SchlickFresnel(NoL);
		light_amount = ( (1.0 / M_PI) * FdV * FdL ) * NoL;
/*
		float energyBias = mix(roughness, 0.0, 0.5);
		float energyFactor = mix(roughness, 1.0, 1.0 / 1.51);
		float fd90 = energyBias + 2.0 * VoH * VoH * roughness;
		float f0 = 1.0;
		float lightScatter = f0 + (fd90 - f0) * pow(1.0 - NoL, 5.0);
		float viewScatter = f0 + (fd90 - f0) * pow(1.0 - NoV, 5.0);

		light_amount = lightScatter * viewScatter * energyFactor;*/
	}
#else
	//lambert
	light_amount = dotNL / M_PI;
#endif

#if defined(TRANSMISSION_USED)
	diffuse += light_color * diffuse_color * mix(vec3(light_amount),vec3(M_PI),transmission) * attenuation;
#else
	diffuse += light_color * diffuse_color * light_amount * attenuation;
#endif


	float dotNV = max(dot(N,V), 0.0 );
#if defined(LIGHT_USE_RIM)
	float rim_light = pow(1.0-dotNV,(1.0-roughness)*16.0);
	diffuse += rim_light * rim * mix(vec3(1.0),diffuse_color,rim_tint) * light_color;
#endif



#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..
