Skip to content

Commit 643ca4f

Browse files
seems that geomNormal becomes NaN sometimes if pseudo-normalized, this is why RR was being so obnoxiously slow
1 parent fe575e1 commit 643ca4f

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

examples_tests/22.RaytracedAO/raytraceCommon.glsl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,13 +264,13 @@ for (uint i=1u; i!=vertex_depth; i++)
264264
// TODO: improve ray offset (maybe using smooth normal wouldn't be a sin)
265265
vec3 geomNormal = cross(dPdBary[0], dPdBary[1]);
266266
const vec3 absGeomNormal = abs(geomNormal);
267-
geomNormal /= max(max(absGeomNormal.x,absGeomNormal.y),absGeomNormal.z)*96.f;
267+
geomNormal /= max(max(absGeomNormal.x,absGeomNormal.y),max(absGeomNormal.z,0.001f))*96.f;
268268
uint offset = 0u;
269269
for (uint i=0u; i<maxRaysToGen; i++)
270270
if (maxT[i]!=0.f)
271271
{
272272
nbl_glsl_ext_RadeonRays_ray newRay;
273-
newRay.origin = origin+uintBitsToFloat(floatBitsToUint(geomNormal)^floatBitsToUint(dot(geomNormal,direction[i]))&0x80000000u);
273+
newRay.origin = origin+uintBitsToFloat(floatBitsToUint(geomNormal) ^ floatBitsToUint(dot(geomNormal, direction[i])) & 0x80000000u);
274274
newRay.maxT = maxT[i];
275275
newRay.direction = direction[i];
276276
newRay.time = packOutPixelLocation(outPixelLocation);

0 commit comments

Comments
 (0)