00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef TOXIC_RENDERER_BSDF_H
00024 #define TOXIC_RENDERER_BSDF_H
00025
00026 #include "common/math/real.h"
00027 #include "common/math/vector3.h"
00028 #include "globals.h"
00029 #include "ibdf.h"
00030
00031 #include <utility>
00032 #include <vector>
00033
00034 namespace toxic {
00035
00036 class Context;
00037
00038
00039 class BSDF : public IBDF {
00040 public:
00041 BSDF();
00042
00043 virtual ~BSDF() {}
00044
00045 virtual bool IsDiffuse() const;
00046 virtual bool IsSpecular() const;
00047
00048 void Insert(const IBRDF *brdf, sheep::Real weight);
00049 void Insert(const IBTDF *btdf, sheep::Real weight);
00050
00051
00052
00053 virtual sheep::Real Evaluate(
00054 const Context &context,
00055 const sheep::Vector3 &incoming,
00056 const sheep::Vector3 &outgoing) const;
00057
00058 virtual sheep::Real EvaluateSpecular(
00059 const Context &context,
00060 const sheep::Vector3 &incoming,
00061 sheep::Vector3 *outgoing) const;
00062
00063
00064
00065
00066
00067 virtual void Sample(
00068 const Context &context,
00069 const sheep::Vector3 &incoming,
00070 sheep::Vector3 *outgoing,
00071 sheep::Real *prob,
00072 sheep::Real *value) const;
00073
00074
00075
00076
00077 virtual sheep::Real ComputeScatteringProbability(
00078 const sheep::Vector3 &incoming,
00079 const sheep::Vector3 &outgoing) const;
00080
00081
00082 virtual sheep::Real ComputeReflectance(const Context &context) const;
00083
00084
00085
00086 virtual sheep::Real ComputeReflectance(
00087 const Context &context,
00088 const sheep::Vector3 &incoming) const;
00089
00090 private:
00091 typedef std::pair<const IBRDF *, sheep::Real> weighted_brdf;
00092 typedef std::pair<const IBTDF *, sheep::Real> weighted_btdf;
00093
00094 typedef std::vector<weighted_brdf> brdf_vector;
00095 typedef std::vector<weighted_btdf> btdf_vector;
00096
00097 typedef brdf_vector::const_iterator brdf_vector_const_it;
00098 typedef btdf_vector::const_iterator btdf_vector_const_it;
00099
00100 brdf_vector m_brdfs;
00101 btdf_vector m_btdfs;
00102 brdf_vector m_specular_brdfs;
00103 btdf_vector m_specular_btdfs;
00104
00105 sheep::Real m_total_weight;
00106 };
00107
00108 #include "bsdf.inl"
00109
00110 }
00111
00112 #endif // !TOXIC_RENDERER_BSDF_H