 #endif
 	
 	// Use ACEScg primaries as working space
-	vec3 WorkingColor = ColorAP0 * AP0_2_AP1_MAT;//mul( AP0_2_AP1_MAT, ColorAP0 );
+	vec3 WorkingColor = transpose(AP0_2_AP1_MAT) * ColorAP0;//mul( AP0_2_AP1_MAT, ColorAP0 );
 
 	WorkingColor = max( vec3(0, 0, 0), WorkingColor );
 

	return max( vec3(0.0), ToneColor );
}

void main() 
{
  out_Color = vec4(pow(FilmToneMap(texture(RenderTarget1, v_texcoord).rgb), vec3(1.0 / 2.2)), 1.0);//vec4( fragColor.rgb, fragColor.a);
}


vec3 FilmToneMap( vec3 LinearColor ) 
{
	const mat3 sRGB_2_AP0 = transpose(XYZ_2_AP0_MAT) * (transpose(D65_2_D60_CAT) * transpose(sRGB_2_XYZ_MAT));//mul( XYZ_2_AP0_MAT, mul( D65_2_D60_CAT, sRGB_2_XYZ_MAT ) );
	const mat3 sRGB_2_AP1 = transpose(XYZ_2_AP1_MAT) * (transpose(D65_2_D60_CAT) * transpose(sRGB_2_XYZ_MAT)); //mul( XYZ_2_AP1_MAT, mul( D65_2_D60_CAT, sRGB_2_XYZ_MAT ) );

	const mat3 AP0_2_sRGB = transpose(XYZ_2_sRGB_MAT)* ( transpose(D60_2_D65_CAT) * transpose(AP0_2_XYZ_MAT) );//mul( XYZ_2_sRGB_MAT, mul( D60_2_D65_CAT, AP0_2_XYZ_MAT ) );
	const mat3 AP1_2_sRGB =  transpose(XYZ_2_sRGB_MAT) * ( transpose(D60_2_D65_CAT) * transpose(AP1_2_XYZ_MAT) );//mul( XYZ_2_sRGB_MAT, mul( D60_2_D65_CAT, AP1_2_XYZ_MAT ) );
	
	const mat3 AP0_2_AP1 = transpose(XYZ_2_AP1_MAT) * transpose(AP0_2_XYZ_MAT);//mul( XYZ_2_AP1_MAT, AP0_2_XYZ_MAT );
	const mat3 AP1_2_AP0 = transpose(XYZ_2_AP0_MAT) * transpose(AP1_2_XYZ_MAT);//mul( XYZ_2_AP0_MAT, AP1_2_XYZ_MAT );
	
	vec3 ColorAP1 = LinearColor;
	//vec3 ColorAP1 = mul( sRGB_2_AP1, vec3(LinearColor) );
	


	vec3 ColorAP0 = AP1_2_AP0 * ColorAP1;//mul( AP1_2_AP0, ColorAP1 );


#if 1
