36 #include <cugar/linalg/vector.h> 37 #include <cugar/basic/numbers.h> 38 #include <cugar/bsdf/differential_geometry.h> 63 CUGAR_FORCEINLINE CUGAR_HOST_DEVICE
65 const float _w1 = 0.5
f,
66 const float _w2 = 0.5
f,
67 const TBsdf1 _bsdf1 = TBsdf1(),
68 const TBsdf2 _bsdf2 = TBsdf2()) :
77 CUGAR_FORCEINLINE CUGAR_HOST_DEVICE
81 w1 * bsdf1.f(geometry,V,L) +
82 w2 * bsdf2.f(geometry,V,L);
87 CUGAR_FORCEINLINE CUGAR_HOST_DEVICE
91 w1 * bsdf1.f_over_p(geometry,V,L) +
92 w2 * bsdf2.f_over_p(geometry,V,L);
97 CUGAR_FORCEINLINE CUGAR_HOST_DEVICE
103 bsdf1.f_over_p( geometry, V, L, f1, p1, measure );
104 bsdf2.f_over_p( geometry, V, L, f2, p2, measure );
106 f = w1 * f1 + w2 * f2;
107 p = w1 * p1 + w2 * p2;
112 CUGAR_FORCEINLINE CUGAR_HOST_DEVICE
116 w1 * bsdf1.p(geometry,V,L) +
117 w2 * bsdf2.p(geometry,V,L);
122 CUGAR_FORCEINLINE CUGAR_HOST_DEVICE
135 bsdf1.sample(
Vector3f(u.x,u.y,u.z/w1), geometry, V, L, g, p, p_proj );
141 else if (u.z < w1 + w2)
144 bsdf2.sample(
Vector3f(u.x,u.y,(u.z-w1)/w2), geometry, V, L, g, p, p_proj );
155 p_proj = (1 - w1 - w2);
161 template <
typename RandomGeneratorT>
162 CUGAR_FORCEINLINE CUGAR_HOST_DEVICE
178 CUGAR_FORCEINLINE CUGAR_HOST_DEVICE
187 p_proj = 1.0f / this->
p( geometry, V, L, u, kProjectedSolidAngle );
188 p = fabsf(dot(L, geometry.normal_s)) * p_proj;
SphericalMeasure
Definition: differential_geometry.h:50
CUGAR_FORCEINLINE CUGAR_HOST_DEVICE BlendBsdf(const float _w1=0.5f, const float _w2=0.5f, const TBsdf1 _bsdf1=TBsdf1(), const TBsdf2 _bsdf2=TBsdf2())
Definition: blend.h:64
Defines various spherical mappings.
CUGAR_FORCEINLINE CUGAR_HOST_DEVICE float p(const DifferentialGeometry &geometry, const Vector3f V, const Vector3f L, const SphericalMeasure measure=kProjectedSolidAngle) const
Definition: blend.h:113
CUGAR_FORCEINLINE CUGAR_HOST_DEVICE bool invert(const DifferentialGeometry &geometry, const Vector3f V, const Vector3f L, RandomGeneratorT &random, Vector3f &z, float &p, float &p_proj) const
Definition: blend.h:163
CUGAR_FORCEINLINE CUGAR_HOST_DEVICE void sample(const Vector3f u, const DifferentialGeometry &geometry, const Vector3f V, Vector3f &L, Vector3f &g, float &p, float &p_proj) const
Definition: blend.h:123
CUGAR_FORCEINLINE CUGAR_HOST_DEVICE Vector3f f_over_p(const DifferentialGeometry &geometry, const Vector3f V, const Vector3f L) const
Definition: blend.h:88
Definition: differential_geometry.h:59
float random()
Definition: tiled_sampling.h:44
CUGAR_FORCEINLINE CUGAR_HOST_DEVICE void inverse_pdf(const DifferentialGeometry &geometry, const Vector3f V, const Vector3f L, const Vector3f u, float &p, float &p_proj) const
Definition: blend.h:179
Define a vector_view POD type and plain_view() for std::vector.
Definition: diff.h:38
CUGAR_FORCEINLINE CUGAR_HOST_DEVICE void f_and_p(const DifferentialGeometry &geometry, const Vector3f V, const Vector3f L, Vector3f &f, float &p, const SphericalMeasure measure=kProjectedSolidAngle) const
Definition: blend.h:98
CUGAR_FORCEINLINE CUGAR_HOST_DEVICE Vector3f f(const DifferentialGeometry &geometry, const Vector3f V, const Vector3f L) const
Definition: blend.h:78