// test scene to show the pixel-sized dot-artifacts that appear when
// using interpolated image_maps into functions

#version 3.7;

#declare fp=function{pigment{image_map{png "test.png" interpolate 2}}}

// using this classical setup causes the pixel-sized artifacts
///*
#declare RED = pigment {
  function { fp(x,y,z).red } 
  color_map { [0 rgb 0][1 rgb <1,0,0>] }
}
#declare GREEN = pigment {
  function { fp(x,y,z).green } 
  color_map { [0 rgb 0][1 rgb <0,1,0>] }
}
#declare BLUE = pigment {
  function { fp(x,y,z).blue } 
  color_map { [0 rgb 0][1 rgb <0,0,1>] }
}
//*/

// this alternative overcomes the problem, but is problematic for HDR images
/*
#declare RED = pigment {
  function { min(fp(x,y,z).red,1) } 
  color_map { [0 rgb 0][1 rgb <1,0,0>] }
}
#declare GREEN = pigment {
  function { min(fp(x,y,z).green,1) }
  color_map { [0 rgb 0][1 rgb <0,1,0>] }
}
#declare BLUE = pigment {
  function { min(fp(x,y,z).blue,1) }  
  color_map { [0 rgb 0][1 rgb <0,0,1>] }
}
*/

// this alternative overcomes the problem, and works for HDR images
/*
#declare RED = pigment {
  function { fp(x,y,z).red/65000 } 
  color_map { [0 rgb 0][1 rgb <65000,0,0>] }
}
#declare GREEN = pigment {
  function { fp(x,y,z).green/65000 }
  color_map { [0 rgb 0][1 rgb <0,65000,0>] }
}
#declare BLUE = pigment {
  function { fp(x,y,z).blue/65000 }  
  color_map { [0 rgb 0][1 rgb <0,0,65000>] }
}
*/


box{-.5,.5
  texture{
    pigment{
      average
      pigment_map{
        [1 RED]
        [1 GREEN]
        [1 BLUE]
      }
    }
    finish{
      emission 3
    }
  }
}
