36 #include <cugar/linalg/vector.h> 37 #include <cugar/basic/numbers.h> 39 #include <cugar/bsdf/differential_geometry.h> 53 CUGAR_FORCEINLINE CUGAR_HOST_DEVICE
54 LambertEdf(
const Vector3f _color) :
59 CUGAR_FORCEINLINE CUGAR_HOST_DEVICE
62 const float NoL = dot(geometry.normal_s, out);
64 return NoL > 0.0f ? color :
Vector3f(0.0
f);
69 CUGAR_FORCEINLINE CUGAR_HOST_DEVICE
72 const float NoL = dot(geometry.normal_s, out);
74 return NoL > 0.0f ? color * float(M_PI) :
Vector3f(0.0
f);
79 CUGAR_FORCEINLINE CUGAR_HOST_DEVICE
82 return (measure == kProjectedSolidAngle) ?
84 fabsf(dot(geometry.normal_s, out)) / float(M_PI);
89 CUGAR_FORCEINLINE CUGAR_HOST_DEVICE
101 out = local_dir[0] * geometry.tangent +
102 local_dir[1] * geometry.binormal +
103 local_dir[2] * geometry.normal_s;
104 g = color * float(M_PI);
105 p = local_dir[2] / float(M_PI);
106 p_proj = 1.0f / float(M_PI);
111 template <
typename RandomGeneratorT>
112 CUGAR_FORCEINLINE CUGAR_HOST_DEVICE
123 dot(L, geometry.tangent),
124 dot(L, geometry.binormal),
125 dot(L, geometry.normal_s));
127 const float LN = local_L[2];
132 p = float(M_PI) / cugar::max( LN, 1.0e-8
f );
133 p_proj = float(M_PI);
136 z =
Vector3f(u.x, u.y, random.next());
142 CUGAR_FORCEINLINE CUGAR_HOST_DEVICE
151 const Vector3f N = geometry.normal_s;
153 const float LN = dot(L, N);
159 p = float(M_PI) / cugar::max( LN, 1.0e-8
f );
160 p_proj = float(M_PI);
CUGAR_FORCEINLINE CUGAR_HOST_DEVICE Vector3f f_over_p(const DifferentialGeometry &geometry, const Vector3f in, const Vector3f out) const
Definition: lambert_edf.h:70
SphericalMeasure
Definition: differential_geometry.h:50
Defines various spherical mappings.
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_edf.h:113
Definition: differential_geometry.h:59
float random()
Definition: tiled_sampling.h:44
CUGAR_FORCEINLINE CUGAR_HOST_DEVICE Vector3f f(const DifferentialGeometry &geometry, const Vector3f in, const Vector3f out) const
Definition: lambert_edf.h:60
Define a vector_view POD type and plain_view() for std::vector.
Definition: diff.h:38
CUGAR_FORCEINLINE CUGAR_HOST_DEVICE float p(const DifferentialGeometry &geometry, const Vector3f in, const Vector3f out, const SphericalMeasure measure=kProjectedSolidAngle) const
Definition: lambert_edf.h:80
CUGAR_FORCEINLINE CUGAR_HOST_DEVICE void sample(const Vector2f u, const DifferentialGeometry &geometry, const Vector3f in, Vector3f &out, Vector3f &g, float &p, float &p_proj) const
Definition: lambert_edf.h:90
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_edf.h:143