//
// Standard with cubemap+bumpmap (3 textures); HDR
// 26-03-09, RvG
//

float Fresnel(float bias,float scale,float power,float3 I,float3 N)
{
  float fresnel;
  float dotIN=dot(I,N);
  dotIN=min(dotIN,0.9);
  dotIN=max(dotIN,-0.8);
  fresnel=bias+scale*pow(1.0+dotIN,power);
  fresnel=min(fresnel,0.8);
  return fresnel;
}

float3 FresnelMix(float3 diffCol,float3 envCol,float Kr,float fresnel)
// Mixing of diffuse & environment color based on fresnel
{
  float3 c=diffCol.rgb+0.01*(envCol.rgb*envCol.rgb)*Kr*fresnel;
  //c=min(c,100);
  return c;
}
