Skip to content

Commit 110547a

Browse files
committed
minor fixes to cook torrance, removed redundant functions
1 parent d0ed7d3 commit 110547a

File tree

1 file changed

+3
-31
lines changed

1 file changed

+3
-31
lines changed

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

Lines changed: 3 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -20,27 +20,6 @@ namespace bxdf
2020

2121
namespace impl
2222
{
23-
template<typename T, typename U>
24-
struct __implicit_promote;
25-
26-
template<typename T>
27-
struct __implicit_promote<T,T>
28-
{
29-
static T __call(const T v)
30-
{
31-
return v;
32-
}
33-
};
34-
35-
template<typename T>
36-
struct __implicit_promote<T,vector<typename vector_traits<T>::scalar_type, 1> >
37-
{
38-
static T __call(const vector<typename vector_traits<T>::scalar_type, 1> v)
39-
{
40-
return hlsl::promote<T>(v[0]);
41-
}
42-
};
43-
4423
template<class N, class F, bool IsBSDF>
4524
struct quant_query_helper;
4625

@@ -197,16 +176,12 @@ struct SCookTorrance
197176
// allows compiler to throw away calls to ndf.D if using __overwriteDG, before that we only avoid computation for G2(correlated)
198177
if (isInfinity)
199178
return value_weight_type::create(scalar_type(0.0), scalar_type(0.0));
200-
201-
scalar_type clampedVdotH = cache.getVdotH();
202-
NBL_IF_CONSTEXPR(IsBSDF)
203-
clampedVdotH = hlsl::abs(clampedVdotH);
204179

205180
spectral_type eval;
206181
NBL_IF_CONSTEXPR(IsBSDF)
207182
eval = pdfQuery.reflectance;
208183
else
209-
eval = impl::__implicit_promote<spectral_type, typename fresnel_type::vector_type>::__call(_f(clampedVdotH));
184+
eval = _f(cache.getVdotH());
210185
eval *= DG;
211186

212187
return value_weight_type::create(eval, _pdf);
@@ -383,14 +358,11 @@ struct SCookTorrance
383358
return query;
384359
}
385360

361+
query.pdf = DG1.projectedLightMeasure;
386362
NBL_IF_CONSTEXPR(IsBSDF)
387363
{
388364
query.scaled_reflectance = __getScaledReflectance(query.orientedFresnel, interaction, hlsl::abs(cache.getVdotH()), cache.isTransmission(), query.reflectance);
389-
query.pdf = query.scaled_reflectance * DG1.projectedLightMeasure;
390-
}
391-
else
392-
{
393-
query.pdf = DG1.projectedLightMeasure;
365+
query.pdf *= query.scaled_reflectance;
394366
}
395367
}
396368

0 commit comments

Comments
 (0)