@@ -47,6 +47,22 @@ NBL_CONCEPT_END(
47
47
);
48
48
#undef query
49
49
#include <nbl/builtin/hlsl/concepts/__end.hlsl>
50
+
51
+ #define NBL_CONCEPT_NAME G2XQuery
52
+ #define NBL_CONCEPT_TPLT_PRM_KINDS (typename)
53
+ #define NBL_CONCEPT_TPLT_PRM_NAMES (T)
54
+ #define NBL_CONCEPT_PARAM_0 (query, T)
55
+ NBL_CONCEPT_BEGIN (1 )
56
+ #define query NBL_CONCEPT_PARAM_T NBL_CONCEPT_PARAM_0
57
+ NBL_CONCEPT_END (
58
+ ((NBL_CONCEPT_REQ_TYPE)(T::scalar_type))
59
+ ((NBL_CONCEPT_REQ_EXPR_RET_TYPE)((query.getDevshV ()), ::nbl::hlsl::is_same_v, typename T::scalar_type))
60
+ ((NBL_CONCEPT_REQ_EXPR_RET_TYPE)((query.getDevshL ()), ::nbl::hlsl::is_same_v, typename T::scalar_type))
61
+ ((NBL_CONCEPT_REQ_EXPR_RET_TYPE)((query.getTransmitted ()), ::nbl::hlsl::is_same_v, bool ))
62
+ ((NBL_CONCEPT_REQ_EXPR_RET_TYPE)((query.getClampMode ()), ::nbl::hlsl::is_same_v, BxDFClampMode))
63
+ );
64
+ #undef query
65
+ #include <nbl/builtin/hlsl/concepts/__end.hlsl>
50
66
}
51
67
52
68
template<typename T, bool IsAnisotropic=false NBL_STRUCT_CONSTRAINABLE>
@@ -104,34 +120,41 @@ struct GGX<T,false NBL_PARTIAL_REQ_BOT(concepts::FloatingPointScalar<T>) >
104
120
return scalar_type (1.0 ) / (absNdotX + devsh_part);
105
121
}
106
122
107
- template<class LS, class Interaction NBL_FUNC_REQUIRES (LightSample<LS> && surface_interactions::Isotropic<Interaction>)
108
- scalar_type correlated_wo_numerator (NBL_CONST_REF_ARG (LS) _sample, NBL_CONST_REF_ARG (Interaction) interaction, BxDFClampMode _clamp )
123
+ template<class Query, class LS, class Interaction NBL_FUNC_REQUIRES (ggx_concepts::G2XQuery<Query> && LightSample<LS> && surface_interactions::Isotropic<Interaction>)
124
+ scalar_type correlated_wo_numerator (NBL_CONST_REF_ARG (Query) query, NBL_CONST_REF_ARG ( LS) _sample, NBL_CONST_REF_ARG (Interaction) interaction)
109
125
{
126
+ BxDFClampMode _clamp = query.getClampMode ();
127
+ assert (_clamp != BxDFClampMode::BCM_NONE);
128
+
110
129
// numerator is 2 * NdotV * NdotL, we factor out 4 * NdotV * NdotL, hence 0.5
111
- scalar_type Vterm = _sample.getNdotL (_clamp) * devsh_part (interaction. getNdotV2 () );
112
- scalar_type Lterm = interaction.getNdotV (_clamp) * devsh_part (_sample. getNdotL2 () );
130
+ scalar_type Vterm = _sample.getNdotL (_clamp) * query. getDevshV ( );
131
+ scalar_type Lterm = interaction.getNdotV (_clamp) * query. getDevshL ( );
113
132
return scalar_type (0.5 ) / (Vterm + Lterm);
114
133
}
115
134
116
- template<class LS, class Interaction NBL_FUNC_REQUIRES (LightSample<LS> && surface_interactions::Isotropic<Interaction>)
117
- scalar_type G2_over_G1 (NBL_CONST_REF_ARG (LS) _sample, NBL_CONST_REF_ARG (Interaction) interaction, bool transmitted, BxDFClampMode _clamp )
135
+ template<class Query, class LS, class Interaction, class MicrofacetCache NBL_FUNC_REQUIRES (ggx_concepts::G2XQuery<Query> && LightSample<LS> && surface_interactions::Isotropic<Interaction>)
136
+ scalar_type G2_over_G1 (NBL_CONST_REF_ARG (Query) query, NBL_CONST_REF_ARG ( LS) _sample, NBL_CONST_REF_ARG (Interaction) interaction)
118
137
{
138
+ BxDFClampMode _clamp = query.getClampMode ();
139
+ assert (_clamp != BxDFClampMode::BCM_NONE);
140
+
119
141
scalar_type G2_over_G1;
120
142
scalar_type NdotV = interaction.getNdotV (_clamp);
121
143
scalar_type NdotL = _sample.getNdotL (_clamp);
122
- if (transmitted)
144
+ scalar_type devsh_v = query.getDevshV ();
145
+ scalar_type devsh_l = query.getDevshL ();
146
+ if (query.getTransmitted ())
123
147
{
124
148
if (NdotV < 1e-7 || NdotL < 1e-7 )
125
149
return 0.0 ;
126
- scalar_type onePlusLambda_V = scalar_type (0.5 ) * (devsh_part (interaction. getNdotV2 ()) / NdotV + scalar_type (1.0 ));
127
- scalar_type onePlusLambda_L = scalar_type (0.5 ) * (devsh_part (_sample. getNdotL2 ()) / NdotL + scalar_type (1.0 ));
150
+ scalar_type onePlusLambda_V = scalar_type (0.5 ) * (devsh_v / NdotV + scalar_type (1.0 ));
151
+ scalar_type onePlusLambda_L = scalar_type (0.5 ) * (devsh_l / NdotL + scalar_type (1.0 ));
128
152
G2_over_G1 = bxdf::beta<scalar_type>(onePlusLambda_L, onePlusLambda_V) * onePlusLambda_V;
129
153
}
130
154
else
131
155
{
132
- scalar_type devsh_v = devsh_part (interaction.getNdotV2 ());
133
156
G2_over_G1 = NdotL * (devsh_v + NdotV); // alternative `Vterm+NdotL*NdotV /// NdotL*NdotV could come as a parameter
134
- G2_over_G1 /= NdotV * devsh_part (_sample. getNdotL2 ()) + NdotL * devsh_v;
157
+ G2_over_G1 /= NdotV * devsh_l + NdotL * devsh_v;
135
158
}
136
159
137
160
return G2_over_G1;
@@ -195,33 +218,40 @@ struct GGX<T,true NBL_PARTIAL_REQ_BOT(concepts::FloatingPointScalar<T>) >
195
218
return scalar_type (1.0 ) / (NdotX + devsh_part);
196
219
}
197
220
198
- template<class LS, class Interaction NBL_FUNC_REQUIRES (LightSample<LS> && surface_interactions::Anisotropic <Interaction>)
199
- scalar_type correlated_wo_numerator (NBL_CONST_REF_ARG (LS) _sample, NBL_CONST_REF_ARG (Interaction) interaction, BxDFClampMode _clamp )
221
+ template<class Query, class LS, class Interaction NBL_FUNC_REQUIRES (ggx_concepts::G2XQuery<Query> && LightSample<LS> && surface_interactions::Anisotropic <Interaction>)
222
+ scalar_type correlated_wo_numerator (NBL_CONST_REF_ARG (Query) query, NBL_CONST_REF_ARG ( LS) _sample, NBL_CONST_REF_ARG (Interaction) interaction)
200
223
{
201
- scalar_type Vterm = _sample.getNdotL (_clamp) * devsh_part (interaction.getTdotV2 (), interaction.getBdotV2 (), interaction.getNdotV2 ());
202
- scalar_type Lterm = interaction.getNdotV (_clamp) * devsh_part (_sample.getTdotL2 (), _sample.getBdotL2 (), _sample.getNdotL2 ());
224
+ BxDFClampMode _clamp = query.getClampMode ();
225
+ assert (_clamp != BxDFClampMode::BCM_NONE);
226
+
227
+ scalar_type Vterm = _sample.getNdotL (_clamp) * query.getDevshV ();
228
+ scalar_type Lterm = interaction.getNdotV (_clamp) * query.getDevshL ();
203
229
return scalar_type (0.5 ) / (Vterm + Lterm);
204
230
}
205
231
206
- template<class LS, class Interaction NBL_FUNC_REQUIRES (LightSample<LS> && surface_interactions::Anisotropic <Interaction>)
207
- scalar_type G2_over_G1 (NBL_CONST_REF_ARG (LS) _sample, NBL_CONST_REF_ARG (Interaction) interaction, bool transmitted, BxDFClampMode _clamp )
232
+ template<class Query, class LS, class Interaction, class MicrofacetCache NBL_FUNC_REQUIRES (ggx_concepts::G2XQuery<Query> && LightSample<LS> && surface_interactions::Anisotropic <Interaction>)
233
+ scalar_type G2_over_G1 (NBL_CONST_REF_ARG (Query) query, NBL_CONST_REF_ARG ( LS) _sample, NBL_CONST_REF_ARG (Interaction) interaction)
208
234
{
235
+ BxDFClampMode _clamp = query.getClampMode ();
236
+ assert (_clamp != BxDFClampMode::BCM_NONE);
237
+
209
238
scalar_type G2_over_G1;
210
239
scalar_type NdotV = interaction.getNdotV (_clamp);
211
240
scalar_type NdotL = _sample.getNdotL (_clamp);
212
- if (transmitted)
241
+ scalar_type devsh_v = query.getDevshV ();
242
+ scalar_type devsh_l = query.getDevshL ();
243
+ if (query.getTransmitted ())
213
244
{
214
245
if (NdotV < 1e-7 || NdotL < 1e-7 )
215
246
return 0.0 ;
216
- scalar_type onePlusLambda_V = scalar_type (0.5 ) * (devsh_part (interaction. getTdotV2 (), interaction. getBdotV2 (), interaction. getNdotV2 ()) / NdotV + scalar_type (1.0 ));
217
- scalar_type onePlusLambda_L = scalar_type (0.5 ) * (devsh_part (_sample. getTdotL2 (), _sample. getBdotL2 (), _sample. getNdotL2 ()) / NdotL + scalar_type (1.0 ));
247
+ scalar_type onePlusLambda_V = scalar_type (0.5 ) * (devsh_v / NdotV + scalar_type (1.0 ));
248
+ scalar_type onePlusLambda_L = scalar_type (0.5 ) * (devsh_l / NdotL + scalar_type (1.0 ));
218
249
G2_over_G1 = bxdf::beta<scalar_type>(onePlusLambda_L, onePlusLambda_V) * onePlusLambda_V;
219
250
}
220
251
else
221
252
{
222
- scalar_type devsh_v = devsh_part (interaction.getTdotV2 (), interaction.getBdotV2 (), interaction.getNdotV2 ());
223
253
G2_over_G1 = NdotL * (devsh_v + NdotV);
224
- G2_over_G1 /= NdotV * devsh_part (_sample. getTdotL2 (), _sample. getBdotL2 (), _sample. getNdotL2 ()) + NdotL * devsh_v;
254
+ G2_over_G1 /= NdotV * devsh_l + NdotL * devsh_v;
225
255
}
226
256
227
257
return G2_over_G1;
0 commit comments