25static_assert(
sizeof(ShaderClosure) >=
sizeof(PhongRampBsdf),
"PhongRampBsdf is too large!");
29 const int MAXCOLORS = 8;
31 const float npos =
pos * (
float)(MAXCOLORS - 1);
36 if (ipos >= (MAXCOLORS - 1)) {
37 return colors[MAXCOLORS - 1];
39 const float offset = npos - (
float)ipos;
40 return colors[ipos] * (1.0f - offset) + colors[ipos + 1] * offset;
46 bsdf->exponent =
max(bsdf->exponent, 0.0f);
56 const float m_exponent = bsdf->exponent;
57 const float cosNI =
dot(bsdf->N, wi);
58 const float cosNO =
dot(bsdf->N, wo);
60 if (cosNI > 0 && cosNO > 0) {
62 const float3 R = (2 * cosNI) * bsdf->N - wi;
63 const float cosRO =
dot(
R, wo);
65 const float cosp =
powf(cosRO, m_exponent);
67 const float out = cosNO * (m_exponent + 2) *
common;
68 *pdf = (m_exponent + 1) *
common;
78 return sqrt(1.0f / ((exponent + 2.0f) / 2.0f));
91 const float cosNI =
dot(bsdf->N, wi);
92 const float m_exponent = bsdf->exponent;
93 const float m_roughness = phong_ramp_exponent_to_roughness(m_exponent);
94 *sampled_roughness =
make_float2(m_roughness, m_roughness);
98 const float3 R = (2 * cosNI) * bsdf->N - wi;
103 const float cosTheta =
powf(rand.
y, 1 / (m_exponent + 1));
105 if (
dot(Ng, *wo) > 0.0f) {
107 const float cosNO =
dot(bsdf->N, *wo);
110 const float cosp =
powf(cosTheta, m_exponent);
112 *pdf = (m_exponent + 1) *
common;
113 const float out = cosNO * (m_exponent + 2) *
common;
dot(value.rgb, luminance_coefficients)") DEFINE_VALUE("REDUCE(lhs
ccl_device float3 spherical_cos_to_direction(const float cos_theta, const float phi)
ccl_device_inline T to_global(const float2 p, const T X, const T Y)
#define SHADER_CLOSURE_BASE
#define ccl_device_inline
#define CCL_NAMESPACE_END
VecBase< float, 3 > float3
@ CLOSURE_BSDF_PHONG_RAMP_ID
ccl_device_inline Spectrum rgb_to_spectrum(const float3 rgb)
ccl_device_inline int float_to_int(const float f)
ccl_device_inline void make_orthonormals(const float3 N, ccl_private float3 *a, ccl_private float3 *b)