36 #include <cugar/linalg/vector.h> 37 #include <cugar/basic/numbers.h> 38 #include <cugar/bsdf/differential_geometry.h> 66 CUGAR_FORCEINLINE CUGAR_HOST_DEVICE
67 LambertBsdf(
const Vector3f _color) :
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 :
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 return NoL * NoV >= 0.0f ? color * M_PIf :
Vector3f(0.0
f);
98 CUGAR_FORCEINLINE CUGAR_HOST_DEVICE
101 const Vector3f N = geometry.normal_s;
103 const float NoL = dot(N, L);
104 const float NoV = dot(N, V);
106 f = NoL * NoV > 0.0f ? color :
Vector3f(0.0f);
107 p = NoL * NoV > 0.0f ? 1.0f / M_PIf : 0.0f;
109 if (measure == kSolidAngle)
115 CUGAR_FORCEINLINE CUGAR_HOST_DEVICE
118 const Vector3f N = geometry.normal_s;
120 const float NoL = dot(N, L);
121 const float NoV = dot(N, V);
123 const float p = NoL * NoV > 0.0f ? 1.0f / M_PIf : 0.0f;
125 return (measure == kSolidAngle) ? p * fabsf(NoL) :
p;
130 CUGAR_FORCEINLINE CUGAR_HOST_DEVICE
140 const Vector3f N = geometry.normal_s;
143 if (dot(V, N) < 0.0f)
144 local_L[2] = -local_L[2];
146 L = local_L[0] * geometry.tangent +
147 local_L[1] * geometry.binormal +
148 local_L[2] * geometry.normal_s;
151 p = fabsf( local_L[2] ) / M_PIf;
152 p_proj = 1.0f / M_PIf;
157 template <
typename RandomGeneratorT>
158 CUGAR_FORCEINLINE CUGAR_HOST_DEVICE
168 const Vector3f N = geometry.normal_s;
170 if (dot(V, N) * dot(L, N) < 0.0
f)
174 dot(L, geometry.tangent ),
175 dot(L, geometry.binormal ),
176 fabsf(dot(L, geometry.normal_s )));
178 p = M_PIf / cugar::max( local_L[2], 1.0e-8
f );
182 z =
Vector3f(u.x, u.y, random.next());
188 CUGAR_FORCEINLINE CUGAR_HOST_DEVICE
197 const Vector3f N = geometry.normal_s;
199 if (dot(V, N) * dot(L, N) < 0.0
f)
203 p = M_PIf / cugar::max(fabsf(dot(L, N)), 1.0e-8
f);
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.h:86
Defines various spherical mappings.
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.h:131
Definition: differential_geometry.h:59
float random()
Definition: tiled_sampling.h:44
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.h:159
Define a vector_view POD type and plain_view() for std::vector.
Definition: diff.h:38
CUGAR_FORCEINLINE CUGAR_HOST_DEVICE Vector3f f(const DifferentialGeometry &geometry, const Vector3f V, const Vector3f L) const
Definition: lambert.h:73
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.h:99
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 float p(const DifferentialGeometry &geometry, const Vector3f V, const Vector3f L, const SphericalMeasure measure=kProjectedSolidAngle) const
Definition: lambert.h:116
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.h:189