Skip to content

Commit b70b7e3

Browse files
committed
Improve robustness of Embree flag test
1 parent 96e0af2 commit b70b7e3

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

src/render/tests/test_scene.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -319,12 +319,10 @@ def test11_sample_silhouette_bijective(variants_vec_rgb):
319319

320320
def test_enable_embree_robust_flag(variants_any_llvm):
321321

322-
# We intersect a ray against two adjacent triangles. The ray hits exactly
322+
# We intersect rays against two adjacent triangles. The rays hit exactly
323323
# the edge between two triangles, which Embree will not count as an
324324
# intersection if the "robust" flag is not set.
325-
R = mi.Transform4f() \
326-
.rotate(dr.normalize(mi.Vector3f(1, 1, 1)), 10) \
327-
.rotate([0, 1, 0], 40)
325+
R = mi.Transform4f().rotate(dr.normalize(mi.Vector3f(1, 1, 1)), 90)
328326
vertices = mi.Vector3f(
329327
[0.0, 1.0, 0.0, 1.0], [0.0, 0.0, 1.0, 1.0], [0.0, 0.0, 0.0, 0.0])
330328
vertices = R @ vertices
@@ -334,11 +332,15 @@ def test_enable_embree_robust_flag(variants_any_llvm):
334332
params['vertex_positions'] = dr.ravel(vertices)
335333
params['faces'] = [0, 1, 2, 1, 3, 2]
336334
params.update()
337-
ray = R @ mi.Ray3f(mi.Point3f(0.5, 0.5, 1), mi.Vector3f(0, 0, -1))
335+
336+
u, v = dr.meshgrid(dr.linspace(mi.Float, 0.05, 0.95, 32),
337+
dr.linspace(mi.Float, 0.05, 0.95, 32))
338+
d = mi.warp.square_to_cosine_hemisphere(mi.Vector2f(u, v))
339+
ray = R @ mi.Ray3f(mi.Point3f(0.5, 0.5, 0.0) + d, -d)
338340

339341
scene = mi.load_dict({'type': 'scene', 'mesh': mesh})
340-
assert not scene.ray_intersect(ray).is_valid()
342+
assert dr.any(~scene.ray_intersect(ray).is_valid())
341343

342344
scene = mi.load_dict({'type': 'scene', 'mesh': mesh,
343345
'embree_use_robust_intersections': True})
344-
assert scene.ray_intersect(ray).is_valid()
346+
assert dr.all(scene.ray_intersect(ray).is_valid())

0 commit comments

Comments
 (0)