68 uint type, param1_offset, param2_offset;
70 uint mix_weight_offset;
101 uint specular_offset, roughness_offset, specular_tint_offset, anisotropic_offset,
102 sheen_offset, sheen_tint_offset, clearcoat_offset, clearcoat_roughness_offset,
103 eta_offset, transmission_offset, anisotropic_rotation_offset,
104 transmission_roughness_offset;
111 &specular_tint_offset,
112 &anisotropic_offset);
117 &clearcoat_roughness_offset);
120 &transmission_offset,
121 &anisotropic_rotation_offset,
122 &transmission_roughness_offset);
126 float subsurface = param2;
134 float clearcoat_roughness =
stack_load_float(stack, clearcoat_roughness_offset);
136 float anisotropic_rotation =
stack_load_float(stack, anisotropic_rotation_offset);
137 float transmission_roughness =
stack_load_float(stack, transmission_roughness_offset);
144 if (anisotropic_rotation != 0.0f)
151 float cosNO =
dot(
N, sd->I);
158 float specular_weight = (1.0f - final_transmission);
187 # ifdef __SUBSURFACE__
188 float3 mixed_ss_base_color = subsurface_color * subsurface +
189 base_color * (1.0f - subsurface);
190 float3 subsurf_weight = weight * mixed_ss_base_color * diffuse_weight;
201 base_color = mixed_ss_base_color;
207 float3 diff_weight = weight * base_color * diffuse_weight;
224 bssrdf->radius = subsurface_radius * subsurface;
228 bssrdf->texture_blur = 0.0f;
241 float3 diff_weight = weight * base_color * diffuse_weight;
259 float3 m_ctint = m_cdlum > 0.0f ?
260 base_color / m_cdlum :
265 m_ctint * sheen_tint;
267 float3 sheen_weight = weight * sheen * sheen_color * diffuse_weight;
281 # ifdef __CAUSTICS_TRICKS__
286 float3 spec_weight = weight * specular_weight;
296 bsdf->
ior = (2.0f / (1.0f -
safe_sqrtf(0.08f * specular))) - 1.0f;
300 float aspect =
safe_sqrtf(1.0f - anisotropic * 0.9f);
306 float m_cdlum = 0.3f * base_color.
x + 0.6f * base_color.
y +
308 float3 m_ctint = m_cdlum > 0.0f ?
309 base_color / m_cdlum :
313 m_ctint * specular_tint;
328 # ifdef __CAUSTICS_TRICKS__
333 # ifdef __CAUSTICS_TRICKS__
338 float3 glass_weight = weight * final_transmission;
339 float3 cspec0 = base_color * specular_tint +
340 make_float3(1.0f, 1.0f, 1.0f) * (1.0f - specular_tint);
347 # ifdef __CAUSTICS_TRICKS__
362 bsdf->
alpha_x = refl_roughness * refl_roughness;
363 bsdf->
alpha_y = refl_roughness * refl_roughness;
376 # ifdef __CAUSTICS_TRICKS__
381 sd,
sizeof(
MicrofacetBsdf), base_color * glass_weight * (1.0f - fresnel));
388 transmission_roughness = 1.0f - (1.0f - refl_roughness) *
389 (1.0f - transmission_roughness);
391 transmission_roughness = refl_roughness;
393 bsdf->
alpha_x = transmission_roughness * transmission_roughness;
394 bsdf->
alpha_y = transmission_roughness * transmission_roughness;
427 # ifdef __CAUSTICS_TRICKS__
432 # ifdef __CAUSTICS_TRICKS__
442 bsdf->N = clearcoat_normal;
447 bsdf->
alpha_x = clearcoat_roughness * clearcoat_roughness;
448 bsdf->
alpha_y = clearcoat_roughness * clearcoat_roughness;
458 # ifdef __CAUSTICS_TRICKS__
504 #ifdef __CAUSTICS_TRICKS__
531 if (rotation != 0.0f)
535 float anisotropy =
clamp(param2, -0.99f, 0.99f);
536 if (anisotropy < 0.0f) {
572 #ifdef __CAUSTICS_TRICKS__
584 float eta =
fmaxf(param2, 1e-5f);
613 #ifdef __CAUSTICS_TRICKS__
622 float eta =
fmaxf(param2, 1e-5f);
626 float cosNO =
dot(
N, sd->I);
631 #ifdef __CAUSTICS_TRICKS__
647 #ifdef __CAUSTICS_TRICKS__
665 #ifdef __CAUSTICS_TRICKS__
688 float eta =
fmaxf(param2, 1e-5f);
713 #ifdef __CAUSTICS_TRICKS__
742 uint offset_ofs, ior_ofs, color_ofs, parametrization;
747 uint coat_ofs, melanin_ofs, melanin_redness_ofs, absorption_coefficient_ofs;
751 &melanin_redness_ofs,
752 &absorption_coefficient_ofs);
754 uint tint_ofs, random_ofs, random_color_ofs, random_roughness_ofs;
756 data_node3.
x, &tint_ofs, &random_ofs, &random_color_ofs, &random_roughness_ofs);
778 stack, random_roughness_ofs, data_node3.
w);
779 float factor_random_roughness = 1.0f + 2.0f * (
random - 0.5f) * random_roughness;
780 float roughness = param1 * factor_random_roughness;
781 float radial_roughness = param2 * factor_random_roughness;
785 float m0_roughness = 1.0f -
clamp(coat, 0.0f, 1.0f);
789 bsdf->
s = radial_roughness;
795 switch (parametrization) {
798 bsdf->
sigma = absorption_coefficient;
804 stack, melanin_redness_ofs, data_node2.
w);
808 random_color =
clamp(random_color, 0.0f, 1.0f);
809 float factor_random_color = 1.0f + 2.0f * (
random - 0.5f) * random_color;
810 melanin *= factor_random_color;
813 melanin = -
logf(
fmaxf(1.0f - melanin, 0.0001f));
816 float eumelanin = melanin * (1.0f - melanin_redness);
817 float pheomelanin = melanin * melanin_redness;
826 bsdf->
sigma = melanin_sigma + tint_sigma;
842 sd->flag |= bsdf_principled_hair_setup(sd, bsdf);
880 #ifdef __SUBSURFACE__
896 bssrdf->albedo = sd->svm_closure_weight;
897 bssrdf->texture_blur = param2;
921 uint type, density_offset, anisotropy_offset;
923 uint mix_weight_offset;
937 float3 weight = sd->svm_closure_weight;
951 float anisotropy = (
stack_valid(anisotropy_offset)) ?
954 volume->
g = anisotropy;
981 uint density_offset, anisotropy_offset, absorption_color_offset, mix_weight_offset;
983 node.y, &density_offset, &anisotropy_offset, &absorption_color_offset, &mix_weight_offset);
992 float primitive_density = 1.0f;
1001 primitive_density = primitive_volume_attribute_float(
kg, sd, attr_density);
1002 density =
fmaxf(density * primitive_density, 0.0f);
1008 float3 color = sd->svm_closure_weight;
1012 color *= primitive_volume_attribute_float3(
kg, sd, attr_color);
1019 float anisotropy = (
stack_valid(anisotropy_offset)) ?
1022 volume->
g = anisotropy;
1040 uint emission_offset, emission_color_offset, blackbody_offset, temperature_offset;
1042 node.z, &emission_offset, &emission_color_offset, &blackbody_offset, &temperature_offset);
1059 float temperature = primitive_volume_attribute_float(
kg, sd, attr_temperature);
1060 T *=
fmaxf(temperature, 0.0f);
1067 float sigma = 5.670373e-8f * 1e-6f /
M_PI_F;
1068 float intensity = sigma *
mix(1.0f,
T4, blackbody);
1082 float3 weight = sd->svm_closure_weight;
1099 float3 weight = sd->svm_closure_weight;
1136 sd->svm_closure_weight = weight;
1170 uint weight_offset, in_weight_offset, weight1_offset, weight2_offset;
1172 node.y, &weight_offset, &in_weight_offset, &weight1_offset, &weight2_offset);
MINLINE float safe_sqrtf(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 GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble u2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLdouble GLdouble v2 _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLdouble GLdouble nz _GL_VOID_RET _GL_VOID GLfloat GLfloat nz _GL_VOID_RET _GL_VOID GLint GLint nz _GL_VOID_RET _GL_VOID GLshort GLshort nz _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const GLfloat *values _GL_VOID_RET _GL_VOID GLsizei const GLushort *values _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID const GLuint const GLclampf *priorities _GL_VOID_RET _GL_VOID GLdouble y _GL_VOID_RET _GL_VOID GLfloat y _GL_VOID_RET _GL_VOID GLint y _GL_VOID_RET _GL_VOID GLshort y _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLfloat GLfloat z _GL_VOID_RET _GL_VOID GLint GLint z _GL_VOID_RET _GL_VOID GLshort GLshort z _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble w _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat w _GL_VOID_RET _GL_VOID GLint GLint GLint w _GL_VOID_RET _GL_VOID GLshort GLshort GLshort w _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble y2 _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat y2 _GL_VOID_RET _GL_VOID GLint GLint GLint y2 _GL_VOID_RET _GL_VOID GLshort GLshort GLshort y2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLuint *buffer _GL_VOID_RET _GL_VOID GLdouble t _GL_VOID_RET _GL_VOID GLfloat t _GL_VOID_RET _GL_VOID GLint t _GL_VOID_RET _GL_VOID GLshort t _GL_VOID_RET _GL_VOID GLdouble GLdouble r _GL_VOID_RET _GL_VOID GLfloat GLfloat r _GL_VOID_RET _GL_VOID GLint GLint r _GL_VOID_RET _GL_VOID GLshort GLshort r _GL_VOID_RET _GL_VOID GLdouble GLdouble r
_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 type
static float mix_weight(float weight, float weight2, char mix_mode)
ccl_device ccl_addr_space void * closure_alloc_extra(ShaderData *sd, int size)
ccl_device_inline ShaderClosure * bsdf_alloc(ShaderData *sd, int size, float3 weight)
CCL_NAMESPACE_BEGIN ccl_device ShaderClosure * closure_alloc(ShaderData *sd, int size, ClosureType type, float3 weight)
CCL_NAMESPACE_BEGIN ccl_device int bsdf_ashikhmin_shirley_setup(MicrofacetBsdf *bsdf)
ccl_device int bsdf_ashikhmin_velvet_setup(VelvetBsdf *bsdf)
ccl_device int bsdf_diffuse_setup(DiffuseBsdf *bsdf)
ccl_device int bsdf_translucent_setup(DiffuseBsdf *bsdf)
ccl_device int bsdf_hair_reflection_setup(HairBsdf *bsdf)
ccl_device int bsdf_hair_transmission_setup(HairBsdf *bsdf)
ccl_device_inline float3 bsdf_principled_hair_sigma_from_concentration(const float eumelanin, const float pheomelanin)
ccl_device_inline float3 bsdf_principled_hair_sigma_from_reflectance(const float3 color, const float azimuthal_roughness)
ccl_device int bsdf_microfacet_beckmann_setup(MicrofacetBsdf *bsdf)
ccl_device int bsdf_microfacet_ggx_refraction_setup(MicrofacetBsdf *bsdf)
ccl_device int bsdf_microfacet_ggx_fresnel_setup(MicrofacetBsdf *bsdf, const ShaderData *sd)
ccl_device int bsdf_microfacet_ggx_clearcoat_setup(MicrofacetBsdf *bsdf, const ShaderData *sd)
ccl_device int bsdf_microfacet_beckmann_refraction_setup(MicrofacetBsdf *bsdf)
ccl_device int bsdf_microfacet_ggx_setup(MicrofacetBsdf *bsdf)
ccl_device int bsdf_microfacet_multi_ggx_fresnel_setup(MicrofacetBsdf *bsdf, const ShaderData *sd)
ccl_device int bsdf_microfacet_multi_ggx_setup(MicrofacetBsdf *bsdf)
ccl_device int bsdf_microfacet_multi_ggx_glass_fresnel_setup(MicrofacetBsdf *bsdf, const ShaderData *sd)
ccl_device int bsdf_microfacet_multi_ggx_glass_setup(MicrofacetBsdf *bsdf)
ccl_device int bsdf_oren_nayar_setup(OrenNayarBsdf *bsdf)
ccl_device int bsdf_principled_diffuse_setup(PrincipledDiffuseBsdf *bsdf)
ccl_device int bsdf_principled_sheen_setup(const ShaderData *sd, PrincipledSheenBsdf *bsdf)
CCL_NAMESPACE_BEGIN ccl_device int bsdf_reflection_setup(MicrofacetBsdf *bsdf)
CCL_NAMESPACE_BEGIN ccl_device int bsdf_refraction_setup(MicrofacetBsdf *bsdf)
ccl_device int bsdf_diffuse_toon_setup(ToonBsdf *bsdf)
ccl_device int bsdf_glossy_toon_setup(ToonBsdf *bsdf)
CCL_NAMESPACE_BEGIN ccl_device void bsdf_transparent_setup(ShaderData *sd, const float3 weight, int path_flag)
ccl_device float fresnel_dielectric_cos(float cosi, float eta)
ccl_device int bssrdf_setup(ShaderData *sd, Bssrdf *bssrdf, ClosureType type)
ccl_device_inline Bssrdf * bssrdf_alloc(ShaderData *sd, float3 weight)
static CCL_NAMESPACE_BEGIN const double alpha
ccl_device void emission_setup(ShaderData *sd, const float3 weight)
CCL_NAMESPACE_BEGIN ccl_device void background_setup(ShaderData *sd, const float3 weight)
IMETHOD void random(Vector &a)
addDelta operator for displacement rotational velocity.
ccl_device_inline AttributeDescriptor find_attribute(KernelGlobals *kg, const ShaderData *sd, uint id)
CCL_NAMESPACE_BEGIN ccl_device_inline float primitive_surface_attribute_float(KernelGlobals *kg, const ShaderData *sd, const AttributeDescriptor desc, float *dx, float *dy)
IconTextureDrawCall normal
CCL_NAMESPACE_BEGIN ccl_device void volume_extinction_setup(ShaderData *sd, float3 weight)
ccl_device int volume_henyey_greenstein_setup(HenyeyGreensteinVolume *volume)
CCL_NAMESPACE_BEGIN ccl_device_inline float3 stack_load_float3(float *stack, uint a)
ccl_device_inline uint4 read_node(KernelGlobals *kg, int *offset)
ccl_device_inline float stack_load_float_default(float *stack, uint a, uint value)
ccl_device_inline float stack_load_float(float *stack, uint a)
ccl_device_inline void stack_store_float3(float *stack, uint a, float3 f)
ccl_device_forceinline void svm_unpack_node_uchar4(uint i, uint *x, uint *y, uint *z, uint *w)
ccl_device_inline void stack_store_float(float *stack, uint a, float f)
ccl_device_inline bool stack_valid(uint a)
ccl_device float linear_rgb_to_gray(KernelGlobals *kg, float3 c)
#define kernel_assert(cond)
#define ccl_device_inline
#define CCL_NAMESPACE_END
#define make_float3(x, y, z)
@ PATH_RAY_DIFFUSE_ANCESTOR
static const pxr::TfToken roughness("roughness", pxr::TfToken::Immortal)
static const pxr::TfToken metallic("metallic", pxr::TfToken::Immortal)
closure color absorption() BUILTIN
closure color bssrdf(string method, normal N, vector radius, color albedo) BUILTIN
PrincipledHairExtra * extra
ccl_device void svm_node_closure_bsdf(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node, ShaderType shader_type, int path_flag, int *offset)
ccl_device void svm_node_mix_closure(ShaderData *sd, float *stack, uint4 node)
ccl_device void svm_node_closure_background(ShaderData *sd, float *stack, uint4 node)
ccl_device_inline void svm_node_closure_store_weight(ShaderData *sd, float3 weight)
CCL_NAMESPACE_BEGIN ccl_device void svm_node_glass_setup(ShaderData *sd, MicrofacetBsdf *bsdf, int type, float eta, float roughness, bool refract)
ccl_device void svm_node_closure_emission(ShaderData *sd, float *stack, uint4 node)
ccl_device void svm_node_principled_volume(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node, ShaderType shader_type, int path_flag, int *offset)
ccl_device void svm_node_set_normal(KernelGlobals *kg, ShaderData *sd, float *stack, uint in_direction, uint out_normal)
ccl_device void svm_node_emission_weight(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node)
ccl_device void svm_node_closure_set_weight(ShaderData *sd, uint r, uint g, uint b)
ccl_device void svm_node_closure_holdout(ShaderData *sd, float *stack, uint4 node)
ccl_device void svm_node_closure_volume(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node, ShaderType shader_type)
ccl_device void svm_node_closure_weight(ShaderData *sd, float *stack, uint weight_offset)
ccl_device float3 svm_math_blackbody_color(float t)
@ NODE_PRINCIPLED_HAIR_REFLECTANCE
@ NODE_PRINCIPLED_HAIR_DIRECT_ABSORPTION
@ NODE_PRINCIPLED_HAIR_PIGMENT_CONCENTRATION
#define SVM_STACK_INVALID
@ CLOSURE_BSDF_MICROFACET_GGX_REFRACTION_ID
@ CLOSURE_VOLUME_HENYEY_GREENSTEIN_ID
@ CLOSURE_BSDF_ASHIKHMIN_SHIRLEY_ID
@ CLOSURE_BSSRDF_CUBIC_ID
@ CLOSURE_BSDF_HAIR_PRINCIPLED_ID
@ CLOSURE_BSSRDF_GAUSSIAN_ID
@ CLOSURE_BSDF_MICROFACET_GGX_GLASS_ID
@ CLOSURE_BSDF_DIFFUSE_ID
@ CLOSURE_BSSRDF_BURLEY_ID
@ CLOSURE_BSDF_PRINCIPLED_ID
@ CLOSURE_BSDF_TRANSPARENT_ID
@ CLOSURE_BSDF_DIFFUSE_TOON_ID
@ CLOSURE_BSDF_MICROFACET_GGX_ID
@ CLOSURE_BSDF_MICROFACET_BECKMANN_REFRACTION_ID
@ CLOSURE_BSDF_MICROFACET_MULTI_GGX_ID
@ CLOSURE_BSDF_HAIR_TRANSMISSION_ID
@ CLOSURE_BSDF_SHARP_GLASS_ID
@ CLOSURE_BSDF_MICROFACET_BECKMANN_GLASS_ID
@ CLOSURE_BSSRDF_RANDOM_WALK_ID
@ CLOSURE_BSDF_REFRACTION_ID
@ CLOSURE_BSDF_MICROFACET_BECKMANN_ID
@ CLOSURE_BSDF_MICROFACET_MULTI_GGX_GLASS_ID
@ CLOSURE_BSSRDF_PRINCIPLED_ID
@ CLOSURE_BSDF_GLOSSY_TOON_ID
@ CLOSURE_VOLUME_ABSORPTION_ID
@ CLOSURE_BSDF_HAIR_REFLECTION_ID
@ CLOSURE_BSDF_TRANSLUCENT_ID
@ CLOSURE_BSDF_REFLECTION_ID
@ CLOSURE_BSDF_ASHIKHMIN_VELVET_ID
#define CLOSURE_WEIGHT_CUTOFF
ccl_device_inline float __uint_as_float(uint i)
ccl_device_inline float saturate(float a)
ccl_device_inline float sqr(float a)
ccl_device_inline float3 rotate_around_axis(float3 p, float3 axis, float angle)
ccl_device_inline int clamp(int a, int mn, int mx)
ccl_device_inline float2 normalize(const float2 &a)
ccl_device_inline float dot(const float2 &a, const float2 &b)
ccl_device_inline float average(const float2 &a)
ccl_device_inline float3 refract(const float3 incident, const float3 normal, const float eta)