33 #ifndef __BSDF_DIFFUSE_RAMP_H__
34 #define __BSDF_DIFFUSE_RAMP_H__
46 static_assert(
sizeof(
ShaderClosure) >=
sizeof(DiffuseRampBsdf),
"DiffuseRampBsdf is too large!");
52 float npos =
pos * (
float)(MAXCOLORS - 1);
56 if (ipos >= (MAXCOLORS - 1))
57 return colors[MAXCOLORS - 1];
58 float offset = npos - (
float)ipos;
59 return colors[ipos] * (1.0f - offset) + colors[ipos + 1] * offset;
62 ccl_device int bsdf_diffuse_ramp_setup(DiffuseRampBsdf *bsdf)
77 const DiffuseRampBsdf *bsdf = (
const DiffuseRampBsdf *)sc;
80 float cos_pi =
fmaxf(
dot(
N, omega_in), 0.0f);
82 return bsdf_diffuse_ramp_get_color(bsdf->colors, cos_pi) *
M_1_PI_F;
106 const DiffuseRampBsdf *bsdf = (
const DiffuseRampBsdf *)sc;
112 if (
dot(Ng, *omega_in) > 0.0f) {
113 *eval = bsdf_diffuse_ramp_get_color(bsdf->colors, *pdf *
M_PI_F) *
M_1_PI_F;
114 # ifdef __RAY_DIFFERENTIALS__
115 *domega_in_dx = (2 *
dot(
N, dIdx)) *
N - dIdx;
116 *domega_in_dy = (2 *
dot(
N, dIdy)) *
N - dIdy;
typedef float(TangentPoint)[2]
#define CCL_NAMESPACE_END
#define make_float3(x, y, z)
ccl_device_inline void sample_cos_hemisphere(const float3 N, float randu, float randv, float3 *omega_in, float *pdf)
#define SHADER_CLOSURE_BASE
static const pxr::TfToken roughness("roughness", pxr::TfToken::Immortal)
@ CLOSURE_BSDF_DIFFUSE_RAMP_ID
ccl_device_inline int float_to_int(float f)
ccl_device_inline float dot(const float2 &a, const float2 &b)