MCPcopy Create free account
hub / github.com/AcademySoftwareFoundation/OpenShadingLanguage / Diffuse

Class Diffuse

src/testrender/shading.cpp:102–114  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

100
101template <int trans>
102struct 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);
111 wi = out_dir; // FIXME: leave derivs 0?
112 return 1;
113 }
114};
115
116struct OrenNayar : public BSDF, OrenNayarParams {
117 OrenNayar(const OrenNayarParams& params) : BSDF(), OrenNayarParams(params) {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected