Skip to content

Commit 5782a49

Browse files
committed
removed redundant weight in interaction
1 parent 4b8a06b commit 5782a49

File tree

2 files changed

+6
-15
lines changed

2 files changed

+6
-15
lines changed

include/nbl/builtin/hlsl/bxdf/base/cook_torrance_base.hlsl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -282,8 +282,8 @@ struct SCookTorrance
282282
assert(NdotV*VdotH >= scalar_type(0.0));
283283
}
284284

285-
spectral_type prefixThroughputWeights = interaction.getPrefixThroughputWeights();
286-
const scalar_type reflectance = hlsl::dot(impl::__implicit_promote<spectral_type, typename fresnel_type::vector_type>::__call(_f(hlsl::abs(VdotH))), prefixThroughputWeights);
285+
spectral_type throughputWeights = interaction.getLuminosityContributionHint();
286+
const scalar_type reflectance = hlsl::dot(impl::__implicit_promote<spectral_type, typename fresnel_type::vector_type>::__call(_f(hlsl::abs(VdotH))), throughputWeights);
287287

288288
scalar_type rcpChoiceProb;
289289
scalar_type z = u.z;
@@ -324,8 +324,8 @@ struct SCookTorrance
324324

325325
NBL_IF_CONSTEXPR(IsBSDF)
326326
{
327-
spectral_type prefixThroughputWeights = interaction.getPrefixThroughputWeights();
328-
const scalar_type reflectance = hlsl::dot(impl::__implicit_promote<spectral_type, typename fresnel_type::vector_type>::__call(_f(hlsl::abs(cache.getVdotH()))), prefixThroughputWeights);
327+
spectral_type throughputWeights = interaction.getLuminosityContributionHint();
328+
const scalar_type reflectance = hlsl::dot(impl::__implicit_promote<spectral_type, typename fresnel_type::vector_type>::__call(_f(hlsl::abs(cache.getVdotH()))), throughputWeights);
329329
return hlsl::mix(reflectance, scalar_type(1.0) - reflectance, cache.isTransmission()) * DG1.projectedLightMeasure;
330330
}
331331
else
@@ -373,9 +373,9 @@ struct SCookTorrance
373373
spectral_type quo;
374374
NBL_IF_CONSTEXPR(IsBSDF)
375375
{
376-
spectral_type prefixThroughputWeights = interaction.getPrefixThroughputWeights();
376+
spectral_type throughputWeights = interaction.getLuminosityContributionHint();
377377
spectral_type reflectance = impl::__implicit_promote<spectral_type, typename fresnel_type::vector_type>::__call(_f(hlsl::abs(cache.getVdotH())));
378-
const scalar_type scaled_reflectance = hlsl::dot(reflectance, prefixThroughputWeights);
378+
const scalar_type scaled_reflectance = hlsl::dot(reflectance, throughputWeights);
379379
quo = hlsl::mix(reflectance / scaled_reflectance,
380380
(hlsl::promote<spectral_type>(1.0) - reflectance) / (scalar_type(1.0) - scaled_reflectance), cache.isTransmission()) * G2_over_G1;
381381
}

include/nbl/builtin/hlsl/bxdf/common.hlsl

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,6 @@ NBL_CONCEPT_END(
195195
((NBL_CONCEPT_REQ_EXPR_RET_TYPE)((iso.getNdotV2()), ::nbl::hlsl::is_same_v, typename T::scalar_type))
196196
((NBL_CONCEPT_REQ_EXPR_RET_TYPE)((iso.getPathOrigin()), ::nbl::hlsl::is_same_v, PathOrigin))
197197
((NBL_CONCEPT_REQ_EXPR_RET_TYPE)((iso.getLuminosityContributionHint()), ::nbl::hlsl::is_same_v, typename T::spectral_type))
198-
((NBL_CONCEPT_REQ_EXPR_RET_TYPE)((iso.getPrefixThroughputWeights()), ::nbl::hlsl::is_same_v, typename T::spectral_type))
199198
((NBL_CONCEPT_REQ_EXPR_RET_TYPE)((T::create(normV,normN)), ::nbl::hlsl::is_same_v, T))
200199
((NBL_CONCEPT_REQ_TYPE_ALIAS_CONCEPT)(ray_dir_info::Basic, typename T::ray_dir_info_type))
201200
);
@@ -223,7 +222,6 @@ struct SIsotropic
223222
retval.NdotV = nbl::hlsl::dot<vector3_type>(retval.N, retval.V.getDirection());
224223
retval.NdotV2 = retval.NdotV * retval.NdotV;
225224
retval.luminosityContributionHint = hlsl::promote<spectral_type>(1.0);
226-
retval.throughputWeights = hlsl::promote<spectral_type>(1.0);
227225

228226
return retval;
229227
}
@@ -238,19 +236,13 @@ struct SIsotropic
238236

239237
PathOrigin getPathOrigin() NBL_CONST_MEMBER_FUNC { return PathOrigin::PO_SENSOR; }
240238
spectral_type getLuminosityContributionHint() NBL_CONST_MEMBER_FUNC { return luminosityContributionHint; }
241-
spectral_type getPrefixThroughputWeights() NBL_CONST_MEMBER_FUNC
242-
{
243-
spectral_type prefixThroughputWeights = luminosityContributionHint * throughputWeights;
244-
return prefixThroughputWeights / math::lpNorm<spectral_type,1>(prefixThroughputWeights);
245-
}
246239

247240
RayDirInfo V;
248241
vector3_type N;
249242
scalar_type NdotV;
250243
scalar_type NdotV2;
251244

252245
spectral_type luminosityContributionHint;
253-
spectral_type throughputWeights; // product of all quotients so far
254246
};
255247

256248
#define NBL_CONCEPT_NAME Anisotropic
@@ -337,7 +329,6 @@ struct SAnisotropic
337329
scalar_type getNdotV2() NBL_CONST_MEMBER_FUNC { return isotropic.getNdotV2(); }
338330
PathOrigin getPathOrigin() NBL_CONST_MEMBER_FUNC { return isotropic.getPathOrigin(); }
339331
spectral_type getLuminosityContributionHint() NBL_CONST_MEMBER_FUNC { return isotropic.getLuminosityContributionHint(); }
340-
spectral_type getPrefixThroughputWeights() NBL_CONST_MEMBER_FUNC { return isotropic.getPrefixThroughputWeights(); }
341332

342333
vector3_type getT() NBL_CONST_MEMBER_FUNC { return T; }
343334
vector3_type getB() NBL_CONST_MEMBER_FUNC { return B; }

0 commit comments

Comments
 (0)