 	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);
-}
-//
-
+	vec3 color = getXYZContributionForPosition(uu, vv, ww);
+	color = color*gainFactor(k1, k2)*150.0*shadowF;
+	color = getBRDF_RGB_T_D65(M_Adobe_XRNew, color);
+	
+	frag_shaded = vec4(gammaCorrect(color, 2.5), 1.0);
+}
 
 void main(){
 	if(shouldRenderBrdfMap == 1){

	return pow(uuu*uuu + vvv*vvv, 0.5);
}





void setVarXY(){
	dH = t0;
	float coherenceLength = 65.0e-6;
	float sigSpatial = coherenceLength/4.0f;

	// temporary sigma
	float sigTemp;
	sigTemp = 0.5 / PI ;
	sigTemp = sigTemp /sigSpatial;
	sigTemp = sigTemp * dH;
	

	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);
