39 # define MNEE_MAX_ITERATIONS 64
40 # define MNEE_MAX_INTERSECTION_COUNT 10
41 # define MNEE_SOLVER_THRESHOLD 0.001f
42 # define MNEE_MINIMUM_STEP_SIZE 0.0001f
43 # define MNEE_MAX_CAUSTIC_CASTERS 6
44 # define MNEE_MIN_DISTANCE 0.001f
45 # define MNEE_MIN_PROGRESS_DISTANCE 0.0001f
46 # define MNEE_MIN_DETERMINANT 0.0001f
47 # define MNEE_PROJECTION_DISTANCE_MULTIPLIER 2.f
92 a.x *
b.x +
a.y *
b.z,
a.x *
b.y +
a.y *
b.w,
a.z *
b.x +
a.w *
b.z,
a.z *
b.y +
a.w *
b.w);
98 return m.x * m.w - m.y * m.z;
104 float det = mat22_determinant(m);
105 if (
fabsf(det) < MNEE_MIN_DETERMINANT)
107 m_inverse =
make_float4(m.w, -m.y, -m.z, m.x) / det;
128 float invarea = klight->spot.invarea;
129 ls->eval_fac = (0.25f *
M_1_PI_F) * invarea;
134 float3 dir =
make_float3(klight->spot.dir[0], klight->spot.dir[1], klight->spot.dir[2]);
136 dir, klight->spot.spot_angle, klight->spot.spot_smooth, ls->Ng);
140 float invarea =
fabsf(klight->area.invarea);
143 if (klight->area.tan_spread > 0.f) {
144 ls->eval_fac = 0.25f * invarea;
146 ls->D, ls->Ng, klight->area.tan_spread, klight->area.normalize_spread);
166 sd_vtx->type = isect->type;
171 shader_setup_object_transforms(kg, sd_vtx, ray->time);
172 sd_vtx->time = ray->time;
174 sd_vtx->prim = isect->prim;
175 sd_vtx->ray_length = isect->t;
177 sd_vtx->u = isect->u;
178 sd_vtx->v = isect->v;
189 sd_vtx->P = (1.f - isect->u - isect->v) *
verts[0] + isect->u *
verts[1] + isect->v *
verts[2];
198 kg, sd_vtx->object, sd_vtx->prim, sd_vtx->time,
verts,
normals);
202 kg, sd_vtx, isect->object, isect->prim, isect->u, isect->v,
verts);
233 const float inv_n_len = 1.f / n_len;
236 dn_du -= vtx->n *
dot(vtx->n, dn_du);
237 dn_dv -= vtx->n *
dot(vtx->n, dn_dv);
241 const float inv_len_dp_du = 1.f /
len(dp_du);
242 dp_du *= inv_len_dp_du;
243 dn_du *= inv_len_dp_du;
245 const float dpdu_dot_dpdv =
dot(dp_du, dp_dv);
246 dp_dv -= dpdu_dot_dpdv * dp_du;
247 dn_dv -= dpdu_dot_dpdv * dn_du;
249 const float inv_len_dp_dv = 1.f /
len(dp_dv);
250 dp_dv *= inv_len_dp_dv;
251 dn_dv *= inv_len_dp_dv;
256 const float cos_theta =
dot(dp_du, vtx->dp_du);
257 const float sin_theta = -
dot(dp_dv, vtx->dp_du);
258 vtx->dn_du = cos_theta * dn_du - sin_theta * dn_dv;
259 vtx->dn_dv = sin_theta * dn_du + cos_theta * dn_dv;
268 vtx->n_offset = n_offset;
276 vtx->object = sd_vtx->object;
277 vtx->prim = sd_vtx->prim;
278 vtx->shader = sd_vtx->shader;
286 const bool light_fixed_direction,
289 for (
int vi = 0; vi < vertex_count; vi++) {
293 float3 wi = (vi == 0) ? surface_sample_pos -
v.p : vertices[vi - 1].p -
v.p;
295 if (ili < MNEE_MIN_DISTANCE)
301 float3 wo = (vi == vertex_count - 1) ?
303 vertices[vi + 1].p -
v.p;
305 if (ilo < MNEE_MIN_DISTANCE)
312 if (
dot(wi,
v.ng) < .0f)
317 float ilh = 1.f /
len(
H);
324 float dp_du_dot_n =
dot(
v.dp_du,
v.n);
325 float3 s =
v.dp_du - dp_du_dot_n *
v.n;
326 float inv_len_s = 1.f /
len(s);
334 ccl_private ManifoldVertex &v_prev = vertices[vi - 1];
335 dH_du = (v_prev.dp_du - wi *
dot(wi, v_prev.dp_du)) * ili;
336 dH_dv = (v_prev.dp_dv - wi *
dot(wi, v_prev.dp_dv)) * ili;
337 dH_du -=
H *
dot(dH_du,
H);
338 dH_dv -=
H *
dot(dH_dv,
H);
346 if (vi == vertex_count - 1 && light_fixed_direction) {
347 dH_du = ili * (-
v.dp_du + wi *
dot(wi,
v.dp_du));
348 dH_dv = ili * (-
v.dp_dv + wi *
dot(wi,
v.dp_dv));
351 dH_du = -
v.dp_du * (ili + ilo) + wi * (
dot(wi,
v.dp_du) * ili) +
352 wo * (
dot(wo,
v.dp_du) * ilo);
353 dH_dv = -
v.dp_dv * (ili + ilo) + wi * (
dot(wi,
v.dp_dv) * ili) +
354 wo * (
dot(wo,
v.dp_dv) * ilo);
356 dH_du -=
H *
dot(dH_du,
H);
357 dH_dv -=
H *
dot(dH_dv,
H);
361 float3 ds_du = -inv_len_s * (
dot(
v.dp_du,
v.dn_du) *
v.n + dp_du_dot_n *
v.dn_du);
362 float3 ds_dv = -inv_len_s * (
dot(
v.dp_du,
v.dn_dv) *
v.n + dp_du_dot_n *
v.dn_dv);
363 ds_du -= s *
dot(s, ds_du);
364 ds_dv -= s *
dot(s, ds_dv);
374 if (vi < vertex_count - 1) {
375 ccl_private ManifoldVertex &v_next = vertices[vi + 1];
376 dH_du = (v_next.dp_du - wo *
dot(wo, v_next.dp_du)) * ilo;
377 dH_dv = (v_next.dp_dv - wo *
dot(wo, v_next.dp_dv)) * ilo;
378 dH_du -=
H *
dot(dH_du,
H);
379 dH_dv -=
H *
dot(dH_dv,
H);
402 float4 Li[MNEE_MAX_CAUSTIC_CASTERS];
403 float2 C[MNEE_MAX_CAUSTIC_CASTERS];
406 float4 Lk = vertices[0].b;
407 if (mat22_inverse(Lk, Li[0]) == 0.f)
410 C[0] = vertices[0].constraint;
412 for (
int k = 1; k < vertex_count; k++) {
413 float4 A = mat22_mult(vertices[k].
a, Li[k - 1]);
415 Lk = vertices[k].b - mat22_mult(
A, vertices[k - 1].
c);
416 if (mat22_inverse(Lk, Li[k]) == 0.f)
419 C[k] = vertices[k].constraint - mat22_mult(
A,
C[k - 1]);
422 dx[vertex_count - 1] = mat22_mult(Li[vertex_count - 1],
C[vertex_count - 1]);
423 for (
int k = vertex_count - 2; k > -1; k--)
424 dx[k] = mat22_mult(Li[k],
C[k] - mat22_mult(vertices[k].
c, dx[k + 1]));
437 float2 dx[MNEE_MAX_CAUSTIC_CASTERS];
438 ManifoldVertex tentative[MNEE_MAX_CAUSTIC_CASTERS];
445 projection_ray.
tmin = 0.0f;
446 projection_ray.
time = sd->time;
449 const bool light_fixed_direction = (ls->t == FLT_MAX);
456 bool reduce_stepsize =
false;
457 bool resolve_constraint =
true;
458 for (
int iteration = 0; iteration < MNEE_MAX_ITERATIONS; iteration++) {
459 if (resolve_constraint) {
461 if (!mnee_compute_constraint_derivatives(
462 vertex_count, vertices, sd->P, light_fixed_direction,
light_sample))
466 float constraint_norm = 0.f;
467 for (
int vi = 0; vi < vertex_count; vi++)
468 constraint_norm =
fmaxf(constraint_norm,
len(vertices[vi].constraint));
471 if (constraint_norm < MNEE_SOLVER_THRESHOLD)
475 if (!mnee_solve_matrix_h_to_x(vertex_count, vertices, dx))
480 for (
int vi = 0; vi < vertex_count; vi++) {
488 const float3 wo = tentative_p - sd->P;
489 if (
dot(sd->Ng, wo) <= 0.f) {
491 tentative_p =
mv.p +
beta * (dx[vi].
x *
mv.dp_du + dx[vi].
y *
mv.dp_dv);
500 projection_ray.
self.
prim = sd->prim;
501 projection_ray.
P = sd->P;
504 ccl_private const ManifoldVertex &pv = vertices[vi - 1];
507 projection_ray.
P = pv.p;
510 projection_ray.
tmax *= MNEE_PROJECTION_DISTANCE_MULTIPLIER;
512 bool projection_success =
false;
513 for (
int isect_count = 0; isect_count < MNEE_MAX_INTERSECTION_COUNT; isect_count++) {
522 if (hit_object ==
mv.object) {
523 projection_success =
true;
531 if (!projection_success) {
532 reduce_stepsize =
true;
543 mnee_setup_manifold_vertex(
544 kg, &tv,
mv.bsdf,
mv.eta,
mv.n_offset, &projection_ray, &projection_isect, sd_vtx);
549 if (
distance < MNEE_MIN_PROGRESS_DISTANCE)
554 if (!reduce_stepsize) {
555 for (
int vi = 0; vi < vertex_count; vi++) {
559 const float3 wi = (vi == 0 ? sd->P : tentative[vi - 1].p) - tv.p;
561 const float3 wo = (vi == vertex_count - 1) ? light_fixed_direction ? ls->D : ls->P - tv.p :
562 tentative[vi + 1].p - tv.p;
564 if (
dot(tv.n, wi) *
dot(tv.n, wo) >= 0.f) {
565 reduce_stepsize =
true;
571 if (reduce_stepsize) {
573 reduce_stepsize =
false;
574 resolve_constraint =
false;
578 if (
beta < MNEE_MINIMUM_STEP_SIZE)
585 for (
int vi = 0; vi < vertex_count; vi++)
586 vertices[vi] = tentative[vi];
589 resolve_constraint =
true;
598 mnee_sample_bsdf_dh(
ClosureType type,
float alpha_x,
float alpha_y,
float sample_u,
float sample_v)
601 float cos_phi, sin_phi;
603 if (alpha_x == alpha_y) {
604 float phi = sample_v *
M_2PI_F;
606 alpha2 = alpha_x * alpha_x;
613 float alpha_x2 = alpha_x * alpha_x;
614 float alpha_y2 = alpha_y * alpha_y;
615 alpha2 = 1.f / (cos_phi * cos_phi / alpha_x2 + sin_phi * sin_phi / alpha_y2);
619 float tan2_theta = alpha2;
621 tan2_theta *= -
logf(1.0f - sample_u);
624 tan2_theta *= sample_u / (1.0f - sample_u);
626 float cos2_theta = 1.0f / (1.0f + tan2_theta);
627 float sin_theta =
safe_sqrtf(1.0f - cos2_theta);
628 return make_float2(cos_phi * sin_theta, sin_phi * sin_theta);
643 float cosNO =
dot(bsdf->N, wi);
644 float cosNI =
dot(bsdf->N, wo);
647 float cosHO =
dot(Ht, wi);
649 float alpha2 = bsdf->alpha_x * bsdf->alpha_y;
650 float cosThetaM =
dot(bsdf->N, Ht);
659 G = (2.f / (1.f +
safe_sqrtf(1.f + alpha2 * (1.f - cosNO * cosNO) / (cosNO * cosNO)))) *
660 (2.f / (1.f +
safe_sqrtf(1.f + alpha2 * (1.f - cosNI * cosNI) / (cosNI * cosNI))));
671 return bsdf->weight *
G *
fabsf(cosHO / (cosNO *
sqr(cosThetaM)));
684 float4 U[MNEE_MAX_CAUSTIC_CASTERS - 1];
686 float4 Lk = vertices[0].b;
687 float Lk_det = mat22_inverse(Lk, Li);
691 float det_dh_dx = Lk_det;
693 for (
int k = 1; k < vertex_count; k++) {
694 U[k - 1] = mat22_mult(Li, vertices[k - 1].
c);
696 Lk = vertices[k].b - mat22_mult(vertices[k].
a,
U[k - 1]);
697 Lk_det = mat22_inverse(Lk, Li);
707 int mi = vertex_count - 1;
708 ccl_private const ManifoldVertex &m = vertices[mi];
718 float3 wi = vertex_count == 1 ? sd->P - m.p : vertices[mi - 1].p - m.p;
719 float ili = 1.f /
len(wi);
724 if (
dot(wi, m.ng) < .0f)
730 if (ls->t == FLT_MAX) {
736 float ilh = 1.f /
len(
H);
739 float ilo = -eta * ilh;
741 float cos_theta =
dot(wo, m.n);
743 float cos_phi =
dot(wo, s);
747 float3 dH_dtheta = ilo * (cos_theta * (cos_phi * s + sin_phi *
t) - sin_theta * m.n);
748 float3 dH_dphi = ilo * sin_theta * (-sin_phi * s + cos_phi *
t);
749 dH_dtheta -=
H *
dot(dH_dtheta,
H);
750 dH_dphi -=
H *
dot(dH_dphi,
H);
755 dot(dH_dtheta, s),
dot(dH_dphi, s),
dot(dH_dtheta,
t),
dot(dH_dphi,
t));
758 dxn_dwn = 1.f /
fmaxf(MNEE_MIN_DISTANCE,
fabsf(sin_theta));
763 float ilo = 1.f /
len(wo);
768 float ilh = 1.f /
len(
H);
773 float3 dH_du = (dp_du - wo *
dot(wo, dp_du)) * ilo;
774 float3 dH_dv = (dp_dv - wo *
dot(wo, dp_dv)) * ilo;
775 dH_du -=
H *
dot(dH_du,
H);
776 dH_dv -=
H *
dot(dH_dv,
H);
787 float4 Tp = -mat22_mult(Li, dc_dlight);
788 for (
int k = vertex_count - 2; k > -1; k--)
789 Tp = -mat22_mult(
U[k], Tp);
791 *dx1_dxlight =
fabsf(mat22_determinant(Tp)) * dxn_dwn;
792 *dh_dx =
fabsf(det_dh_dx);
814 mnee_update_light_sample(kg, vertices[vertex_count - 1].p, ls);
845 if (!mnee_compute_transfer_matrix(sd, ls, vertex_count, vertices, &dx1_dxlight, &dh_dx))
849 const float dw0_dx1 =
fabsf(
dot(wo, vertices[0].n)) /
sqr(wo_len);
852 const float G =
fminf(dw0_dx1 * dx1_dxlight, 2.f);
861 probe_ray.
tmin = 0.0f;
864 probe_ray.
time = sd->time;
873 for (
int vi = 0; vi < vertex_count; vi++) {
883 if (hit_object !=
v.object ||
fabsf(probe_ray.
tmax - probe_isect.
t) > MNEE_MIN_DISTANCE)
916 shader_eval_surface<KERNEL_FEATURE_NODE_MASK_SURFACE_SHADOW>(
920 wo = (vi == vertex_count - 1) ? (ls->t == FLT_MAX ? ls->D : ls->P -
v.p) :
921 vertices[vi + 1].p -
v.p;
927 float3 bsdf_contribution = mnee_eval_bsdf_contribution(
v.bsdf, wi, wo);
962 probe_ray.
tmin = 0.0f;
963 if (ls->t == FLT_MAX) {
966 probe_ray.
tmax = ls->t;
970 probe_ray.
D = ls->P - probe_ray.
P;
975 probe_ray.
time = sd->time;
978 ManifoldVertex vertices[MNEE_MAX_CAUSTIC_CASTERS];
980 int vertex_count = 0;
981 for (
int isect_count = 0; isect_count < MNEE_MAX_INTERSECTION_COUNT; isect_count++) {
990 if (vertex_count >= MNEE_MAX_CAUSTIC_CASTERS)
1009 shader_eval_surface<KERNEL_FEATURE_NODE_MASK_SURFACE_SHADOW>(
1013 bool found_transimissive_microfacet_bsdf =
false;
1014 for (
int ci = 0; ci < sd_mnee->num_closure; ci++) {
1026 found_transimissive_microfacet_bsdf =
true;
1030 const float eta = (sd_mnee->flag &
SD_BACKFACING) ? 1.0f / microfacet_bsdf->
ior :
1031 microfacet_bsdf->ior;
1034 if (microfacet_bsdf->alpha_x > 0.f && microfacet_bsdf->alpha_y > 0.f) {
1036 float bsdf_u, bsdf_v;
1038 h = mnee_sample_bsdf_dh(
1039 bsdf->type, microfacet_bsdf->alpha_x, microfacet_bsdf->alpha_y, bsdf_u, bsdf_v);
1043 mnee_setup_manifold_vertex(kg, &
mv, bsdf, eta, h, &probe_ray, &probe_isect, sd_mnee);
1047 if (!found_transimissive_microfacet_bsdf)
1059 if (vertex_count == 0)
1085 if (mnee_newton_solver(kg, sd, sd_mnee, ls, vertex_count, vertices)) {
1087 if (!mnee_path_contribution(kg,
state, sd, sd_mnee, ls, vertex_count, vertices, throughput))
1090 return vertex_count;
MINLINE float safe_sqrtf(float a)
void map_to_sphere(float *r_u, float *r_v, float x, float y, float z)
_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
_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 t
ccl_device_inline void bsdf_eval_mul(ccl_private BsdfEval *eval, float value)
ATTR_WARN_UNUSED_RESULT const BMVert * v
ccl_device_inline float bsdf_beckmann_G1(float alpha, float cos_n)
ccl_device float spot_light_attenuation(float3 dir, float spot_angle, float spot_smooth, float3 N)
ccl_device float light_spread_attenuation(const float3 D, const float3 lightNg, const float tan_spread, const float normalize_spread)
#define ccl_device_forceinline
#define ccl_device_inline
#define CCL_NAMESPACE_END
ccl_device_forceinline int intersection_get_object_flags(KernelGlobals kg, ccl_private const Intersection *ccl_restrict isect)
ccl_device_forceinline float intersection_t_offset(const float t)
CCL_NAMESPACE_BEGIN ccl_device_noinline_cpu float3 light_sample_shader_eval(KernelGlobals kg, IntegratorState state, ccl_private ShaderData *ccl_restrict emission_sd, ccl_private LightSample *ccl_restrict ls, float time)
const KernelGlobalsCPU *ccl_restrict KernelGlobals
#define kernel_data_fetch(name, index)
ccl_device_forceinline float differential_make_compact(const differential3 D)
ccl_device_forceinline float differential_zero_compact()
ccl_device_intersect bool scene_intersect(KernelGlobals kg, ccl_private const Ray *ray, const uint visibility, ccl_private Intersection *isect)
ccl_device_inline Transform object_get_transform(KernelGlobals kg, ccl_private const ShaderData *sd)
#define object_normal_transform_auto
#define object_position_transform_auto
ccl_device float shader_bsdf_eval(KernelGlobals kg, ccl_private ShaderData *sd, const float3 omega_in, const bool is_transmission, ccl_private BsdfEval *bsdf_eval, const uint light_shader_flags)
ccl_device_inline bool light_sample(KernelGlobals kg, const int lamp, const float randu, const float randv, const float3 P, const uint32_t path_flag, ccl_private LightSample *ls)
@ CLOSURE_BSDF_MICROFACET_GGX_REFRACTION_ID
@ CLOSURE_BSDF_MICROFACET_BECKMANN_REFRACTION_ID
@ CLOSURE_BSDF_SHARP_GLASS_ID
@ CLOSURE_BSDF_REFRACTION_ID
@ CLOSURE_BSDF_MICROFACET_MULTI_GGX_GLASS_ID
@ CLOSURE_BSDF_MICROFACET_MULTI_GGX_GLASS_FRESNEL_ID
@ SD_OBJECT_TRANSFORM_APPLIED
@ SD_OBJECT_NEGATIVE_SCALE_APPLIED
@ SD_OBJECT_CAUSTICS_CASTER
ccl_device void fast_sincosf(float x, ccl_private float *sine, ccl_private float *cosine)
ccl_device_inline float2 zero_float2()
ccl_device_inline float2 normalize_len(const float2 &a, float *t)
ccl_device_inline float4 zero_float4()
ccl_device_inline void motion_triangle_vertices_and_normals(KernelGlobals kg, int object, int prim, float time, float3 verts[3], float3 normals[3])
CCL_NAMESPACE_BEGIN ccl_device_inline float3 motion_triangle_point_from_uv(KernelGlobals kg, ccl_private ShaderData *sd, const int isect_object, const int isect_prim, const float u, const float v, float3 verts[3])
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 distance(const T &a, const T &b)
vec_base< T, Size > normalize(const vec_base< T, Size > &v)
static const pxr::TfToken b("b", pxr::TfToken::Immortal)
MutableSpan< float3 > normals
ccl_device_inline void path_state_rng_2D(KernelGlobals kg, ccl_private const RNGState *rng_state, int dimension, ccl_private float *fx, ccl_private float *fy)
ccl_device_inline void shader_setup_from_sample(KernelGlobals kg, ccl_private ShaderData *ccl_restrict sd, const float3 P, const float3 Ng, const float3 I, int shader, int object, int prim, float u, float v, float t, float time, bool object_space, int lamp)
CCL_NAMESPACE_BEGIN ccl_device_inline void shader_setup_from_ray(KernelGlobals kg, ccl_private ShaderData *ccl_restrict sd, ccl_private const Ray *ccl_restrict ray, ccl_private const Intersection *ccl_restrict isect)
IntegratorStateCPU *ccl_restrict IntegratorState
#define INTEGRATOR_STATE_WRITE(state, nested_struct, member)
#define INTEGRATOR_STATE(state, nested_struct, member)
ccl_device_inline void triangle_vertices_and_normals(KernelGlobals kg, int prim, float3 P[3], float3 N[3])
ccl_device_inline float sqr(float a)
ccl_device_inline float beta(float x, float y)
ccl_device_inline void make_orthonormals(const float3 N, ccl_private float3 *a, ccl_private float3 *b)