40 "PrincipledHairBSDF is too large!");
42 "PrincipledHairExtra is too large!");
53 return 2.0f * p * gamma_t - 2.0f * gamma_o + p *
M_PI_F;
72 return v / (s *
sqr(1.0f +
v));
84 return 1.0f / (1.0f +
expf(arg));
92 float val = 1.0f + 0.25f *
x;
93 float pow_x_2i =
sqr(
x);
96 for (
int i = 2; i < 10; i++) {
98 float newval = val + pow_x_2i / (pow_4_i * i_fac_2);
137 float x = -s *
logf(1.0f / (u * (1.0f - 2.0f * cdf_minuspi) + cdf_minuspi) - 1.0f);
143 float phi,
int p,
float s,
float gamma_o,
float gamma_t)
152 float sin_theta_i,
float cos_theta_i,
float sin_theta_o,
float cos_theta_o,
float v)
154 float inv_v = 1.0f /
v;
155 float cos_arg = cos_theta_i * cos_theta_o * inv_v;
156 float sin_arg = sin_theta_i * sin_theta_o * inv_v;
159 float val =
expf(i0 - sin_arg - inv_v + 0.6931f +
logf(0.5f * inv_v));
164 float val = (
expf(-sin_arg) * i0) / (
sinhf(inv_v) * 2.0f *
v);
181 bsdf->v =
clamp(bsdf->v, 0.001f, 1.0f);
182 bsdf->s =
clamp(bsdf->s, 0.001f, 1.0f);
184 bsdf->m0_roughness =
clamp(bsdf->m0_roughness * bsdf->v, 0.001f, 1.0f);
187 bsdf->v =
sqr(0.726f * bsdf->v + 0.812f *
sqr(bsdf->v) + 3.700f *
pow20(bsdf->v));
189 bsdf->m0_roughness =
sqr(0.726f * bsdf->m0_roughness + 0.812f *
sqr(bsdf->m0_roughness) +
190 3.700f *
pow20(bsdf->m0_roughness));
238 float totweight = Ap[0].w + Ap[1].w + Ap[2].w + Ap[3].w;
253 float sin_1alpha =
sinf(alpha);
255 float sin_2alpha = 2.0f * sin_1alpha * cos_1alpha;
256 float cos_2alpha =
sqr(cos_1alpha) -
sqr(sin_1alpha);
257 float sin_4alpha = 2.0f * sin_2alpha * cos_2alpha;
258 float cos_4alpha =
sqr(cos_2alpha) -
sqr(sin_2alpha);
260 angles[0] = sin_theta_i * cos_2alpha + cos_theta_i * sin_2alpha;
261 angles[1] =
fabsf(cos_theta_i * cos_2alpha - sin_theta_i * sin_2alpha);
262 angles[2] = sin_theta_i * cos_1alpha - cos_theta_i * sin_1alpha;
263 angles[3] =
fabsf(cos_theta_i * cos_1alpha + sin_theta_i * sin_1alpha);
264 angles[4] = sin_theta_i * cos_4alpha - cos_theta_i * sin_4alpha;
265 angles[5] =
fabsf(cos_theta_i * cos_4alpha + sin_theta_i * sin_4alpha);
287 float sin_theta_o = wo.
x;
291 float sin_theta_t = sin_theta_o / bsdf->eta;
294 float sin_gamma_o = bsdf->extra->geom.w;
298 float sin_gamma_t = sin_gamma_o * cos_theta_o /
sqrtf(
sqr(bsdf->eta) -
sqr(sin_theta_o));
302 float3 T =
exp(-bsdf->sigma * (2.0f * cos_gamma_t / cos_theta_t));
306 float sin_theta_i = wi.
x;
310 float phi = phi_i - phi_o;
327 F += Ap[1] * Mp * Np;
333 F += Ap[2] * Mp * Np;
339 F += Ap[3] * Mp * Np;
373 float sin_theta_o = wo.
x;
377 float sin_theta_t = sin_theta_o / bsdf->eta;
380 float sin_gamma_o = bsdf->extra->geom.w;
384 float sin_gamma_t = sin_gamma_o * cos_theta_o /
sqrtf(
sqr(bsdf->eta) -
sqr(sin_theta_o));
388 float3 T =
exp(-bsdf->sigma * (2.0f * cos_gamma_t / cos_theta_t));
394 if (u[0].
x < Ap[p].
w) {
408 u[1].
x =
max(u[1].
x, 1e-5f);
409 float fac = 1.0f +
v *
logf(u[1].
x + (1.0f - u[1].
x) *
expf(-2.0f /
v));
410 float sin_theta_i = -fac * sin_theta_o +
417 sin_theta_i = angles[2 * p];
418 cos_theta_i = angles[2 * p + 1];
428 float phi_i = phi_o + phi;
444 F += Ap[1] * Mp * Np;
450 F += Ap[2] * Mp * Np;
456 F += Ap[3] * Mp * Np;
462 *omega_in =
X * sin_theta_i +
Y * cos_theta_i *
cosf(phi_i) +
Z * cos_theta_i *
sinf(phi_i);
464 #ifdef __RAY_DIFFERENTIALS__
466 *domega_in_dx = (2 *
dot(
N, sd->dI.dx)) *
N - sd->dI.dx;
467 *domega_in_dy = (2 *
dot(
N, sd->dI.dy)) *
N - sd->dI.dy;
486 const float azimuthal_roughness)
488 const float x = azimuthal_roughness;
489 return (((((0.245f *
x) + 5.574f) *
x - 10.73f) *
x + 2.532f) *
x - 0.215f) *
x + 5.969f;
503 return sigma * sigma;
507 const float pheomelanin)
509 return eumelanin *
make_float3(0.506f, 0.841f, 1.653f) +
MINLINE float safe_sqrtf(float a)
MINLINE float safe_asinf(float a)
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint y
in reality light always falls off quadratically Particle Retrieve the data of the particle that spawned the object for example to give variation to multiple instances of an object Point Retrieve information about points in a point cloud Retrieve the edges of an object as it appears to Cycles topology will always appear triangulated Convert a blackbody temperature to an RGB value Normal Generate a perturbed normal from an RGB normal map image Typically used for faking highly detailed surfaces Generate an OSL shader from a file or text data block Image Sample an image file as a texture Sky Generate a procedural sky texture Noise Generate fractal Perlin noise Wave Generate procedural bands or rings with noise Voronoi Generate Worley noise based on the distance to random points Typically used to generate textures such as or biological cells Brick Generate a procedural texture producing bricks Texture Retrieve multiple types of texture coordinates nTypically used as inputs for texture nodes Vector Convert a or normal between and object coordinate space Combine Create a color from its and value channels Color Retrieve a color or the default fallback if none is specified Separate Split a vector into its X
in reality light always falls off quadratically Particle Retrieve the data of the particle that spawned the object for example to give variation to multiple instances of an object Point Retrieve information about points in a point cloud Retrieve the edges of an object as it appears to Cycles topology will always appear triangulated Convert a blackbody temperature to an RGB value Normal Generate a perturbed normal from an RGB normal map image Typically used for faking highly detailed surfaces Generate an OSL shader from a file or text data block Image Sample an image file as a texture Sky Generate a procedural sky texture Noise Generate fractal Perlin noise Wave Generate procedural bands or rings with noise Voronoi Generate Worley noise based on the distance to random points Typically used to generate textures such as or biological cells Brick Generate a procedural texture producing bricks Texture Retrieve multiple types of texture coordinates nTypically used as inputs for texture nodes Vector Convert a or normal between and object coordinate space Combine Create a color from its and value channels Color Retrieve a color or the default fallback if none is specified Separate Split a vector into its Y
Group Output data from inside of a node group A color picker Mix two input colors RGB to Convert a color s luminance to a grayscale value Generate a normal vector and a dot product Bright Control the brightness and contrast of the input color Vector Map an input vectors to used to fine tune the interpolation of the input Camera Retrieve information about the camera and how it relates to the current shading point s position Clamp a value between a minimum and a maximum Vector Perform vector math operation Invert a color
ATTR_WARN_UNUSED_RESULT const BMVert * v
ccl_device_inline float logistic_cdf(float x, float s)
ccl_device void bsdf_principled_hair_blur(ccl_private ShaderClosure *sc, float roughness)
ccl_device_inline float logistic(float x, float s)
ccl_device_inline void hair_attenuation(KernelGlobals kg, float f, float3 T, ccl_private float4 *Ap)
ccl_device_inline float delta_phi(int p, float gamma_o, float gamma_t)
ccl_device_inline float log_bessel_I0(float x)
ccl_device_inline float longitudinal_scattering(float sin_theta_i, float cos_theta_i, float sin_theta_o, float cos_theta_o, float v)
ccl_device_inline float3 bsdf_principled_hair_sigma_from_concentration(const float eumelanin, const float pheomelanin)
ccl_device_inline float bsdf_principled_hair_albedo_roughness_scale(const float azimuthal_roughness)
ccl_device_inline float sample_trimmed_logistic(float u, float s)
ccl_device float3 bsdf_principled_hair_albedo(ccl_private const ShaderClosure *sc)
CCL_NAMESPACE_BEGIN struct PrincipledHairExtra PrincipledHairExtra
ccl_device int bsdf_principled_hair_sample(KernelGlobals kg, ccl_private const ShaderClosure *sc, ccl_private ShaderData *sd, float randu, float randv, ccl_private float3 *eval, ccl_private float3 *omega_in, ccl_private float3 *domega_in_dx, ccl_private float3 *domega_in_dy, ccl_private float *pdf)
ccl_device_inline float wrap_angle(float a)
ccl_device_inline void hair_alpha_angles(float sin_theta_i, float cos_theta_i, float alpha, ccl_private float *angles)
ccl_device_inline float azimuthal_scattering(float phi, int p, float s, float gamma_o, float gamma_t)
ccl_device_inline float bessel_I0(float x)
ccl_device float3 bsdf_principled_hair_eval(KernelGlobals kg, ccl_private const ShaderData *sd, ccl_private const ShaderClosure *sc, const float3 omega_in, ccl_private float *pdf)
ccl_device_inline float trimmed_logistic(float x, float s)
struct PrincipledHairBSDF PrincipledHairBSDF
ccl_device_inline float4 combine_with_energy(KernelGlobals kg, float3 c)
ccl_device_inline float3 bsdf_principled_hair_sigma_from_reflectance(const float3 color, const float azimuthal_roughness)
ccl_device_inline float cos_from_sin(const float s)
ccl_device float fresnel_dielectric_cos(float cosi, float eta)
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
#define kernel_assert(cond)
#define ccl_device_inline
#define CCL_NAMESPACE_END
const KernelGlobalsCPU *ccl_restrict KernelGlobals
@ CLOSURE_BSDF_HAIR_PRINCIPLED_ID
ccl_device float linear_rgb_to_gray(KernelGlobals kg, float3 c)
ccl_device float lcg_step_float(T rng)
ccl_device_inline float2 safe_normalize(const float2 &a)
ccl_device_inline float3 exp(float3 v)
ccl_device_inline float3 log(float3 v)
T dot(const vec_base< T, Size > &a, const vec_base< T, Size > &b)
vec_base< T, 3 > cross(const vec_base< T, 3 > &a, const vec_base< T, 3 > &b)
T clamp(const T &a, const T &min, const T &max)
T safe_divide(const T &a, const T &b)
static const pxr::TfToken roughness("roughness", pxr::TfToken::Immortal)
unsigned __int64 uint64_t
ccl_private PrincipledHairExtra * extra
ccl_device_inline float pow22(float a)
ccl_device_inline float pow20(float a)
ccl_device_inline float sqr(float a)
ccl_device_inline float3 safe_divide_color(float3 a, float3 b)
ccl_device_inline bool isfinite_safe(float f)
ccl_device_inline float3 float4_to_float3(const float4 a)