 	return min(1.0f, f1);
 }
 
+//rescales given normalized CIE XYZ colors back to heir original scale
+//using their extreme values.
+//@param X 1st CIE XYZ colorvalue (normalized)
+//@param Y 2nd CIE XYZ colorvalue (normalized)
+//@param Z 3rd CIE XYZ colorvalue (normalized)
+//@param index which dft terms should be used
+//     in oder to appropriately lookup their
+//     extreme values for rescaling them.
+//@return rescaled CIE XYZ colors
 vec3 rescaleXYZ(float X, float Y, float Z, int index){
 	vec4 vMin = scalingFactors[index*2];
 	vec4 vMax = scalingFactors[index*2 + 1];

	float vv = k1.y - k2.y;
	float ww = k1.z - k2.z;

	vec3 totalXYZ = getRawXYZFromTaylorSeries(uu, vv, ww);

	
	totalXYZ = totalXYZ*gainF(k1, k2)*85.0*shadowF;
	totalXYZ = getBRDF_RGB_T_D65(M_Adobe_XRNew, totalXYZ);
	if(isnan(totalXYZ.x*totalXYZ.y*totalXYZ.z)){
		totalXYZ.x = 1.0;
		totalXYZ.y = 1.0;
		totalXYZ.z = 0.0;
	}
	frag_shaded = vec4(gammaCorrect(totalXYZ, 2.5), 1.0);
}


vec3 blend3 (vec3 x){
	vec3 y = 1.0 - x * x;
	y = max(y, vec3 (0, 0, 0));
	return (y);
}
//


void main(){
	if(shouldRenderBrdfMap == 1){

	return tmp/N_i;
}

// computes pq factor which is sqrt(p^2 + q^2)
// for the 1dim case. for the 2dim case i refer to 
// chapter "derivation" PQ" in my thesis, section 'pq approach'.
// @param w_u angular frequency along u direction
// @param w_v angular frequency along v direction
// @return pq scale factor (used for amplitude)
float compute_pq_scale_factor(float w_u, float w_v){
	float in_periods = periods;
	in_periods = ceil(patchReso/dx);
