
// ===================================================================
// $Id$
//
// simplified_cook_torrance.h
//    Implementation of simplified Cook-Torrance BRDF.
//
// Class: CSimpleCookTorrance
//
// Initial coding by Hana Truskova & Michael Smutny, 2009.
//
// Edited by Jiri Nekola within diploma thesis, September 2011
// ===================================================================

#ifndef __SIMP_SURFCOOK_TORRANCE_H__
#define __SIMP_SURFCOOK_TORRANCE_H__

// Framework headers
#include "cook_torrance.h"

// standard headers

__BEGIN_BRDFLIB_HEADER


// ----------------------------------------------------------------------------
//  Reference:
//  Kelemen, C., Szirmay-Kalos, L. EUROGRAPHICS, 2001;
//
//  " A Microfacet Based BRDF Model", Kelemen, C., Szirmay-Kalos, L.
//  http://www.fsz.bme.hu/~szirmay/scook.pdf
// ----------------------------------------------------------------------------
class CSimpleCookTorrance:
  public CCookTorrance
{
public:
  /**
     Constructs the Cook-Torrance surface.
     @param rho_d (in)  The diffuse reflectance texture.
     @param rho_s (in)  The glossy reflectance texture.
     @param slope (in)  Standard deviation (RMS) of the surface slope.
  */
  CSimpleCookTorrance(CTexture *rho_d, CTexture *rho_s, CSlopeMicrofacets *slope):
    CCookTorrance(rho_d, rho_s, slope)
  { }

  CSimpleCookTorrance():
    CCookTorrance()
  {}

  virtual ~CSimpleCookTorrance() {};

  virtual char* GetName() const
  {return (char*)"CSimpleCookTorrance";}

  // left same as in CookTorrance model
  /*virtual int
  SpawnStochasticRays(CContributionArray  &carray,
		      const CHitPointInfo &hitInfo,
		      CSamplingInfo       &samplingInfo,
		      EDistributionType    distType = EE_ALL) const;*/

  virtual bool
  EvaluateBSDF(CValues             &res,
	       const CHitPointInfo &hitInfo,
	       const CVector3D     &dirIn,
	       EDistributionType    distType = EE_ALL) const;


  virtual bool
  GetAlbedo(CValues &albedo,
	    const CHitPointInfo &hitInfo,
	    EDistributionType   distType = EE_ALL) const;


  virtual inline EType GetType() const { return  EE_BSDFMicrofacetRefl; }

  virtual const char* GetHelp() const;

protected:

  virtual EDistributionType _microfacetReflectionType() const
  { return EE_REFLECTED_GLOSSY; }

  virtual int SpawnStochasticSpecularRays(const CValues       &ks_local,
				          CVector2D           &slopeXY,
				          CVector2D           &slopeXY_sq,
                                          const CValues       &kd_local,
				          CContributionArray  &carray,
				          const CHitPointInfo &hitInfo,
				          CSamplingInfo       &samplingInfo,
				          int                 maxRays) const;

  // not sure how to spawn diffuse rays, left same as in cook_torrance model
  /*virtual int SpawnStochasticDiffuseRays(const CValues        &kd_local,
                                         const CValues        &ks_local,
				         CVector2D            &slopeXY,
				         CVector2D            &slopeXY_sq,
					 CContributionArray   &carray,
				         const CHitPointInfo  &hitInfo,
				         CSamplingInfo        &samplingInfo,
				         int                  maxRays) const;*/

};


__END_BRDFLIB_HEADER

#endif // __SIMP_SURFCOOK_TORRANCE_H__

