Skip to content

Commit 3bcd088

Browse files
Implement anisotropic cache valid by construction
not sure we need to output `tangentSpaceL`, if we do, then I'll add overloads for it
1 parent de66abf commit 3bcd088

File tree

1 file changed

+30
-1
lines changed

1 file changed

+30
-1
lines changed

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

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,6 @@ struct LightSample
192192
//
193193
struct IsotropicMicrofacetCache
194194
{
195-
// always valid by construction
196195
// always valid because its specialized for the reflective case
197196
static IsotropicMicrofacetCache createForReflection(const float NdotV, const float NdotL, const float VdotL, out float LplusV_rcpLen)
198197
{
@@ -290,6 +289,36 @@ struct IsotropicMicrofacetCache
290289
struct AnisotropicMicrofacetCache : IsotropicMicrofacetCache
291290
{
292291
// always valid by construction
292+
static AnisotropicMicrofacetCache create(const float3 tangentSpaceV, const float3 tangentSpaceH)
293+
{
294+
AnisotropicMicrofacetCache retval;
295+
296+
retval.VdotH = dot(tangentSpaceV,tangentSpaceH);
297+
retval.LdotH = retval.VdotH;
298+
retval.NdotH = tangentSpaceH.z;
299+
retval.NdotH2 = retval.NdotH*retval.NdotH;
300+
retval.TdotH = tangentSpaceH.x;
301+
retval.BdotH = tangentSpaceH.y;
302+
303+
return retval;
304+
}
305+
static AnisotropicMicrofacetCache create(
306+
const float3 tangentSpaceV,
307+
const float3 tangentSpaceH,
308+
const bool transmitted,
309+
const float rcpOrientedEta,
310+
const float rcpOrientedEta2
311+
)
312+
{
313+
AnisotropicMicrofacetCache retval = create(tangentSpaceV,tangentSpaceH);
314+
if (transmitted)
315+
{
316+
const float VdotH = retval.VdotH;
317+
LdotH = transmitted ? refract_compute_NdotT(VdotH<0.0,VdotH*VdotH,rcpOrientedEta2);
318+
}
319+
320+
return retval;
321+
}
293322
// always valid because its specialized for the reflective case
294323
static AnisotropicMicrofacetCache createForReflection(const float3 tangentSpaceV, const float3 tangentSpaceL, const float VdotL)
295324
{

0 commit comments

Comments
 (0)