/******************************************************************/ /* BRDFMaterial.h */ /* ----------------------- */ /* */ /* The file defines a simple material class for path tracing. It */ /* allows a BRDF class to be passed in. This class's shade */ /* function then samples the BRDF according to it's members */ /* and modulates the color by a fired ray. This class is here */ /* to make development of new BRDFs easy (so the Shade() func */ /* need not be rewritten). */ /* */ /* Really, if one did a little more design (and perhaps tweaked */ /* this class a little more), this would be the ONLY material */ /* class needed for your path tracer. */ /* */ /* Note this is NOT tuned for extreme performance. It is assumed */ /* it will be running in a batch mode, so it is written with */ /* an eye towards maintainability over minor speed bumps. */ /* */ /* Chris Wyman (03/30/2007) */ /******************************************************************/ #ifndef BRDFMATERIAL_H #define BRDFMATERIAL_H #include "DataTypes/Color.h" #include "Utils/TextParsing.h" #include "Core/Ray.h" #include "Core/RayPacket.h" #include "Materials/Material.h" #include "Materials/BRDF.h" #include #include #include class Scene; class BRDFMaterial : public Material { BRDF *brdf; bool useExplicitDirectLighting; // One of these two functions is called by the shade routine. // (Performance loss: 2 temp copies of the color, this way...) Color ImplicitDirectLight( Ray &ray, Scene &scene ) const; Color ExplicitDirectLight( Ray &ray, Scene &scene ) const; public: // One can either pass in an existing BRDF. BRDFMaterial( BRDF *brdf, bool useExplicitDirectLighting=false ) : brdf(brdf), useExplicitDirectLighting(useExplicitDirectLighting) {} // Or one can read the material from a file. BRDFMaterial( FILE *f, Scene *s ); // This is the shade routine -- it computes color with one of the two // private methods depending on if the scene asks for explicit direct // lighting or the naive (implicit) method. virtual Color Shade( Ray &ray, Scene &scene ) const; }; #endif