| 102 | struct Diffuse : public BSDF, DiffuseParams { |
| 103 | Diffuse(const DiffuseParams& params) : BSDF(), DiffuseParams(params) { if (trans) N = -N; } |
| 104 | virtual float eval (const OSL::ShaderGlobals& sg, const OSL::Vec3& wi, float& pdf) const { |
| 105 | pdf = std::max(N.dot(wi), 0.0f) * float(M_1_PI); |
| 106 | return 1.0f; |
| 107 | } |
| 108 | virtual float sample(const OSL::ShaderGlobals& sg, float rx, float ry, float rz, OSL::Dual2<OSL::Vec3>& wi, float& pdf) const { |
| 109 | Vec3 out_dir; |
| 110 | Sampling::sample_cosine_hemisphere(N, rx, ry, out_dir, pdf); |