12
12
13
13
bool traceRay(in ImmutableRay_t _immutable, inout MutableRay_t _mutable)
14
14
{
15
- const bool anyHit = bitfieldExtract( _immutable.typeDepthSampleIx, 31 , 1 ) != 0 ;
15
+ const bool anyHit = _immutable.anyHit ;
16
16
17
17
int objectID = - 1 ;
18
18
float intersectionT = _immutable.maxT;
@@ -42,7 +42,7 @@ vec3 nbl_glsl_light_deferred_eval_and_prob(out float pdf, in Sphere sphere, in v
42
42
return Light_getRadiance(light);
43
43
}
44
44
45
- nbl_glsl_LightSample nbl_glsl_light_generate_and_remainder_and_pdf(out vec3 remainder, out float pdf, out float newRayMaxT, in vec3 origin, in nbl_glsl_AnisotropicViewSurfaceInteraction interaction, in vec3 u, in int depth)
45
+ nbl_glsl_LightSample nbl_glsl_light_generate_and_remainder_and_pdf(out vec3 remainder, out float pdf, out float newRayMaxT, in vec3 origin, in nbl_glsl_AnisotropicViewSurfaceInteraction interaction, in vec3 u, in uint depth)
46
46
{
47
47
// normally we'd pick from set of lights, using `u.z`
48
48
const Light light = lights[0 ];
@@ -82,7 +82,7 @@ nbl_glsl_LightSample nbl_glsl_light_generate_and_remainder_and_pdf(out vec3 rema
82
82
}
83
83
84
84
85
- bool closestHitProgram(inout Ray_t ray, inout nbl_glsl_xoroshiro64star_state_t scramble_state)
85
+ bool closestHitProgram(in uint depth, in uint _sample, inout Ray_t ray, inout nbl_glsl_xoroshiro64star_state_t scramble_state)
86
86
{
87
87
const MutableRay_t _mutable = ray._mutable;
88
88
@@ -114,9 +114,6 @@ bool closestHitProgram(inout Ray_t ray, inout nbl_glsl_xoroshiro64star_state_t s
114
114
vec3 lightVal = nbl_glsl_light_deferred_eval_and_prob(lightPdf,sphere,ray._immutable.origin,interaction,lights[lightID]);
115
115
ray._payload.accumulation += throughput* lightVal/ (1.0 + lightPdf* lightPdf* ray._payload.otherTechniqueHeuristic);
116
116
}
117
-
118
- const int sampleIx = bitfieldExtract(ray._immutable.typeDepthSampleIx,0 ,DEPTH_BITS_OFFSET);
119
- const int depth = bitfieldExtract(ray._immutable.typeDepthSampleIx,DEPTH_BITS_OFFSET,DEPTH_BITS_COUNT);
120
117
121
118
// check if we even have a BSDF at all
122
119
uint bsdfID = bitfieldExtract(bsdfLightIDs,0 ,16 );
@@ -138,7 +135,7 @@ bool closestHitProgram(inout Ray_t ray, inout nbl_glsl_xoroshiro64star_state_t s
138
135
139
136
140
137
const float bsdfGeneratorProbability = BSDFNode_getMISWeight(bsdf);
141
- mat2x3 epsilon = rand3d(depth,sampleIx ,scramble_state);
138
+ mat2x3 epsilon = rand3d(depth,_sample ,scramble_state);
142
139
143
140
float rcpChoiceProb;
144
141
const bool doNEE = nbl_glsl_partitionRandVariable(bsdfGeneratorProbability,epsilon[0 ].z,rcpChoiceProb);
@@ -202,7 +199,7 @@ bool closestHitProgram(inout Ray_t ray, inout nbl_glsl_xoroshiro64star_state_t s
202
199
ray._immutable.origin = intersection+ _sample.L* (doNEE ? maxT: 1.0 /* kSceneSize*/ )* getStartTolerance(depth);
203
200
ray._immutable.maxT = maxT;
204
201
ray._immutable.direction = _sample.L;
205
- ray._immutable.typeDepthSampleIx = bitfieldInsert(sampleIx,depth + 2 ,DEPTH_BITS_OFFSET,DEPTH_BITS_COUNT) | ( doNEE ? ANY_HIT_FLAG : 0 ) ;
202
+ ray._immutable.anyHit = doNEE;
206
203
return false;
207
204
}
208
205
}
0 commit comments