-
Notifications
You must be signed in to change notification settings - Fork 65
Hlsl bxdfs 3 #899
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Hlsl bxdfs 3 #899
Changes from 2 commits
34ee35c
f6752c6
42fcb2a
81e56f4
1e73953
6253da8
d13cad4
7110c50
98a0be1
eef66c6
eec8486
fcadc22
9742aa1
8433133
bafe623
3ad9f44
bc13d1f
f56476e
fe7c882
a12d8d1
328c7ea
aeafa07
91ca79e
3401783
3115423
b244c12
e8d5aa3
8158aea
d632b3a
3df4851
ffaaf87
aae9a58
c3c97e1
b308bff
2c2b368
67993ad
35cd97a
4f230e8
029116f
aa91c06
362d8cd
7734550
05ef0e8
0abf434
2aa51eb
b53c605
16209a8
5a3e7e6
cbdb9f6
785291d
1286459
3616dcf
3b78a06
5bfdf2f
ecdbbf7
ca8905e
9d2a2f3
b83fae6
2539b13
796c65b
9ad1be4
567875c
2239a5e
6fc78a4
a4012dc
ac23035
ccaa0a5
cf6c5c2
1d3f291
d79346b
2217e81
a4fff1c
e413e78
8052ada
d176107
1a1327f
1cedf68
bde6e60
3618e4c
5a00f7d
35ded62
7d8e982
6e5c569
2125aab
a0d356b
a1d18d3
aceb799
a0dddce
772c9b6
c4de151
d00533a
90e39d1
4bf43e3
ce0001f
edca69a
967ec9e
0b4e33a
97a22af
0497410
18e8437
4c91597
de3e5f2
1337646
2fe105d
d3b3c59
6ad2965
705c4e9
0d4e8ab
660b0fc
6fcccfe
d1a37bd
dc739aa
7953914
d31a92b
721978e
78fb433
dc9db3e
cc031f6
6ca571e
39a8a9b
656b069
b02f8e6
6662daa
9712b8d
8c65555
e0ccc9e
b2b7794
e8a9756
bc68c22
2b8bbbb
2e368ab
bd52332
bff0aa6
deda14a
576b814
268b573
7162a29
540919b
ac70036
4c7dfa6
b982f2c
a0334a0
79ef0d7
cc5fab5
f99933b
f2f9210
493bc49
4b87a4a
31f2af8
927ef68
1cc205d
688b950
f0491a9
4ac25e5
5d74015
d24ac0e
6b5b24b
48816a0
f0e6aea
64ec358
af22570
21292a7
772e6a7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -21,37 +21,36 @@ namespace bxdf | |||||||||
namespace fresnel | ||||||||||
{ | ||||||||||
|
||||||||||
template<typename T NBL_PRIMARY_REQUIRES(is_scalar_v<T> || is_vector_v<T>) | ||||||||||
template<typename T NBL_PRIMARY_REQUIRES(concepts::FloatingPointLikeVectorial<T>) | ||||||||||
struct OrientedEtas | ||||||||||
{ | ||||||||||
using scalar_type = typename vector_traits<T>::scalar_type; | ||||||||||
|
||||||||||
static OrientedEtas<T> create(scalar_type NdotI, T eta) | ||||||||||
{ | ||||||||||
OrientedEtas<T> retval; | ||||||||||
retval.backside = NdotI < scalar_type(0.0); | ||||||||||
const bool backside = NdotI < scalar_type(0.0); | ||||||||||
const T rcpEta = hlsl::promote<T>(1.0) / eta; | ||||||||||
retval.value = retval.backside ? rcpEta : eta; | ||||||||||
retval.rcp = retval.backside ? eta : rcpEta; | ||||||||||
retval.value = backside ? rcpEta : eta; | ||||||||||
retval.rcp = backside ? eta : rcpEta; | ||||||||||
return retval; | ||||||||||
} | ||||||||||
|
||||||||||
T value; | ||||||||||
T rcp; | ||||||||||
bool backside; | ||||||||||
}; | ||||||||||
|
||||||||||
template<typename T NBL_PRIMARY_REQUIRES(is_scalar_v<T> || is_vector_v<T>) | ||||||||||
template<typename T NBL_PRIMARY_REQUIRES(concepts::FloatingPointLikeVectorial<T>) | ||||||||||
struct OrientedEtaRcps | ||||||||||
{ | ||||||||||
using scalar_type = typename vector_traits<T>::scalar_type; | ||||||||||
|
||||||||||
static OrientedEtaRcps<T> create(scalar_type NdotI, T eta) | ||||||||||
{ | ||||||||||
OrientedEtaRcps<T> retval; | ||||||||||
retval.backside = NdotI < scalar_type(0.0); | ||||||||||
const bool backside = NdotI < scalar_type(0.0); | ||||||||||
const T rcpEta = hlsl::promote<T>(1.0) / eta; | ||||||||||
retval.value = retval.backside ? eta : rcpEta; | ||||||||||
retval.value = backside ? eta : rcpEta; | ||||||||||
retval.value2 = retval.value * retval.value; | ||||||||||
return retval; | ||||||||||
} | ||||||||||
|
@@ -71,7 +70,6 @@ struct OrientedEtaRcps | |||||||||
|
||||||||||
T value; | ||||||||||
T value2; | ||||||||||
bool backside; | ||||||||||
}; | ||||||||||
|
||||||||||
} | ||||||||||
|
@@ -97,7 +95,7 @@ struct Reflect | |||||||||
this_t retval; | ||||||||||
retval.I = I; | ||||||||||
retval.N = N; | ||||||||||
retval.NdotI = computeNdotI(I, N); | ||||||||||
retval.recomputeNdotI(); | ||||||||||
return retval; | ||||||||||
} | ||||||||||
|
||||||||||
|
@@ -121,29 +119,16 @@ struct Refract | |||||||||
{ | ||||||||||
using this_t = Refract<T>; | ||||||||||
using vector_type = vector<T, 3>; | ||||||||||
using monochrome_type = vector<T, 1>; | ||||||||||
using scalar_type = T; | ||||||||||
|
||||||||||
static this_t create(NBL_CONST_REF_ARG(fresnel::OrientedEtaRcps<scalar_type>) rcpEtas, NBL_CONST_REF_ARG(vector_type) I, NBL_CONST_REF_ARG(vector_type) N) | ||||||||||
static this_t create(NBL_CONST_REF_ARG(fresnel::OrientedEtaRcps<monochrome_type>) rcpEtas, NBL_CONST_REF_ARG(vector_type) I, NBL_CONST_REF_ARG(vector_type) N, const bool backside) | ||||||||||
{ | ||||||||||
this_t retval; | ||||||||||
retval.I = I; | ||||||||||
retval.N = N; | ||||||||||
retval.NdotI = hlsl::dot<vector_type>(N, I); | ||||||||||
retval.NdotI2 = retval.NdotI * retval.NdotI; | ||||||||||
retval.rcpOrientedEta = rcpEtas; | ||||||||||
retval.recomputeNdotT(rcpEtas.backside, retval.NdotI2, rcpEtas.value2); | ||||||||||
return retval; | ||||||||||
} | ||||||||||
|
||||||||||
static this_t create(NBL_CONST_REF_ARG(fresnel::OrientedEtaRcps<scalar_type>) rcpEtas, NBL_CONST_REF_ARG(vector_type) I, NBL_CONST_REF_ARG(vector_type) N, const scalar_type NdotI) | ||||||||||
{ | ||||||||||
this_t retval; | ||||||||||
retval.I = I; | ||||||||||
retval.N = N; | ||||||||||
retval.NdotI = NdotI; | ||||||||||
retval.NdotI2 = retval.NdotI * retval.NdotI; | ||||||||||
retval.rcpOrientedEta = rcpEtas; | ||||||||||
retval.recomputeNdotT(rcpEtas.backside, retval.NdotI2, rcpEtas.value2); | ||||||||||
retval.recomputeNdotI(); | ||||||||||
retval.recomputeNdotT(backside, retval.NdotI2, rcpEtas.value2[0]); | ||||||||||
devshgraphicsprogramming marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||
return retval; | ||||||||||
} | ||||||||||
|
||||||||||
|
@@ -160,18 +145,17 @@ struct Refract | |||||||||
NdotT = ieee754::flipSign(absNdotT, backside); | ||||||||||
devshgraphicsprogramming marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||
} | ||||||||||
|
||||||||||
vector_type operator()() | ||||||||||
vector_type operator()(const bool backside, scalar_type rcpOrientedEta) | ||||||||||
{ | ||||||||||
recomputeNdotT(rcpOrientedEta.backside, NdotI2, rcpOrientedEta.value2); | ||||||||||
return N * (NdotI * rcpOrientedEta.value + NdotT) - rcpOrientedEta.value * I; | ||||||||||
recomputeNdotT(rcpOrientedEta.backside, NdotI2, rcpOrientedEta*rcpOrientedEta); | ||||||||||
return N * (NdotI * rcpOrientedEta + NdotT) - rcpOrientedEta * I; | ||||||||||
devshgraphicsprogramming marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||
} | ||||||||||
|
||||||||||
vector_type I; | ||||||||||
vector_type N; | ||||||||||
scalar_type NdotT; | ||||||||||
scalar_type NdotI; | ||||||||||
scalar_type NdotI2; | ||||||||||
fresnel::OrientedEtaRcps<scalar_type> rcpOrientedEta; | ||||||||||
}; | ||||||||||
|
||||||||||
template<typename T NBL_PRIMARY_REQUIRES(concepts::Scalar<T>) | ||||||||||
|
@@ -192,14 +176,14 @@ struct ReflectRefract | |||||||||
return retval; | ||||||||||
} | ||||||||||
|
||||||||||
static this_t create(bool r, NBL_CONST_REF_ARG(Refract<scalar_type>) refract) | ||||||||||
static this_t create(bool r, NBL_CONST_REF_ARG(Refract<scalar_type>) refract, scalar_type rcpOrientedEta) | ||||||||||
{ | ||||||||||
this_t retval; | ||||||||||
retval.I = refract.I; | ||||||||||
retval.N = refract.N; | ||||||||||
retval.NdotI = refract.NdotI; | ||||||||||
retval.NdotTorR = hlsl::mix(refract.NdotI, refract.NdotT, r); | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. don't store a The idea is that I create once, and I call So we can't keep a cached You can add There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can accept r(r.computeNdotTorR(doRefract)) then you can know whether refraction was intended from looking at |
||||||||||
retval.rcpOrientedEta = refract.rcpOrientedEta.value; | ||||||||||
retval.rcpOrientedEta = rcpOrientedEta; | ||||||||||
return retval; | ||||||||||
} | ||||||||||
|
||||||||||
|
@@ -232,7 +216,7 @@ struct ReflectRefract | |||||||||
namespace fresnel | ||||||||||
{ | ||||||||||
|
||||||||||
template<typename T NBL_PRIMARY_REQUIRES(is_scalar_v<T> || is_vector_v<T>) | ||||||||||
template<typename T NBL_PRIMARY_REQUIRES(concepts::FloatingPointScalar<T> || concepts::FloatingPointLikeVectorial<T>) | ||||||||||
struct Schlick | ||||||||||
{ | ||||||||||
using scalar_type = typename vector_traits<T>::scalar_type; | ||||||||||
|
@@ -257,7 +241,7 @@ struct Schlick | |||||||||
scalar_type clampedCosTheta; | ||||||||||
}; | ||||||||||
|
||||||||||
template<typename T NBL_PRIMARY_REQUIRES(is_scalar_v<T> || is_vector_v<T>) | ||||||||||
template<typename T NBL_PRIMARY_REQUIRES(concepts::FloatingPointScalar<T> || concepts::FloatingPointLikeVectorial<T>) | ||||||||||
struct Conductor | ||||||||||
{ | ||||||||||
using scalar_type = typename vector_traits<T>::scalar_type; | ||||||||||
|
@@ -294,7 +278,7 @@ struct Conductor | |||||||||
scalar_type clampedCosTheta; | ||||||||||
}; | ||||||||||
|
||||||||||
template<typename T NBL_PRIMARY_REQUIRES(is_scalar_v<T> || is_vector_v<T>) | ||||||||||
template<typename T NBL_PRIMARY_REQUIRES(concepts::FloatingPointScalar<T> || concepts::FloatingPointLikeVectorial<T>) | ||||||||||
struct Dielectric | ||||||||||
{ | ||||||||||
using scalar_type = typename vector_traits<T>::scalar_type; | ||||||||||
|
@@ -332,7 +316,7 @@ struct Dielectric | |||||||||
scalar_type absCosTheta; | ||||||||||
}; | ||||||||||
|
||||||||||
template<typename T NBL_PRIMARY_REQUIRES(is_scalar_v<T> || is_vector_v<T>) | ||||||||||
template<typename T NBL_PRIMARY_REQUIRES(concepts::FloatingPointScalar<T> || concepts::FloatingPointLikeVectorial<T>) | ||||||||||
struct DielectricFrontFaceOnly | ||||||||||
{ | ||||||||||
using scalar_type = typename vector_traits<T>::scalar_type; | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. look at your tpedef, your code still wont compile with a scalar T, just give up and require vectorial for Schlick, Conductor, Dielectric and so on There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It does compile and run with Nabla/include/nbl/builtin/hlsl/vector_utils/vector_traits.hlsl Lines 13 to 16 in 5a1575f
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||||||||||
|
Uh oh!
There was an error while loading. Please reload this page.