38 #include <cugar/linalg/vector.h> 40 #include <cugar/bsdf/lambert_trans.h> 42 #include <cugar/bsdf/ggx_smith.h> 44 #include <cugar/bsdf/refraction.h> 45 #include <renderer_view.h> 46 #include <mis_utils.h> 48 #define DIFFUSE_ONLY 0 49 #define SPECULAR_ONLY 0 50 #define SUPPRESS_SPECULAR 0 51 #define SUPPRESS_DIFFUSE 0 53 #define USE_EFFICIENT_SAMPLER_WITH_APPROXIMATE_PDFS 1 85 kRadianceTransport = 0,
86 kParticleTransport = 1
129 kDiffuseReflectionIndex = 0u,
130 kDiffuseTransmissionIndex = 1u,
131 kGlossyReflectionIndex = 2u,
132 kGlossyTransmissionIndex = 3u,
133 kClearcoatReflectionIndex = 4u,
143 kDiffuseReflection = 0x1u,
144 kDiffuseTransmission = 0x2u,
145 kGlossyReflection = 0x4u,
146 kGlossyTransmission = 0x8u,
147 kClearcoatReflection = 0x10u,
152 kReflectionMask = 0x5u,
153 kTransmissionMask = 0xAu,
154 kAllComponents = 0xFFu
161 #elif defined(USE_GGX_SMITH) 177 if (comp == kDiffuseReflection)
return 0;
178 if (comp == kDiffuseTransmission)
return 1;
179 if (comp == kGlossyReflection)
return 2;
180 if (comp == kGlossyTransmission)
return 3;
195 m_diffuse(0.0
f), m_diffuse_trans(0.0
f), m_glossy(0.0
f, NULL, NULL, NULL, 0u), m_glossy_trans(1.0
f,true), m_fresnel(0.0
f) {}
197 m_diffuse(0.0
f), m_diffuse_trans(0.0
f), m_glossy(1.0
f), m_glossy_trans(1.0
f,
true), m_fresnel(0.0
f) {}
204 m_diffuse(bsdf.m_diffuse),
205 m_diffuse_trans(bsdf.m_diffuse_trans),
206 m_glossy(bsdf.m_glossy),
207 m_glossy_trans(bsdf.m_glossy_trans),
208 m_fresnel(bsdf.m_fresnel),
209 m_reflectivity(bsdf.m_reflectivity),
211 m_opacity(bsdf.m_opacity),
212 m_clearcoat_ior(bsdf.m_clearcoat_ior),
213 m_glossy_reflectance(bsdf.m_glossy_reflectance),
214 m_transport(bsdf.m_transport) {}
223 const float mollification_factor = 1.0
f,
224 const float mollification_bias = 0.0
f,
225 const float min_roughness = 0.0
f) :
229 m_glossy(
cugar::max(material.roughness * mollification_factor + mollification_bias, min_roughness), renderer.ltc_M, renderer.ltc_Minv, renderer.ltc_A, renderer.ltc_size),
231 m_glossy(
cugar::max(material.roughness * mollification_factor + mollification_bias, min_roughness)),
232 m_glossy_trans(material.roughness , true, material.index_of_refraction, 1.0
f),
234 m_fresnel(
cugar::Vector3f(material.specular.x, material.specular.y, material.specular.z) / M_PIf),
235 m_reflectivity(
cugar::Vector3f(material.reflectivity.x, material.reflectivity.y, material.reflectivity.z)),
236 m_ior(material.index_of_refraction),
237 m_opacity(material.opacity),
238 m_glossy_reflectance(renderer.glossy_reflectance),
239 m_transport(transport)
241 const float R0 = cugar::min( cugar::max_comp( m_reflectivity ), 0.95
f );
242 m_clearcoat_ior = (1 + sqrtf(R0)) / (1 - sqrtf(R0));
253 const float roughness,
255 const float opacity = 1.0
f,
256 const float ior = 1.0
f) :
257 m_diffuse(diffuse / M_PIf),
258 m_diffuse_trans(diffuse_trans / M_PIf),
260 m_glossy(roughness, renderer.ltc_M, renderer.ltc_Minv, renderer.ltc_A, renderer.ltc_size),
263 m_glossy_trans(roughness, true, ior, 1.0
f),
265 m_fresnel(specular / M_PIf),
268 m_glossy_reflectance(renderer.glossy_reflectance),
269 m_transport(transport)
271 const float R0 = cugar::min( cugar::max_comp( m_reflectivity ), 0.95
f );
272 m_clearcoat_ior = (1 + sqrtf(R0)) / (1 - sqrtf(R0));
278 const diffuse_trans_component&
diffuse_trans()
const {
return m_diffuse_trans; }
283 const diffuse_component&
diffuse()
const {
return m_diffuse; }
288 const glossy_component&
glossy()
const {
return m_glossy; }
293 const glossy_component&
glossy_trans()
const {
return m_glossy_trans; }
298 float get_eta(
const float NoV)
const {
return NoV > 0.0f ? 1.0f / m_ior : m_ior; }
303 float get_inv_eta(
const float NoV)
const {
return NoV > 0.0f ? m_ior : 1.0f / m_ior; }
311 FERMAT_FORCEINLINE FERMAT_HOST_DEVICE
327 ((components & kDiffuseReflection) ? m_diffuse.
f(geometry, w_i, w_o) * w[kDiffuseReflectionIndex] * factor : 0.0f) +
328 ((components & kDiffuseTransmission) ? m_diffuse_trans.
f(geometry, w_i, w_o) * w[kDiffuseTransmissionIndex] * factor : 0.0f) +
329 ((components & kGlossyReflection) ? m_glossy.
f(geometry, w_i, w_o) * w[kGlossyReflectionIndex] * factor : 0.0f) +
330 ((components & kGlossyTransmission) ? m_glossy_trans.
f(geometry, w_i, w_o) * w[kGlossyTransmissionIndex] * factor : 0.0f);
335 FERMAT_FORCEINLINE FERMAT_HOST_DEVICE
350 f_d = m_diffuse.
f(geometry, w_i, w_o);
351 f_g = m_diffuse_trans.
f(geometry, w_i, w_o);
352 f_dt = m_glossy.
f(geometry, w_i, w_o);
353 f_gt = m_glossy_trans.
f(geometry, w_i, w_o);
357 f[kDiffuseReflectionIndex] = f_d * w[kDiffuseReflectionIndex] * factor;
358 f[kDiffuseTransmissionIndex] = f_dt * w[kDiffuseTransmissionIndex] * factor;
359 f[kGlossyReflectionIndex] = f_g * w[kGlossyReflectionIndex] * factor;
360 f[kGlossyTransmissionIndex] = f_gt * w[kGlossyTransmissionIndex] * factor;
365 FERMAT_FORCEINLINE FERMAT_HOST_DEVICE
373 bool RR =
true)
const 382 float coat_reflection_prob = cugar::average(Fc_1);
383 float coat_transmission_prob = 1.0f - coat_reflection_prob;
387 float p_d, p_g, p_dt, p_gt;
389 m_diffuse.
f_and_p(geometry, w_i, w_o, f_d, p_d, measure);
390 m_diffuse_trans.
f_and_p(geometry, w_i, w_o, f_dt, p_dt, measure);
391 m_glossy.
f_and_p(geometry, w_i, w_o, f_g, p_g, measure);
392 m_glossy_trans.
f_and_p(geometry, w_i, w_o, f_gt, p_gt, measure);
401 p[kDiffuseReflectionIndex] = p_d * w_p[kDiffuseReflectionIndex];
402 p[kDiffuseTransmissionIndex] = p_dt * w_p[kDiffuseTransmissionIndex];
403 p[kGlossyReflectionIndex] = p_g * w_p[kGlossyReflectionIndex];
404 p[kGlossyTransmissionIndex] = p_gt * w_p[kGlossyTransmissionIndex];
408 f[kDiffuseReflectionIndex] = f_d * w[kDiffuseReflectionIndex] * factor;
409 f[kDiffuseTransmissionIndex] = f_dt * w[kDiffuseTransmissionIndex] * factor;
410 f[kGlossyReflectionIndex] = f_g * w[kGlossyReflectionIndex] * factor;
411 f[kGlossyTransmissionIndex] = f_gt * w[kGlossyTransmissionIndex] * factor;
416 FERMAT_FORCEINLINE FERMAT_HOST_DEVICE
424 const bool RR =
true,
434 float coat_reflection_prob = cugar::average(Fc_1);
435 float coat_transmission_prob = 1.0f - coat_reflection_prob;
439 float p_d(0.0f), p_g(0.0f), p_dt(0.0f), p_gt(0.0f);
441 if (components & kDiffuseReflection) m_diffuse.
f_and_p(geometry, w_i, w_o, f_d, p_d, measure);
442 if (components & kDiffuseTransmission) m_diffuse_trans.
f_and_p(geometry, w_i, w_o, f_dt, p_dt, measure);
443 if (components & kGlossyReflection) m_glossy.
f_and_p(geometry, w_i, w_o, f_g, p_g, measure);
444 if (components & kGlossyTransmission) m_glossy_trans.
f_and_p(geometry, w_i, w_o, f_gt, p_gt, measure);
453 p = p_d * w_p[kDiffuseReflectionIndex] +
454 p_dt * w_p[kDiffuseTransmissionIndex] +
455 p_g * w_p[kGlossyReflectionIndex] +
456 p_gt * w_p[kGlossyTransmissionIndex];
460 f = f_d * w[kDiffuseReflectionIndex] * factor +
461 f_dt * w[kDiffuseTransmissionIndex] * factor +
462 f_g * w[kGlossyReflectionIndex] * factor +
463 f_gt * w[kGlossyTransmissionIndex] * factor;
473 FERMAT_FORCEINLINE FERMAT_HOST_DEVICE
479 const bool RR =
true,
489 if (!clearcoat_transmission(
503 float coat_reflection_prob = cugar::average(Fc_1);
504 float coat_transmission_prob = 1.0f - coat_reflection_prob;
513 float p_d(0.0
f), p_g(0.0
f), p_dt(0.0
f), p_gt(0.0
f);
515 if (components & kDiffuseReflection) p_d = m_diffuse.
p(geometry, w_i, w_o, measure);
516 if (components & kDiffuseTransmission) p_dt = m_diffuse_trans.
p(geometry, w_i, w_o, measure);
517 if (components & kGlossyReflection) p_g = m_glossy.
p(geometry, w_i, w_o, measure);
518 if (components & kGlossyTransmission) p_gt = m_glossy_trans.
p(geometry, w_i, w_o, measure);
521 p_d * w_p[kDiffuseReflectionIndex] +
522 p_dt * w_p[kDiffuseTransmissionIndex] +
523 p_g * w_p[kGlossyReflectionIndex] +
524 p_gt * w_p[kGlossyTransmissionIndex];
529 FERMAT_FORCEINLINE FERMAT_HOST_DEVICE
533 float& diffuse_refl_prob,
534 float& diffuse_trans_prob,
535 float& glossy_refl_prob,
536 float& glossy_trans_prob)
const 538 const float NoV_signed = cugar::dot(geometry.normal_s, V);
539 const float NoV = fabsf( NoV_signed );
551 r_coeff = glossy_reflectance( NoV_signed );
564 #if SUPPRESS_SPECULAR 571 glossy_refl_prob = cugar::max_comp( r_coeff );
572 glossy_trans_prob = (1 - m_opacity) * cugar::max_comp( t_coeff );
573 diffuse_refl_prob = m_opacity * cugar::max_comp( t_coeff * m_diffuse.color ) * M_PIf;
574 diffuse_trans_prob = m_opacity * cugar::max_comp( t_coeff * m_diffuse_trans.color ) * M_PIf;
579 FERMAT_FORCEINLINE FERMAT_HOST_DEVICE
585 sampling_weights( geometry, V, w[kDiffuseReflectionIndex], w[kDiffuseTransmissionIndex], w[kGlossyReflectionIndex], w[kGlossyTransmissionIndex] );
590 FERMAT_FORCEINLINE FERMAT_HOST_DEVICE
593 float& coat_reflection_prob,
594 float& coat_transmission_prob,
599 if ((components & kDiffuseReflection) == 0) w_p[kDiffuseReflectionIndex] = 0;
600 if ((components & kDiffuseTransmission) == 0) w_p[kDiffuseTransmission] = 0;
601 if ((components & kGlossyReflection) == 0) w_p[kGlossyReflection] = 0;
602 if ((components & kGlossyTransmission) == 0) w_p[kGlossyTransmission] = 0;
603 if ((components & kClearcoatReflection) == 0) { coat_reflection_prob = 0; coat_transmission_prob = 1; }
606 w_p[kDiffuseReflectionIndex] *= coat_transmission_prob;
607 w_p[kDiffuseTransmissionIndex] *= coat_transmission_prob;
608 w_p[kGlossyReflectionIndex] *= coat_transmission_prob;
609 w_p[kGlossyTransmissionIndex] *= coat_transmission_prob;
613 const float inv_sum = 1.0f / (
614 w_p[kDiffuseReflectionIndex] +
615 w_p[kDiffuseTransmissionIndex] +
616 w_p[kGlossyReflectionIndex] +
617 w_p[kGlossyTransmissionIndex] +
618 coat_reflection_prob);
620 w_p[kDiffuseReflectionIndex] *= inv_sum;
621 w_p[kDiffuseTransmissionIndex] *= inv_sum;
622 w_p[kGlossyReflectionIndex] *= inv_sum;
623 w_p[kGlossyTransmissionIndex] *= inv_sum;
624 coat_reflection_prob *= inv_sum;
625 coat_transmission_prob *= inv_sum;
631 FERMAT_FORCEINLINE FERMAT_HOST_DEVICE
658 #if SUPPRESS_SPECULAR 668 FERMAT_FORCEINLINE FERMAT_HOST_DEVICE
677 float inv_eta = 0.0f;
684 eta = dot(N, V) > 0.0f ? 1.0f / m_ior : m_ior;
685 inv_eta = dot(N, V) > 0.0f ? m_ior : 1.0f / m_ior;
700 FERMAT_FORCEINLINE FERMAT_HOST_DEVICE
713 glossy_refl_coeff = w[kGlossyReflectionIndex];
714 glossy_trans_coeff = w[kGlossyTransmissionIndex];
715 diffuse_refl_coeff = w[kDiffuseReflectionIndex];
716 diffuse_trans_coeff = w[kDiffuseTransmissionIndex];
721 FERMAT_FORCEINLINE FERMAT_HOST_DEVICE
735 const float diffuse_weight =
736 (1.0f - glossy_reflectance( dot(geometry.normal_s,V) )) *
737 (1.0
f - glossy_reflectance( dot(geometry.normal_s,L) ));
739 w[kGlossyReflectionIndex] = r_coeff;
740 w[kGlossyTransmissionIndex] = t_coeff * (1 - m_opacity);
741 w[kDiffuseReflectionIndex] = t_coeff * m_opacity * diffuse_weight;
742 w[kDiffuseTransmissionIndex] = t_coeff * m_opacity * diffuse_weight;
747 FERMAT_FORCEINLINE FERMAT_HOST_DEVICE
763 if (!clearcoat_transmission(
773 w[kGlossyReflectionIndex] = 0.0f;
774 w[kGlossyTransmissionIndex] = 0.0f;
775 w[kDiffuseReflectionIndex] = 0.0f;
776 w[kDiffuseTransmissionIndex] = 0.0f;
788 w[kGlossyReflectionIndex] *= Tc_1 * Tc_2;
789 w[kGlossyTransmissionIndex] *= Tc_1 * Tc_2;
790 w[kDiffuseReflectionIndex] *= Tc_1 * Tc_2;
791 w[kDiffuseTransmissionIndex] *= Tc_1 * Tc_2;
796 FERMAT_FORCEINLINE FERMAT_HOST_DEVICE
824 FERMAT_HOST_DEVICE FERMAT_FORCEINLINE
834 const bool evaluate_full_bsdf =
false)
const 840 if (out_comp == kDiffuseReflection)
847 else if (out_comp == kGlossyReflection)
854 else if (out_comp == kDiffuseTransmission)
861 else if (out_comp == kGlossyTransmission)
869 if (out_comp != kAbsorption)
872 if (evaluate_full_bsdf)
874 g = this->
f(geometry, in, out, kAllComponents) / p_proj;
884 (out_comp & kGlossyReflection) ? w[kGlossyReflectionIndex] :
885 (out_comp & kGlossyTransmission) ? w[kGlossyTransmissionIndex] :
886 (out_comp & kDiffuseReflection) ? w[kDiffuseReflectionIndex] :
887 w[kDiffuseTransmissionIndex];
920 FERMAT_HOST_DEVICE FERMAT_FORCEINLINE
931 bool evaluate_full_bsdf =
false,
980 if (!clearcoat_transmission(
997 float coat_reflection_prob = cugar::average(Fc_1);
998 float coat_transmission_prob = 1.0f - coat_reflection_prob;
1004 #if USE_EFFICIENT_SAMPLER_WITH_APPROXIMATE_PDFS 1026 const float eta = V_local.z > 0.0f ? 1.0f / m_ior : m_ior;
1031 w_p[kGlossyReflectionIndex] = (w_p[kGlossyReflectionIndex] + cugar::max_comp( r_coeff ) ) * 0.5
f;
1032 w_p[kGlossyTransmissionIndex] = (w_p[kGlossyTransmissionIndex] + (1 - m_opacity) * cugar::max_comp( t_coeff )) * 0.5
f;
1033 w_p[kDiffuseReflectionIndex] = (w_p[kDiffuseReflectionIndex] + m_opacity * cugar::max_comp( t_coeff * m_diffuse.color ) * M_PIf) * 0.5
f;
1034 w_p[kDiffuseTransmissionIndex] = (w_p[kDiffuseTransmissionIndex] + m_opacity * cugar::max_comp( t_coeff * m_diffuse_trans.color ) * M_PIf) * 0.5
f;
1041 if (z[2] < w_p[kDiffuseReflectionIndex])
1046 z_norm = z[2] / w_p[kDiffuseReflectionIndex];
1047 p_comp = w_p[kDiffuseReflectionIndex];
1051 out_comp = kDiffuseReflection;
1053 else if (z[2] < w_p[kDiffuseReflectionIndex] +
1054 w_p[kGlossyReflectionIndex])
1059 z_norm = (z[2] - w_p[kDiffuseReflectionIndex]) / w_p[kGlossyReflectionIndex];
1060 p_comp = w_p[kGlossyReflectionIndex];
1062 #if !USE_EFFICIENT_SAMPLER_WITH_APPROXIMATE_PDFS 1066 component.
sample( geometry, H, w_i, w_o, g, p, p_proj );
1068 out_comp = kGlossyReflection;
1070 else if (z[2] < w_p[kDiffuseReflectionIndex] +
1071 w_p[kGlossyReflectionIndex] +
1072 w_p[kDiffuseTransmissionIndex])
1077 z_norm = (z[2] - w_p[kDiffuseReflectionIndex] - w_p[kGlossyReflectionIndex]) / w_p[kDiffuseTransmissionIndex];
1078 p_comp = w_p[kDiffuseTransmissionIndex];
1082 out_comp = kDiffuseTransmission;
1084 else if (z[2] < w_p[kDiffuseReflectionIndex] +
1085 w_p[kGlossyReflectionIndex] +
1086 w_p[kDiffuseTransmissionIndex] +
1087 w_p[kGlossyTransmissionIndex])
1092 z_norm = (z[2] - w_p[kDiffuseReflectionIndex] - w_p[kGlossyReflectionIndex] - w_p[kDiffuseTransmissionIndex]) / w_p[kGlossyTransmissionIndex];
1093 p_comp = w_p[kGlossyTransmissionIndex];
1095 #if !USE_EFFICIENT_SAMPLER_WITH_APPROXIMATE_PDFS 1099 component.
sample( geometry, H, w_i, w_o, g, p, p_proj );
1102 out_comp = kGlossyTransmission;
1104 else if (z[2] < w_p[kDiffuseReflectionIndex] +
1105 w_p[kGlossyReflectionIndex] +
1106 w_p[kDiffuseTransmissionIndex] +
1107 w_p[kGlossyTransmissionIndex] +
1108 coat_reflection_prob)
1111 z_norm = (z[2] - w_p[kDiffuseReflectionIndex] - w_p[kGlossyReflectionIndex] - w_p[kDiffuseTransmissionIndex] - w_p[kGlossyTransmissionIndex]) / coat_reflection_prob;
1112 p_comp = coat_reflection_prob;
1115 out = 2 * cos_theta_i * H_c - in;
1117 p_proj = cugar::float_infinity();
1118 p = cugar::float_infinity();
1120 out_comp = kClearcoatReflection;
1124 out_comp = kAbsorption;
1127 if (out_comp != kAbsorption &&
1128 out_comp != kClearcoatReflection)
1144 if (out_comp != kAbsorption)
1147 if (out_comp != kClearcoatReflection)
1149 if (evaluate_full_bsdf)
1151 float p_d = (components & kDiffuseReflection) ?
diffuse().
p(geometry, in, out, cugar::kProjectedSolidAngle) : 0.0f;
1152 float p_dt = (components & kDiffuseTransmission) ?
diffuse_trans().
p(geometry, in, out, cugar::kProjectedSolidAngle) : 0.0f;
1153 float p_g = (components & kGlossyReflection) ?
glossy().
p(geometry, in, out, cugar::kProjectedSolidAngle) : 0.0f;
1154 float p_gt = (components & kGlossyTransmission) ?
glossy_trans().
p(geometry, in, out, cugar::kProjectedSolidAngle) : 0.0f;
1157 p_d * w_p[kDiffuseReflectionIndex] * coat_transmission_prob +
1158 p_dt * w_p[kDiffuseTransmissionIndex] * coat_transmission_prob +
1159 p_g * w_p[kGlossyReflectionIndex] * coat_transmission_prob +
1160 p_gt * w_p[kGlossyTransmissionIndex] * coat_transmission_prob;
1162 p = p_proj * fabsf( dot(out, geometry.normal_s) );
1163 g = this->
f(geometry, in, out, components) / p_proj;
1173 (out_comp & kGlossyReflection) ? w[kGlossyReflectionIndex] :
1174 (out_comp & kGlossyTransmission) ? w[kGlossyTransmissionIndex] :
1175 (out_comp & kDiffuseReflection) ? w[kDiffuseReflectionIndex] :
1176 w[kDiffuseTransmissionIndex];
1187 out_p_proj = p_proj;
1201 FERMAT_FORCEINLINE FERMAT_HOST_DEVICE
1202 bool clearcoat_transmission(
1211 const float R0 = cugar::min( cugar::max_comp( m_reflectivity ), 0.95
f );
1212 const float eta_c = 1.0f / m_clearcoat_ior;
1214 H = geometry.normal_s;
1215 cos_theta_i = dot(w_i, H);
1229 Fc_1 = cugar::lerp( m_reflectivity,
cugar::Vector3f(1.0
f), cugar::max(Fc_1_s - R0, 0.0
f) / (1 - R0) );
1236 FERMAT_FORCEINLINE FERMAT_HOST_DEVICE
1242 if (m_transport == kRadianceTransport && m_ior)
1245 const float NoV = dot(w_i, geometry.normal_s);
1246 const float NoL = dot(w_o, geometry.normal_s);
1247 if (NoV * NoL < 0.0
f)
1248 return cugar::sqr( NoV > 0.0
f ? m_ior : 1.0
f / m_ior );
1253 FERMAT_FORCEINLINE FERMAT_HOST_DEVICE
1254 float glossy_reflectance(
const float cos_theta)
const 1256 const uint32 S = 32;
1258 const float eta = cos_theta > 0.0f ? 1.0f / m_ior : m_ior;
1260 const uint32 cos_theta_i = cugar::min( S-1u, uint32( fabsf(cos_theta) * (S-1) ) );
1261 const uint32 base_spec_i = cugar::min( S-1u, uint32( cugar::max_comp( m_fresnel ) * (S-1) ) );
1262 const uint32 eta_i = cugar::min( S-1u, uint32( (eta / 2.0
f) * (S-1) ) );
1263 const uint32 roughness_i = cugar::min( S-1u, uint32( m_glossy.roughness * (S-1) ) );
1265 const uint32 cell_i = (eta_i*S*S*S + base_spec_i*S*S + roughness_i*S + cos_theta_i);
1267 return m_glossy_reflectance[cell_i];
1270 diffuse_component m_diffuse;
1271 diffuse_trans_component m_diffuse_trans;
1272 glossy_component m_glossy;
1273 glossy_component m_glossy_trans;
1278 float m_clearcoat_ior;
1279 const float* m_glossy_reflectance;
CUGAR_FORCEINLINE CUGAR_HOST_DEVICE float p(const DifferentialGeometry &geometry, const Vector3f V, const Vector3f L, const SphericalMeasure measure=kProjectedSolidAngle) const
Definition: lambert_trans.h:103
CUGAR_FORCEINLINE CUGAR_HOST_DEVICE void sample(const Vector3f u, const DifferentialGeometry &geometry, const Vector3f V, Vector3f &L, Vector3f &g, float &p, float &p_proj) const
Definition: lambert_trans.h:118
SphericalMeasure
Definition: differential_geometry.h:50
CUGAR_FORCEINLINE CUGAR_HOST_DEVICE Vector3f f(const DifferentialGeometry &geometry, const Vector3f V, const Vector3f L) const
Definition: ggx_smith.h:346
CUGAR_FORCEINLINE CUGAR_HOST_DEVICE Vector3f sample(const Vector3f u, const Vector3f V, float *p=NULL) const
Definition: ggx_smith.h:114
CUGAR_FORCEINLINE CUGAR_HOST_DEVICE void sample(const DifferentialGeometry &geometry, const Vector3f H, const Vector3f V, Vector3f &L, Vector3f &g, float &p, float &p_proj) const
Definition: ggx_smith.h:529
static FERMAT_HOST_DEVICE uint32 component_count()
Definition: bsdf.h:170
CUGAR_FORCEINLINE CUGAR_HOST_DEVICE GGXSmithMicrofacetDistribution distribution() const
Definition: ggx_smith.h:236
CUGAR_FORCEINLINE CUGAR_HOST_DEVICE VectorType fresnel_schlick(float cos_theta_i, const float eta, const VectorType fresnel_base)
Definition: refraction.h:105
CUGAR_FORCEINLINE CUGAR_HOST_DEVICE float p(const DifferentialGeometry &geometry, const Vector3f V, const Vector3f L, const SphericalMeasure measure=kProjectedSolidAngle) const
Definition: ggx_smith.h:484
FERMAT_HOST_DEVICE float get_eta(const float NoV) const
Definition: bsdf.h:298
FERMAT_FORCEINLINE FERMAT_HOST_DEVICE float compression_factor(const cugar::DifferentialGeometry &geometry, const cugar::Vector3f w_i, const cugar::Vector3f w_o) const
Definition: bsdf.h:1237
FERMAT_FORCEINLINE FERMAT_HOST_DEVICE void fresnel_weights(const cugar::DifferentialGeometry &geometry, const cugar::Vector3f V, const cugar::Vector3f L, cugar::Vector3f &r_coeff, cugar::Vector3f &t_coeff) const
Definition: bsdf.h:669
Definition: lambert_trans.h:51
FERMAT_HOST_DEVICE const glossy_component & glossy_trans() const
Definition: bsdf.h:293
static FERMAT_HOST_DEVICE ComponentType component_mask(const ComponentIndex comp)
Definition: bsdf.h:188
ComponentType
Definition: bsdf.h:139
Defines the Lambert BSDF.
FERMAT_HOST_DEVICE Bsdf(const TransportType transport, const RenderingContextView renderer, const MeshMaterial material, const float mollification_factor=1.0f, const float mollification_bias=0.0f, const float min_roughness=0.0f)
Definition: bsdf.h:219
Definition: MeshView.h:55
FERMAT_FORCEINLINE FERMAT_HOST_DEVICE void normalize_sampling_weights(float *w_p, float &coat_reflection_prob, float &coat_transmission_prob, const bool RR, const ComponentType components=kAllComponents) const
Definition: bsdf.h:591
TransportType
Definition: bsdf.h:83
FERMAT_HOST_DEVICE const diffuse_component & diffuse() const
Definition: bsdf.h:283
CUGAR_HOST_DEVICE Vector3f to_local(const Vector3f v) const
Definition: differential_geometry.h:70
CUGAR_FORCEINLINE CUGAR_HOST_DEVICE void sample(const Vector3f u, const DifferentialGeometry &geometry, const Vector3f V, Vector3f &L, Vector3f &g, float &p, float &p_proj) const
Definition: lambert.h:131
CUGAR_HOST_DEVICE Vector3f from_local(const Vector3f v) const
Definition: differential_geometry.h:82
FERMAT_HOST_DEVICE const diffuse_trans_component & diffuse_trans() const
Definition: bsdf.h:278
Definition: ggx_smith.h:54
FERMAT_FORCEINLINE FERMAT_HOST_DEVICE void component_weights(const cugar::DifferentialGeometry &geometry, const cugar::Vector3f w_i, const cugar::Vector3f w_o, cugar::Vector3f *w) const
Definition: bsdf.h:797
FERMAT_HOST_DEVICE FERMAT_FORCEINLINE bool sample(const cugar::DifferentialGeometry &geometry, const float z[3], const cugar::Vector3f in, ComponentType &out_comp, cugar::Vector3f &out, float &out_p, float &out_p_proj, cugar::Vector3f &out_g, bool RR=true, bool evaluate_full_bsdf=false, const ComponentType components=kAllComponents) const
Definition: bsdf.h:921
CUGAR_FORCEINLINE CUGAR_HOST_DEVICE Vector3f f(const DifferentialGeometry &geometry, const Vector3f V, const Vector3f L) const
Definition: lambert_trans.h:60
FERMAT_HOST_DEVICE Bsdf()
Definition: bsdf.h:193
ComponentIndex
Definition: bsdf.h:127
FERMAT_HOST_DEVICE Bsdf(const Bsdf &bsdf)
Definition: bsdf.h:203
CUGAR_FORCEINLINE CUGAR_HOST_DEVICE bool refract(const Vector3f w_i, const Vector3f N, const float cos_theta_i, const float eta, Vector3f *out, float *F)
Definition: refraction.h:157
float CUGAR_HOST_DEVICE sqr(const float x)
Definition: numbers.h:610
FERMAT_FORCEINLINE FERMAT_HOST_DEVICE void f_and_p(const cugar::DifferentialGeometry &geometry, const cugar::Vector3f w_i, const cugar::Vector3f w_o, cugar::Vector3f &f, float &p, const cugar::SphericalMeasure measure=cugar::kProjectedSolidAngle, const bool RR=true, const ComponentType components=kAllComponents) const
Definition: bsdf.h:417
CUGAR_FORCEINLINE CUGAR_HOST_DEVICE Vector3f microfacet(const Vector3f V, const Vector3f L, const Vector3f N, const float inv_eta)
Definition: ggx_common.h:50
Definition: differential_geometry.h:59
FERMAT_FORCEINLINE FERMAT_HOST_DEVICE void f(const cugar::DifferentialGeometry &geometry, const cugar::Vector3f w_i, const cugar::Vector3f w_o, cugar::Vector3f *f) const
Definition: bsdf.h:336
Definition: ggx_smith.h:204
FERMAT_FORCEINLINE FERMAT_HOST_DEVICE void inner_component_weights(const cugar::DifferentialGeometry &geometry, const cugar::Vector3f V, const cugar::Vector3f L, cugar::Vector3f &diffuse_refl_coeff, cugar::Vector3f &diffuse_trans_coeff, cugar::Vector3f &glossy_refl_coeff, cugar::Vector3f &glossy_trans_coeff) const
Definition: bsdf.h:701
FERMAT_FORCEINLINE FERMAT_HOST_DEVICE void f_and_p(const cugar::DifferentialGeometry &geometry, const cugar::Vector3f w_i, const cugar::Vector3f w_o, cugar::Vector3f *f, float *p, const cugar::SphericalMeasure measure=cugar::kProjectedSolidAngle, bool RR=true) const
Definition: bsdf.h:366
FERMAT_FORCEINLINE FERMAT_HOST_DEVICE void fresnel_weights(const float VoH, const float eta, cugar::Vector3f &r_coeff, cugar::Vector3f &t_coeff) const
Definition: bsdf.h:632
Define a vector_view POD type and plain_view() for std::vector.
Definition: diff.h:38
FERMAT_FORCEINLINE FERMAT_HOST_DEVICE void sampling_weights(const cugar::DifferentialGeometry &geometry, const cugar::Vector3f V, float *w) const
Definition: bsdf.h:580
CUGAR_FORCEINLINE CUGAR_HOST_DEVICE void f_and_p(const DifferentialGeometry &geometry, const Vector3f V, const Vector3f L, Vector3f &f, float &p, const SphericalMeasure measure=kProjectedSolidAngle) const
Definition: lambert_trans.h:86
CUGAR_FORCEINLINE CUGAR_HOST_DEVICE Vector3f f(const DifferentialGeometry &geometry, const Vector3f V, const Vector3f L) const
Definition: lambert.h:73
FERMAT_FORCEINLINE FERMAT_HOST_DEVICE void sampling_weights(const cugar::DifferentialGeometry &geometry, const cugar::Vector3f V, float &diffuse_refl_prob, float &diffuse_trans_prob, float &glossy_refl_prob, float &glossy_trans_prob) const
Definition: bsdf.h:530
FERMAT_FORCEINLINE FERMAT_HOST_DEVICE void component_weights(const cugar::DifferentialGeometry &geometry, const cugar::Vector3f w_i, const cugar::Vector3f w_o, cugar::Vector3f &Fc_1, cugar::Vector3f &Tc_1, cugar::Vector3f &Fc_2, cugar::Vector3f &Tc_2, cugar::Vector3f *w) const
Definition: bsdf.h:748
CUGAR_FORCEINLINE CUGAR_HOST_DEVICE void f_and_p(const DifferentialGeometry &geometry, const Vector3f V, const Vector3f L, Vector3f &f, float &p, const SphericalMeasure measure=kProjectedSolidAngle) const
Definition: lambert.h:99
static FERMAT_HOST_DEVICE uint32 component_index(const ComponentType comp)
Definition: bsdf.h:175
CUGAR_FORCEINLINE CUGAR_HOST_DEVICE uint8 comp(const uchar2 a, const char c)
Definition: numbers.h:218
FERMAT_HOST_DEVICE Bsdf(const TransportType transport, const RenderingContextView renderer, const cugar::Vector3f diffuse, const cugar::Vector3f specular, const float roughness, const cugar::Vector3f diffuse_trans, const float opacity=1.0f, const float ior=1.0f)
Definition: bsdf.h:248
FERMAT_FORCEINLINE FERMAT_HOST_DEVICE cugar::Vector3f f(const cugar::DifferentialGeometry &geometry, const cugar::Vector3f w_i, const cugar::Vector3f w_o, const ComponentType components=kAllComponents) const
Definition: bsdf.h:312
Definition: renderer_view.h:80
CUGAR_FORCEINLINE CUGAR_HOST_DEVICE void f_and_p(const DifferentialGeometry &geometry, const Vector3f V, const Vector3f L, Vector3f &f, float &p, const SphericalMeasure measure=kProjectedSolidAngle) const
Definition: ggx_smith.h:428
FERMAT_HOST_DEVICE FERMAT_FORCEINLINE bool sample_component(const cugar::DifferentialGeometry &geometry, const float z[3], const cugar::Vector3f in, const ComponentType out_comp, cugar::Vector3f &out, float &out_p, float &out_p_proj, cugar::Vector3f &out_g, const bool evaluate_full_bsdf=false) const
Definition: bsdf.h:825
CUGAR_FORCEINLINE CUGAR_HOST_DEVICE float p(const DifferentialGeometry &geometry, const Vector3f V, const Vector3f L, const SphericalMeasure measure=kProjectedSolidAngle) const
Definition: lambert.h:116
FERMAT_HOST_DEVICE const glossy_component & glossy() const
Definition: bsdf.h:288
FERMAT_FORCEINLINE FERMAT_HOST_DEVICE void inner_component_weights(const cugar::DifferentialGeometry &geometry, const cugar::Vector3f V, const cugar::Vector3f L, cugar::Vector3f *w) const
Definition: bsdf.h:722
FERMAT_HOST_DEVICE float get_inv_eta(const float NoV) const
Definition: bsdf.h:303
FERMAT_FORCEINLINE FERMAT_HOST_DEVICE float p(const cugar::DifferentialGeometry &geometry, const cugar::Vector3f w_i, const cugar::Vector3f w_o, const cugar::SphericalMeasure measure=cugar::kProjectedSolidAngle, const bool RR=true, const ComponentType components=kAllComponents) const
Definition: bsdf.h:474