@@ -313,9 +313,7 @@ NBL_CONCEPT_BEGIN(2)
313313NBL_CONCEPT_END (
314314 ((NBL_CONCEPT_REQ_TYPE)(T::scalar_type))
315315 ((NBL_CONCEPT_REQ_TYPE)(T::vector_type))
316- ((NBL_CONCEPT_REQ_TYPE)(T::eta_type))
317316 ((NBL_CONCEPT_REQ_EXPR_RET_TYPE)((fresnel (cosTheta)), ::nbl::hlsl::is_same_v, typename T::vector_type))
318- ((NBL_CONCEPT_REQ_EXPR_RET_TYPE)((fresnel.getOrientedEtaRcps ()), ::nbl::hlsl::is_same_v, OrientedEtaRcps<typename T::eta_type>))
319317);
320318#undef cosTheta
321319#undef fresnel
@@ -331,7 +329,9 @@ NBL_CONCEPT_BEGIN(2)
331329#define cosTheta NBL_CONCEPT_PARAM_T NBL_CONCEPT_PARAM_1
332330NBL_CONCEPT_END (
333331 ((NBL_CONCEPT_REQ_TYPE_ALIAS_CONCEPT)(Fresnel, T))
332+ ((NBL_CONCEPT_REQ_TYPE)(T::eta_type))
334333 ((NBL_CONCEPT_REQ_EXPR_RET_TYPE)((fresnel.getRefractionOrientedEta ()), ::nbl::hlsl::is_same_v, typename T::scalar_type))
334+ ((NBL_CONCEPT_REQ_EXPR_RET_TYPE)((fresnel.getRefractionOrientedEtaRcps ()), ::nbl::hlsl::is_same_v, OrientedEtaRcps<typename T::eta_type>))
335335 ((NBL_CONCEPT_REQ_EXPR_RET_TYPE)((fresnel.getReorientedFresnel (cosTheta)), ::nbl::hlsl::is_same_v, T))
336336);
337337#undef cosTheta
@@ -362,7 +362,7 @@ struct Schlick
362362 return F0 + (1.0 - F0) * x*x*x*x*x;
363363 }
364364
365- OrientedEtaRcps<eta_type> getOrientedEtaRcps () NBL_CONST_MEMBER_FUNC
365+ OrientedEtaRcps<eta_type> getRefractionOrientedEtaRcps () NBL_CONST_MEMBER_FUNC
366366 {
367367 const eta_type sqrtF0 = hlsl::sqrt (F0);
368368 OrientedEtaRcps<eta_type> rcpEta;
@@ -424,13 +424,13 @@ struct Conductor
424424 return (rs2 + rp2) * hlsl::promote<T>(0.5 );
425425 }
426426
427- OrientedEtaRcps<eta_type> getOrientedEtaRcps () NBL_CONST_MEMBER_FUNC
428- {
429- OrientedEtaRcps<eta_type> rcpEta;
430- rcpEta.value = hlsl::promote<eta_type>(1.0 ) / eta;
431- rcpEta.value2 = rcpEta.value * rcpEta.value;
432- return rcpEta;
433- }
427+ // OrientedEtaRcps<eta_type> getRefractionOrientedEtaRcps () NBL_CONST_MEMBER_FUNC
428+ // {
429+ // OrientedEtaRcps<eta_type> rcpEta;
430+ // rcpEta.value = hlsl::promote<eta_type>(1.0) / eta;
431+ // rcpEta.value2 = rcpEta.value * rcpEta.value;
432+ // return rcpEta;
433+ // }
434434
435435 T eta;
436436 T etak2;
@@ -484,7 +484,7 @@ struct Dielectric
484484 // default to monochrome, but it is possible to have RGB fresnel without dispersion fixing the refraction Eta
485485 // to be something else than the etas used to compute RGB reflectance or some sort of interpolation of them
486486 scalar_type getRefractionOrientedEta () NBL_CONST_MEMBER_FUNC { return orientedEta.value[0 ]; }
487- OrientedEtaRcps<T> getOrientedEtaRcps () NBL_CONST_MEMBER_FUNC { return orientedEta.getReciprocals (); }
487+ OrientedEtaRcps<eta_type> getRefractionOrientedEtaRcps () NBL_CONST_MEMBER_FUNC { return orientedEta.getReciprocals (); }
488488
489489 Dielectric<T> getReorientedFresnel (const scalar_type NdotI) NBL_CONST_MEMBER_FUNC
490490 {
@@ -548,8 +548,6 @@ struct iridescent_helper
548548 static T __call (const vector_type _D, const vector_type ior1, const vector_type ior2, const vector_type ior3, const vector_type iork3,
549549 const vector_type eta12, const vector_type eta23, const vector_type etak23, const scalar_type clampedCosTheta)
550550 {
551- const vector_type wavelengths = vector_type (Colorspace::wavelength_R, Colorspace::wavelength_G, Colorspace::wavelength_B);
552-
553551 const scalar_type cosTheta_1 = clampedCosTheta;
554552 vector_type R12p, R23p, R12s, R23s;
555553 vector_type cosTheta_2;
@@ -589,7 +587,6 @@ struct iridescent_helper
589587
590588 // Optical Path Difference
591589 const vector_type D = _D * cosTheta_2;
592- const vector_type Dphi = hlsl::promote<vector_type>(2.0 * numbers::pi<scalar_type>) * D / wavelengths;
593590
594591 vector_type phi21p, phi21s, phi23p, phi23s, r123s, r123p, Rs;
595592 vector_type I = hlsl::promote<vector_type>(0.0 );
@@ -635,7 +632,7 @@ struct iridescent_helper
635632 I += Cm*Sm;
636633 }
637634
638- return hlsl::max (colorspace::scRGB ::FromXYZ (I) * hlsl::promote<vector_type>(0.5 ), hlsl::promote<vector_type>(0.0 ));
635+ return hlsl::max (Colorspace ::FromXYZ (I) * hlsl::promote<vector_type>(0.5 ), hlsl::promote<vector_type>(0.0 ));
639636 }
640637};
641638
@@ -652,6 +649,7 @@ struct iridescent_base
652649 vector_type iork3;
653650 vector_type eta12; // outside (usually air 1.0) -> thin-film IOR
654651 vector_type eta23; // thin-film -> base material IOR
652+ vector_type eta13;
655653};
656654}
657655
@@ -688,6 +686,7 @@ struct Iridescent<T, false, Colorspace NBL_PARTIAL_REQ_BOT(concepts::FloatingPoi
688686 retval.eta12 = params.ior2/params.ior1;
689687 retval.eta23 = params.ior3/params.ior2;
690688 retval.etak23 = params.iork3/params.ior2;
689+ retval.eta13 = params.ior3/params.ior1;
691690 return retval;
692691 }
693692
@@ -697,13 +696,13 @@ struct Iridescent<T, false, Colorspace NBL_PARTIAL_REQ_BOT(concepts::FloatingPoi
697696 base_type::eta12, base_type::eta23, getEtak23 (), clampedCosTheta);
698697 }
699698
700- OrientedEtaRcps<eta_type> getOrientedEtaRcps () NBL_CONST_MEMBER_FUNC
701- {
702- OrientedEtaRcps<eta_type> rcpEta;
703- rcpEta.value = hlsl::promote<eta_type>(1.0 ) / base_type::eta23 ;
704- rcpEta.value2 = rcpEta.value * rcpEta.value;
705- return rcpEta;
706- }
699+ // OrientedEtaRcps<eta_type> getRefractionOrientedEtaRcps () NBL_CONST_MEMBER_FUNC
700+ // {
701+ // OrientedEtaRcps<eta_type> rcpEta;
702+ // rcpEta.value = hlsl::promote<eta_type>(1.0) / base_type::eta13 ;
703+ // rcpEta.value2 = rcpEta.value * rcpEta.value;
704+ // return rcpEta;
705+ // }
707706
708707 vector_type getEtak23 () NBL_CONST_MEMBER_FUNC
709708 {
@@ -743,6 +742,7 @@ struct Iridescent<T, true, Colorspace NBL_PARTIAL_REQ_BOT(concepts::FloatingPoin
743742 retval.ior3 = params.ior3;
744743 retval.eta12 = params.ior2/params.ior1;
745744 retval.eta23 = params.ior3/params.ior2;
745+ retval.eta13 = params.ior3/params.ior1;
746746 return retval;
747747 }
748748
@@ -752,11 +752,11 @@ struct Iridescent<T, true, Colorspace NBL_PARTIAL_REQ_BOT(concepts::FloatingPoin
752752 base_type::eta12, base_type::eta23, getEtak23 (), clampedCosTheta);
753753 }
754754
755- scalar_type getRefractionOrientedEta () NBL_CONST_MEMBER_FUNC { return base_type::ior3[ 0 ] / base_type::ior1 [0 ]; }
756- OrientedEtaRcps<eta_type> getOrientedEtaRcps () NBL_CONST_MEMBER_FUNC
755+ scalar_type getRefractionOrientedEta () NBL_CONST_MEMBER_FUNC { return base_type::eta13 [0 ]; }
756+ OrientedEtaRcps<eta_type> getRefractionOrientedEtaRcps () NBL_CONST_MEMBER_FUNC
757757 {
758758 OrientedEtaRcps<eta_type> rcpEta;
759- rcpEta.value = hlsl::promote<eta_type>(base_type::ior1[ 0 ] / base_type::ior3 [0 ]);
759+ rcpEta.value = hlsl::promote<eta_type>(1.0 ) / hlsl::promote<eta_type>( base_type::eta13 [0 ]);
760760 rcpEta.value2 = rcpEta.value * rcpEta.value;
761761 return rcpEta;
762762 }
@@ -771,6 +771,7 @@ struct Iridescent<T, true, Colorspace NBL_PARTIAL_REQ_BOT(concepts::FloatingPoin
771771 orientedFresnel.ior3 = hlsl::mix (base_type::ior3, base_type::ior1, flip);
772772 orientedFresnel.eta12 = hlsl::mix (base_type::eta12, hlsl::promote<vector_type>(1.0 )/base_type::eta23, flip);
773773 orientedFresnel.eta23 = hlsl::mix (base_type::eta23, hlsl::promote<vector_type>(1.0 )/base_type::eta12, flip);
774+ orientedFresnel.eta13 = hlsl::mix (base_type::eta13, hlsl::promote<vector_type>(1.0 )/base_type::eta13, flip);
774775 return orientedFresnel;
775776 }
776777
0 commit comments