@@ -85,7 +85,7 @@ vec3 rand3d(inout nbl_glsl_xoroshiro64star_state_t scramble_state, in uint _samp
85
85
return vec3(seqVal)*uintBitsToFloat(0x2f800004u);
86
86
}
87
87
88
- bool gen_sample_ray(
88
+ void gen_sample_ray(
89
89
out float maxT, out vec3 direction, out vec3 throughput,
90
90
inout nbl_glsl_xoroshiro64star_state_t scramble_state, in uint sampleID,
91
91
in nbl_glsl_MC_precomputed_t precomp, in nbl_glsl_MC_instr_stream_t gcs, in nbl_glsl_MC_instr_stream_t rnps
@@ -101,8 +101,6 @@ bool gen_sample_ray(
101
101
throughput /= float(staticViewData.samplesPerPixelPerDispatch);
102
102
103
103
direction = s.L;
104
-
105
- return any(greaterThan(throughput,vec3(FLT_MIN)));
106
104
}
107
105
108
106
void main()
@@ -122,6 +120,7 @@ void main()
122
120
nbl_glsl_MC_precomputed_t precomputed;
123
121
124
122
const bool nonBackgroudPixel = revdepth>0.0;
123
+ vec3 emissive = staticViewData.envmapBaseColor;
125
124
if (nonBackgroudPixel)
126
125
{
127
126
// vis buffer read
@@ -154,7 +153,6 @@ void main()
154
153
}
155
154
156
155
// decode vis buffer
157
- vec3 emissive = vec3(0.0,0.0,0.0);
158
156
{
159
157
const uint objectID = visBuffer[0]&0x7fffffffu;
160
158
const uint triangleID = visBuffer[1];
@@ -184,18 +182,18 @@ void main()
184
182
nbl_glsl_MC_runNormalPrecompStream(nbl_glsl_MC_oriented_material_t_getNormalPrecompStream(material), dUVdScreen, precomputed);
185
183
#endif
186
184
}
185
+ }
187
186
188
- //
189
- if (any(greaterThan(emissive,vec3(FLT_MIN))))
187
+ //
188
+ if (any(greaterThan(emissive,vec3(FLT_MIN))))
189
+ {
190
+ vec3 acc = emissive;
191
+ if (pc.cummon.rcpFramesDispatched<1.0)
190
192
{
191
- vec3 acc = emissive;
192
- if (pc.cummon.rcpFramesDispatched<1.0)
193
- {
194
- acc /= float(pc.cummon.framesDispatched-1u);
195
- acc += fetchAccumulation(pixelCoord);
196
- }
197
- storeAccumulation(acc,pixelCoord);
193
+ acc /= float(pc.cummon.framesDispatched-1u);
194
+ acc += fetchAccumulation(pixelCoord);
198
195
}
196
+ storeAccumulation(acc,pixelCoord);
199
197
}
200
198
#ifdef USE_OPTIX_DENOISER
201
199
// TODO: translate normal into float16_t buff
@@ -205,19 +203,18 @@ void main()
205
203
{
206
204
vec3 direction;
207
205
float maxT;
208
- vec4 throughput;
209
- throughput.a = -1.0; // -1 needs to be there to ensure no backface culling on rays
206
+ vec4 throughput = vec4(0.0,0.0,0.0,-1.0); // -1 needs to be there to ensure no backface culling on rays
210
207
211
- bool validRay = false;
212
208
if (nonBackgroudPixel)
213
209
{
214
210
nbl_glsl_xoroshiro64star_state_t scramble_state = scramble_start_state;
215
211
const uint sampleID = pc.cummon.samplesComputedPerPixel+i;
216
- validRay = gen_sample_ray(maxT,direction,throughput.rgb,scramble_state,sampleID,precomputed,gcs,rnps);
212
+ gen_sample_ray(maxT,direction,throughput.rgb,scramble_state,sampleID,precomputed,gcs,rnps);
217
213
}
218
214
219
215
// TODO: repack rays in smem for coalescing, or optimize this somehow
220
216
const uint realOutputID = outputID+i;
217
+ const bool validRay = any(greaterThan(throughput.rgb,vec3(FLT_MIN)));
221
218
if (validRay)
222
219
{
223
220
const float err = 1.0/256.0; // TODO: improve ray offsets
@@ -226,15 +223,15 @@ void main()
226
223
rays[realOutputID].direction = direction;
227
224
rays[realOutputID].mask = -1;
228
225
rays[realOutputID]._active = 1;
229
- rays[realOutputID].backfaceCulling = int(packHalf2x16(throughput.ab));
230
- rays[realOutputID].useless_padding = int(packHalf2x16(throughput.gr));
231
226
}
232
227
else
233
228
{
234
229
rays[realOutputID].maxT = 0.0;
235
230
rays[realOutputID].mask = 0;
236
231
rays[realOutputID]._active = 0;
237
232
}
233
+ rays[realOutputID].backfaceCulling = int(packHalf2x16(throughput.ab));
234
+ rays[realOutputID].useless_padding = int(packHalf2x16(throughput.gr));
238
235
}
239
236
}
240
237
}
0 commit comments