@@ -11,13 +11,12 @@ layout(set = 2, binding = 1) uniform usampler2D scramblebuf;
11
11
// vis buffer
12
12
layout(set = 2, binding = 2) uniform sampler2D depthbuf;
13
13
layout(set = 2, binding = 3) uniform usampler2D frontFacing_Object_Triangle;
14
+ //layout(set = 2, binding = 3) uniform sampler2D barycentricDerivatives;
14
15
layout(set = 2, binding = 4) uniform sampler2D encodedNormal;
15
16
layout(set = 2, binding = 5) uniform sampler2D uvCoords;
16
17
17
18
18
- // no idea yet
19
- #define sizeof_bsdf_data 1u // wtf??? it's not supposed to be user-defined
20
- #include <nbl/builtin/glsl/material_compiler/common_declarations.glsl>
19
+ #include "bin/material_declarations.glsl"
21
20
vec3 normalizedV;
22
21
vec3 nbl_glsl_MC_getNormalizedWorldSpaceV()
23
22
{
@@ -33,92 +32,26 @@ vec3 nbl_glsl_MC_getWorldSpacePosition()
33
32
{
34
33
return worldPosition;
35
34
}
35
+ mat2x3 dPosdScreen = mat2x3(vec3(0.0),vec3(0.0)); // TODO
36
36
mat2x3 nbl_glsl_MC_getdPos(in vec3 p)
37
37
{
38
- return mat2x3(vec3(0.0/0.0), vec3(0.0/0.0)) ;
38
+ return dPosdScreen ;
39
39
}
40
- /*
41
- #define _IRR_USER_PROVIDED_MATERIAL_COMPILER_GLSL_BACKEND_FUNCTIONS_
42
- instr_stream_t getEvalStream(in MC_precomputed_t precomp)
43
- {
44
- instr_stream_t stream;
45
- if (precomp.frontface)
46
- {
47
- stream.offset = InstData.data[InstanceIndex].front_instr_offset;
48
- stream.count = InstData.data[InstanceIndex].front_rem_pdf_count;
49
- }
50
- else
51
- {
52
- stream.offset = InstData.data[InstanceIndex].back_instr_offset;
53
- stream.count = InstData.data[InstanceIndex].back_rem_pdf_count;
54
- }
55
- return stream;
56
- }
57
- instr_t nbl_glsl_MC_fetchInstr(in uint ix)
40
+
41
+ nbl_glsl_instr_t nbl_glsl_MC_fetchInstr(in uint ix)
58
42
{
59
43
return instr_buf.data[ix];
60
44
}
61
- prefetch_instr_t nbl_glsl_MC_fetchPrefetchInstr(in uint ix)
45
+ nbl_glsl_prefetch_instr_t nbl_glsl_MC_fetchPrefetchInstr(in uint ix)
62
46
{
63
47
return prefetch_instr_buf.data[ix];
64
48
}
65
- bsdf_data_t nbl_glsl_MC_fetchBSDFData(in uint ix)
49
+ nbl_glsl_bsdf_data_t nbl_glsl_MC_fetchBSDFData(in uint ix)
66
50
{
67
51
return bsdf_buf.data[ix];
68
52
}
69
- ///
70
- //rem'n'pdf and eval use the same instruction stream
71
- instr_stream_t getRemAndPdfStream(in MC_precomputed_t precomp)
72
- {
73
- return getEvalStream(precomp);
74
- }
75
- instr_stream_t getGenChoiceStream(in MC_precomputed_t precomp)
76
- {
77
- instr_stream_t stream;
78
- if (precomp.frontface)
79
- {
80
- stream.offset = InstData.data[InstanceIndex].front_instr_offset + InstData.data[InstanceIndex].front_rem_pdf_count;
81
- stream.count = InstData.data[InstanceIndex].front_genchoice_count;
82
- }
83
- else
84
- {
85
- stream.offset = InstData.data[InstanceIndex].back_instr_offset + InstData.data[InstanceIndex].back_rem_pdf_count;
86
- stream.count = InstData.data[InstanceIndex].back_genchoice_count;
87
- }
88
- return stream;
89
- }
90
- instr_stream_t getTexPrefetchStream(in MC_precomputed_t precomp)
91
- {
92
- instr_stream_t stream;
93
- if (precomp.frontface)
94
- {
95
- stream.offset = InstData.data[InstanceIndex].front_prefetch_offset;
96
- stream.count = InstData.data[InstanceIndex].front_prefetch_count;
97
- }
98
- else
99
- {
100
- stream.offset = InstData.data[InstanceIndex].back_prefetch_offset;
101
- stream.count = InstData.data[InstanceIndex].back_prefetch_count;
102
- }
103
- return stream;
104
- }
105
- instr_stream_t getNormalPrecompStream(in MC_precomputed_t precomp)
106
- {
107
- instr_stream_t stream;
108
- if (precomp.frontface)
109
- {
110
- stream.offset = InstData.data[InstanceIndex].front_instr_offset + InstData.data[InstanceIndex].front_rem_pdf_count + InstData.data[InstanceIndex].front_genchoice_count;
111
- stream.count = InstData.data[InstanceIndex].front_nprecomp_count;
112
- }
113
- else
114
- {
115
- stream.offset = InstData.data[InstanceIndex].back_instr_offset + InstData.data[InstanceIndex].back_rem_pdf_count + InstData.data[InstanceIndex].back_genchoice_count;
116
- stream.count = InstData.data[InstanceIndex].back_nprecomp_count;
117
- }
118
- return stream;
119
- }
120
- #include <irr/builtin/material_compiler/glsl/common.glsl>
121
- */
53
+ #define _NBL_USER_PROVIDED_MATERIAL_COMPILER_GLSL_BACKEND_FUNCTIONS_
54
+ #include <nbl/builtin/glsl/material_compiler/common.glsl>
122
55
123
56
//
124
57
///
@@ -284,6 +217,15 @@ void main()
284
217
{
285
218
// vis buffer read
286
219
const uvec2 visBuffer = texelFetch(frontFacing_Object_Triangle,pixelCoord,0).rg;
220
+ mat2x3 dBarydScreen;/*
221
+ {
222
+ // TODO: future https://diaryofagraphicsprogrammer.blogspot.com/2018/03/triangle-visibility-buffer.html
223
+ vec4 data;// = texelFetch(barycentricDerivatives,pixelCoord,0);
224
+ dBarydScreen[0] = vec3(data.rg,-data.r-data.g);
225
+ dBarydScreen[1] = vec3(data.ba,-data.b-data.a);
226
+ }
227
+ dPosdScreen = mat3(vPos[0],vPos[1],vPos[2])*dBarydScreen;
228
+ */
287
229
// init scramble
288
230
start_scramble = texelFetch(scramblebuf,pixelCoord,0).rg;
289
231
// tmp gbuffer reads
@@ -313,8 +255,8 @@ void main()
313
255
normalizedN = nbl_glsl_NormalDecode_signedSpherical(normalBuffer);
314
256
}
315
257
316
- // TODO: once we merge the material compiler with the raygen
317
- // precomputed = precomputeData (frontfacing);
258
+ //
259
+ nbl_glsl_MC_precomputed_t precomputed = nbl_glsl_precomputeData (frontfacing);
318
260
319
261
//
320
262
const vec3 emissive = vec3(0.0,1.0,0.0);
0 commit comments