Skip to content

Commit 3671194

Browse files
Create transmission.hlsl
1 parent 01fd600 commit 3671194

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
// Copyright (C) 2018-2020 - DevSH Graphics Programming Sp. z O.O.
2+
// This file is part of the "Nabla Engine".
3+
// For conditions of distribution and use, see copyright notice in nabla.h
4+
#ifndef _NBL_BUILTIN_HLSL_BXDF_TRANSMISSION_INCLUDED_
5+
#define _NBL_BUILTIN_HLSL_BXDF_TRANSMISSION_INCLUDED_
6+
7+
#include <nbl/builtin/glsl/math/functions.glsl>
8+
#include <nbl/builtin/hlsl/bxdf/common.hlsl>
9+
10+
namespace nbl
11+
{
12+
namespace hlsl
13+
{
14+
namespace bxdf
15+
{
16+
namespace transmission
17+
{
18+
19+
template<class RayDirInfo>
20+
LightSample<RayDirInfo> cos_generate(const surface_interactions::Isotropic<RayDirInfo> interaction)
21+
{
22+
return LightSample<RayDirInfo>(interaction.V.transmit(),-1.f,interaction.N);
23+
}
24+
template<class RayDirInfo>
25+
LightSample<RayDirInfo> cos_generate(const surface_interactions::Anisotropic<RayDirInfo> interaction)
26+
{
27+
return LightSample<RayDirInfo>(interaction.V.transmit(),-1.f,interaction.T,interaction.B,interaction.N);
28+
}
29+
30+
// Why don't we check that the incoming and outgoing directions equal each other
31+
// (or similar for other delta distributions such as reflect, or smooth [thin] dielectrics):
32+
// - The `quotient_and_pdf` functions are meant to be used with MIS and RIS
33+
// - Our own generator can never pick an improbable path, so no checking necessary
34+
// - For other generators the estimator will be `f_BSDF*f_Light*f_Visibility*clampedCos(theta)/(1+(p_BSDF^alpha+p_otherNonChosenGenerator^alpha+...)/p_ChosenGenerator^alpha)`
35+
// therefore when `p_BSDF` equals `nbl_glsl_FLT_INF` it will drive the overall MIS estimator for the other generators to 0 so no checking necessary
36+
template<typename SpectralBins>
37+
quotient_and_pdf<SpectralBins> cos_quotient_and_pdf()
38+
{
39+
return quotient_and_pdf<SpectralBins>::create(SpectralBins(1.f),nbl::hlsl::numeric_limits<float>::inf());
40+
}
41+
42+
}
43+
}
44+
}
45+
}
46+
47+
#endif

0 commit comments

Comments
 (0)