1
1
#version 430 core
2
2
#include "raytraceCommon.glsl"
3
3
4
+ // for per pixel inputs
4
5
#include <nbl/builtin/glsl/utils/normal_decode.glsl>
5
6
#include <nbl/builtin/glsl/random/xoroshiro.glsl>
6
7
@@ -10,13 +11,22 @@ layout(set = 2, binding = 1) uniform usampler2D scramblebuf;
10
11
// vis buffer
11
12
layout(set = 2, binding = 2) uniform sampler2D depthbuf;
12
13
layout(set = 2, binding = 3) uniform usampler2D frontFacing_Object_Triangle;
14
+ //layout(set = 2, binding = 3) uniform sampler2D barycentricDerivatives;
13
15
layout(set = 2, binding = 4) uniform sampler2D encodedNormal;
14
16
layout(set = 2, binding = 5) uniform sampler2D uvCoords;
15
17
16
18
17
- // no idea yet
18
- #define sizeof_bsdf_data 1u // wtf??? it's not supposed to be user-defined
19
- #include <nbl/builtin/glsl/material_compiler/common_declarations.glsl>
19
+ #include "bin/material_declarations.glsl"
20
+
21
+ /*
22
+ // something to get our GLSL intellisense to "shut up"
23
+ #ifndef _NBL_EXT_MITSUBA_LOADER_VT_STORAGE_VIEW_COUNT
24
+ #define _NBL_EXT_MITSUBA_LOADER_VT_STORAGE_VIEW_COUNT 4
25
+ #include <nbl/builtin/glsl/virtual_texturing/impl_functions.glsl>
26
+ #endif
27
+ */
28
+ #include <nbl/builtin/glsl/ext/MitsubaLoader/material_compiler_compatibility_impl.glsl>
29
+
20
30
vec3 normalizedV;
21
31
vec3 nbl_glsl_MC_getNormalizedWorldSpaceV()
22
32
{
@@ -32,92 +42,13 @@ vec3 nbl_glsl_MC_getWorldSpacePosition()
32
42
{
33
43
return worldPosition;
34
44
}
45
+ mat2x3 dPosdScreen = mat2x3(vec3(0.0),vec3(0.0)); // TODO
35
46
mat2x3 nbl_glsl_MC_getdPos(in vec3 p)
36
47
{
37
- return mat2x3(vec3(0.0/0.0), vec3(0.0/0.0));
38
- }
39
- /*
40
- #define _IRR_USER_PROVIDED_MATERIAL_COMPILER_GLSL_BACKEND_FUNCTIONS_
41
- instr_stream_t getEvalStream(in MC_precomputed_t precomp)
42
- {
43
- instr_stream_t stream;
44
- if (precomp.frontface)
45
- {
46
- stream.offset = InstData.data[InstanceIndex].front_instr_offset;
47
- stream.count = InstData.data[InstanceIndex].front_rem_pdf_count;
48
- }
49
- else
50
- {
51
- stream.offset = InstData.data[InstanceIndex].back_instr_offset;
52
- stream.count = InstData.data[InstanceIndex].back_rem_pdf_count;
53
- }
54
- return stream;
55
- }
56
- instr_t nbl_glsl_MC_fetchInstr(in uint ix)
57
- {
58
- return instr_buf.data[ix];
59
- }
60
- prefetch_instr_t nbl_glsl_MC_fetchPrefetchInstr(in uint ix)
61
- {
62
- return prefetch_instr_buf.data[ix];
63
- }
64
- bsdf_data_t nbl_glsl_MC_fetchBSDFData(in uint ix)
65
- {
66
- return bsdf_buf.data[ix];
67
- }
68
- ///
69
- //rem'n'pdf and eval use the same instruction stream
70
- instr_stream_t getRemAndPdfStream(in MC_precomputed_t precomp)
71
- {
72
- return getEvalStream(precomp);
73
- }
74
- instr_stream_t getGenChoiceStream(in MC_precomputed_t precomp)
75
- {
76
- instr_stream_t stream;
77
- if (precomp.frontface)
78
- {
79
- stream.offset = InstData.data[InstanceIndex].front_instr_offset + InstData.data[InstanceIndex].front_rem_pdf_count;
80
- stream.count = InstData.data[InstanceIndex].front_genchoice_count;
81
- }
82
- else
83
- {
84
- stream.offset = InstData.data[InstanceIndex].back_instr_offset + InstData.data[InstanceIndex].back_rem_pdf_count;
85
- stream.count = InstData.data[InstanceIndex].back_genchoice_count;
86
- }
87
- return stream;
88
- }
89
- instr_stream_t getTexPrefetchStream(in MC_precomputed_t precomp)
90
- {
91
- instr_stream_t stream;
92
- if (precomp.frontface)
93
- {
94
- stream.offset = InstData.data[InstanceIndex].front_prefetch_offset;
95
- stream.count = InstData.data[InstanceIndex].front_prefetch_count;
96
- }
97
- else
98
- {
99
- stream.offset = InstData.data[InstanceIndex].back_prefetch_offset;
100
- stream.count = InstData.data[InstanceIndex].back_prefetch_count;
101
- }
102
- return stream;
103
- }
104
- instr_stream_t getNormalPrecompStream(in MC_precomputed_t precomp)
105
- {
106
- instr_stream_t stream;
107
- if (precomp.frontface)
108
- {
109
- stream.offset = InstData.data[InstanceIndex].front_instr_offset + InstData.data[InstanceIndex].front_rem_pdf_count + InstData.data[InstanceIndex].front_genchoice_count;
110
- stream.count = InstData.data[InstanceIndex].front_nprecomp_count;
111
- }
112
- else
113
- {
114
- stream.offset = InstData.data[InstanceIndex].back_instr_offset + InstData.data[InstanceIndex].back_rem_pdf_count + InstData.data[InstanceIndex].back_genchoice_count;
115
- stream.count = InstData.data[InstanceIndex].back_nprecomp_count;
116
- }
117
- return stream;
48
+ return dPosdScreen;
118
49
}
119
- #include <irr/builtin/material_compiler/glsl/common.glsl>
120
- */
50
+ #define _NBL_USER_PROVIDED_MATERIAL_COMPILER_GLSL_BACKEND_FUNCTIONS_
51
+ #include <nbl/builtin/glsl/material_compiler/common.glsl>
121
52
122
53
//
123
54
///
@@ -277,12 +208,22 @@ void main()
277
208
278
209
bool alive = false;
279
210
nbl_glsl_MC_precomputed_t precomputed;
211
+ nbl_glsl_MC_oriented_material_t material;
280
212
nbl_glsl_xoroshiro64star_state_t start_scramble;
281
213
vec2 uv;
282
214
if (revdepth>0.0)
283
215
{
284
216
// vis buffer read
285
217
const uvec2 visBuffer = texelFetch(frontFacing_Object_Triangle,pixelCoord,0).rg;
218
+ mat2x3 dBarydScreen;/*
219
+ {
220
+ // TODO: future https://diaryofagraphicsprogrammer.blogspot.com/2018/03/triangle-visibility-buffer.html
221
+ vec4 data;// = texelFetch(barycentricDerivatives,pixelCoord,0);
222
+ dBarydScreen[0] = vec3(data.rg,-data.r-data.g);
223
+ dBarydScreen[1] = vec3(data.ba,-data.b-data.a);
224
+ }
225
+ dPosdScreen = mat3(vPos[0],vPos[1],vPos[2])*dBarydScreen;
226
+ */
286
227
// init scramble
287
228
start_scramble = texelFetch(scramblebuf,pixelCoord,0).rg;
288
229
// tmp gbuffer reads
@@ -312,11 +253,12 @@ void main()
312
253
normalizedN = nbl_glsl_NormalDecode_signedSpherical(normalBuffer);
313
254
}
314
255
315
- // TODO: once we merge the material compiler with the raygen
316
- //precomputed = precomputeData(frontfacing);
256
+ //
257
+ precomputed = nbl_glsl_MC_precomputeData(frontfacing);
258
+ //material = nbl_glsl_MC_material_data_t_getOriented(InstData.data[objectID].material,precomputed.frontface);
317
259
318
260
//
319
- const vec3 emissive = vec3(0.0,1.0,0.0);
261
+ const vec3 emissive = vec3(0.0,1.0,0.0);//nbl_glsl_MC_oriented_material_t_getEmissive(material);
320
262
vec3 acc;
321
263
if (pc.cummon.rcpFramesDispatched<1.0)
322
264
acc = fetchAccumulation(pixelCoord)+emissive/float(pc.cummon.framesDispatched-1u);
@@ -351,8 +293,8 @@ void main()
351
293
{
352
294
throughput /= float(staticViewData.samplesPerPixelPerDispatch);
353
295
354
- rays[realOutputID].origin = nbl_glsl_MC_WorldSpacePosition ();/*+newray.direction*err?; TODO */
355
- rays[realOutputID].maxT = 0.0 ;
296
+ rays[realOutputID].origin = nbl_glsl_MC_getWorldSpacePosition ();/*+newray.direction*err?; TODO */
297
+ rays[realOutputID].maxT = FLT_MAX ;
356
298
rays[realOutputID].direction = direction;
357
299
rays[realOutputID].mask = -1;
358
300
rays[realOutputID]._active = 1;
0 commit comments