Plasma, Wood, Noise and Marble
They inherit Fonction<Real>, so if you want to use them as diffuse coeff, for example, you will have to use a palette...
Palette class : the only method is
void addColor(Real p,const Intensity& i);
When you add up a color i at index p (in [0;1]) this way, the palette object automatically interpolates between the color at the nearest (of the indexes under the one you're adding) index already added (default is index 0) and the color you are adding.
An example should clarify this :
Palette pal; pal.addColor(0.0,Intensity(0,0,0)); pal.addColor(0.5,Intensity(0,0,1)); pal.addColor(1.0,Intensity(0,1,0));Now you have a palette like this :
In order to apply this palette to your function, use the PaletizedFonction class :
Plasma plasma(.15,.15,.15,6,.5); // this is your Fonction<Real> function Palette pal; // the palette that will translate the indexes returned by your function into Intensities pal.addColor(0,Intensity(0,0,0)); pal.addColor(.3,Intensity(0,0,0.3)); pal.addColor(.6,Intensity(1,0,0)); pal.addColor(.7,Intensity(.3,.6,.7)); pal.addColor(1,Intensity(1,.5,.3)); // do whatever shades you want ! PaletizedFonction pf; // this is a Fonction<Intensity> pf.setFonction(plasma); pf.setPalette(pal); myMaterial.setDiffuse(pf); // here you need a Fonction<Intensity>, that's why you made a palette myMaterial.setReflexion(plasma); // here all you need is your Fonction<Real>
Warning : the ONLY supported file format is TGA 24bits uncompressed. Memory expensive, but easy to load and use. Use the Picture and Map2D classes like this :
PicturemyPicture; myPicture.load("spam_and_eggs.tga"); Map2D<Intensity> myMap = Map2D (picture->getWidth(),picture->getHeight(),(Intensity*)picture->getData()); Notice the (Intensity*) cast... Then, your object myMap is of inherited type Fonction<Intensity>, so you can do :
whateverMaterial.setDiffuse(myMap); // or setSpecular...