36 #include <cugar/linalg/vector.h> 37 #include <cugar/basic/numbers.h> 38 #include <cugar/bsdf/differential_geometry.h> 48 struct LambertTransBsdf
53 CUGAR_FORCEINLINE CUGAR_HOST_DEVICE
54 LambertTransBsdf(
const Vector3f _color) :
59 CUGAR_FORCEINLINE CUGAR_HOST_DEVICE
62 const Vector3f N = geometry.normal_s;
64 const float NoL = dot(N,L);
65 const float NoV = dot(N,V);
67 return NoL * NoV < 0.0f ? color :
Vector3f(0.0
f);
72 CUGAR_FORCEINLINE CUGAR_HOST_DEVICE
75 const Vector3f N = geometry.normal_s;
77 const float NoL = dot(N,L);
78 const float NoV = dot(N,V);
80 return NoL * NoV < 0.0f ? color * M_PIf :
Vector3f(0.0
f);
85 CUGAR_FORCEINLINE CUGAR_HOST_DEVICE
88 const Vector3f N = geometry.normal_s;
90 const float NoL = dot(N, L);
91 const float NoV = dot(N, V);
93 f = NoL * NoV < 0.0f ? color :
Vector3f(0.0f);
94 p = NoL * NoV < 0.0f ? 1.0f / M_PIf : 0.0f;
96 if (measure == kSolidAngle)
102 CUGAR_FORCEINLINE CUGAR_HOST_DEVICE
105 const Vector3f N = geometry.normal_s;
107 const float NoL = dot(N, L);
108 const float NoV = dot(N, V);
110 const float p = NoL * NoV < 0.0f ? 1.0f / M_PIf : 0.0f;
112 return (measure == kSolidAngle) ? p * fabsf(NoL) :
p;
117 CUGAR_FORCEINLINE CUGAR_HOST_DEVICE
127 const Vector3f N = geometry.normal_s;
130 if (dot(V, N) > 0.0f)
131 local_L[2] = -local_L[2];
133 L = local_L[0] * geometry.tangent +
134 local_L[1] * geometry.binormal +
135 local_L[2] * geometry.normal_s;
138 p = fabsf( local_L[2] ) / M_PIf;
139 p_proj = 1.0f / M_PIf;
144 template <
typename RandomGeneratorT>
145 CUGAR_FORCEINLINE CUGAR_HOST_DEVICE
155 const Vector3f N = geometry.normal_s;
157 if (dot(V, N) * dot(L, N) > 0.0
f)
161 dot(L, geometry.tangent ),
162 dot(L, geometry.binormal ),
163 fabsf(dot(L, geometry.normal_s )));
165 p = M_PIf / cugar::max( local_L[2], 1.0e-8
f );
169 z =
Vector3f(u.x, u.y, random.next());
175 CUGAR_FORCEINLINE CUGAR_HOST_DEVICE
184 const Vector3f N = geometry.normal_s;
186 const float NoL = dot(N, L);
187 const float NoV = dot(N, V);
189 if (NoV * NoL > 0.0
f)
193 p = M_PIf / cugar::max(fabsf(NoL), 1.0e-8
f);
CUGAR_FORCEINLINE CUGAR_HOST_DEVICE float p(const DifferentialGeometry &geometry, const Vector3f V, const Vector3f L, const SphericalMeasure measure=kProjectedSolidAngle) const
Definition: lambert_trans.h:103
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: lambert_trans.h:118
SphericalMeasure
Definition: differential_geometry.h:50
CUGAR_FORCEINLINE CUGAR_HOST_DEVICE Vector3f f_over_p(const DifferentialGeometry &geometry, const Vector3f V, const Vector3f L) const
Definition: lambert_trans.h:73
Defines various spherical mappings.
CUGAR_FORCEINLINE CUGAR_HOST_DEVICE Vector3f f(const DifferentialGeometry &geometry, const Vector3f V, const Vector3f L) const
Definition: lambert_trans.h:60
Definition: differential_geometry.h:59
float random()
Definition: tiled_sampling.h:44
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: lambert_trans.h:86
CUGAR_HOST CUGAR_DEVICE Vector3f square_to_cosine_hemisphere(const Vector2f &uv)
Definition: mappings_inline.h:119
CUGAR_HOST CUGAR_DEVICE Vector2f cosine_hemisphere_to_square(const Vector3f &dir)
Definition: mappings_inline.h:137
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: lambert_trans.h:176
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: lambert_trans.h:146