Skip to content

Commit 6f80f73

Browse files
not the best error bounding solution in the world but seems to work
1 parent 371d614 commit 6f80f73

File tree

3 files changed

+14
-15
lines changed

3 files changed

+14
-15
lines changed

examples_tests/22.RaytracedAO/closestHit.comp

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -90,29 +90,22 @@ void main()
9090
);
9191

9292
vec3 origin_error;
93-
const float compactBary_error = 0.f; // TODO:
93+
const float compactBary_error = nbl_glsl_ieee754_gamma(1u);
9494
const vec3 origin = nbl_glsl_interpolate_with_bounds(origin_error,dPdBary,dPdBary_error,lastVxPos,lastVxPos_error,compactBary,compactBary_error);
9595

9696
generate_next_rays(
9797
MAX_RAYS_GENERATED,material,frontfacing,vertex_depth,scramble_start_state,
9898
sampleID,outPixelLocation,origin,origin_error,throughput
9999
);
100100
}
101-
#if 1
102-
if (vertex_depth!=2u)
103-
emissive = vec3(0.f);
104-
else
105-
emissive = frontfacing ? vec3(0.f,10.f,0.f):vec3(10.f,0.f,0.f);
106-
#endif
107101
}
108-
#if 1
102+
109103
// TODO: finish MIS
110104
vec3 acc;
111105
const uvec3 accumulationLocation = uvec3(outPixelLocation,sampleID%staticViewData.samplesPerPixelPerDispatch);
112106
const bool first_accumulating_path_vertex = accumulationLocation.z!=0u||get_path_vertex_depth()==2u;
113107
const bool notFirstFrame = pc.cummon.rcpFramesDispatched!=1.f;
114108
if (record_emission_common(acc,accumulationLocation,emissive*throughput,first_accumulating_path_vertex))
115109
storeAccumulation(acc,accumulationLocation);
116-
#endif
117110
}
118111
}

examples_tests/22.RaytracedAO/raygen.comp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,6 @@ void main()
6767
const vec3 origin = nbl_glsl_interpolate_with_bounds(origin_error,dPdBary,dPdBary_error,lastVxPos,lastVxPos_error,compactBary,compactBary_error);
6868
normalizedV = normalize(pc.cummon.camPos-origin);
6969

70-
//emissive = vec3(1000.f)*dot(abs(normalizedN),origin_error)*1.03125f;
71-
7270
// generate rays
7371
const uint vertex_depth = 1u;
7472
generate_next_rays(

examples_tests/22.RaytracedAO/raytraceCommon.glsl

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -302,9 +302,17 @@ for (uint i=1u; i!=vertex_depth; i++)
302302
// TODO: investigate workgroup reductions here
303303
const uint baseOutputID = atomicAdd(rayCount[pc.cummon.rayCountWriteIx],raysToAllocate);
304304

305-
const vec3 geomNormal = cross(dPdBary[0],dPdBary[1]);
306-
float ray_offset = dot(normalize(abs(normalizedN)),origin_error)+nbl_glsl_ieee754_gamma(3u);
307-
//float ray_offset = nbl_glsl_ieee754_gamma(3u);
305+
float ray_offset = dot(normalize(abs(normalizedN)),origin_error)+nbl_glsl_ieee754_gamma(3u); // I pulled the gamma(3) out of my @$$
306+
// TODO: in the future run backward error analysis of
307+
// dot(mat3(WorldToObj)*(origin+offset*geomNormal/length(geomNormal))+(WorldToObj-vx_pos[1]),geomNormal)
308+
// where
309+
// origin = mat3x2(vx_pos[2]-vx_pos[1],vx_pos[0]-vx_pos[1])*barys+vx_pos[1]
310+
// geonNormal = cross(vx_pos[2]-vx_pos[1],vx_pos[0]-vx_pos[1])
311+
// and we assume only `WorldToObj`, `vx_pos[i]` and `barys` are accurate values. So far:
312+
// offset > (1+gamma(2))/(1-gamma(2))*(dot(abs(geomNormal),omega_error)+dot(abs(omega),geomNormal_error)+dot(omega_error,geomNormal_error))
313+
//const vec3 geomNormal = cross(dPdBary[0],dPdBary[1]);
314+
//float ray_offset = ?;
315+
//ray_offset = nbl_glsl_ieee754_next_ulp_away_from_zero(ray_offset);
308316
// adjust for the fact that the normal might be too short (inversesqrt precision)
309317
ray_offset *= 1.03125f;
310318
uint offset = 0u;
@@ -326,7 +334,7 @@ for (uint i=1u; i!=vertex_depth; i++)
326334
}
327335
}
328336

329-
/* TODO: optimize
337+
/* TODO: optimize and reorganize
330338
void main()
331339
{
332340
clear_raycount();

0 commit comments

Comments
 (0)