Skip to content

Commit

Permalink
fix shadow ray regression
Browse files Browse the repository at this point in the history
  • Loading branch information
pgrit committed Mar 8, 2024
1 parent eb624d9 commit f76c313
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Core/scene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,9 @@ bool Scene::IsOccluded(const Ray& ray, float maxDistance) {
rtcray.dir_z = ray.direction.z;
rtcray.tnear = ray.minDistance;
rtcray.tfar = maxDistance;
rtcray.mask = 0;
rtcray.mask = 1;
rtcray.flags = 0;
rtcray.time = 0;

rtcOccluded1(embreeScene, &rtcray);

Expand Down
39 changes: 39 additions & 0 deletions TinyEmbree.Tests/Raytracer_Simple.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,45 @@ public void SimpleQuad_ShouldBeIntersected() {
Assert.Equal(1u, rt.Stats.NumRayHits);
}

[Fact]
public void SimpleQuad_ShadowRay() {

var vertices = new Vector3[] {
new Vector3(-1, 0, -1),
new Vector3( 1, 0, -1),
new Vector3( 1, 0, 1),
new Vector3(-1, 0, 1)
};

var indices = new int[] {
0, 1, 2,
0, 2, 3
};

TriangleMesh mesh = new(vertices, indices);

using var rt = new Raytracer();
rt.AddMesh(mesh);
rt.CommitScene();

Hit a = new() {
Position = new Vector3(-0.5f, -10, 0),
};

Hit b = new() {
Position = new Vector3(-0.5f, 10, 0),
};

Hit c = new() {
Position = new Vector3(-0.5f, -20, 0),
};

Assert.True(rt.IsOccluded(a, b));
Assert.True(rt.IsOccluded(b, a));
Assert.True(!rt.IsOccluded(a, c));
Assert.True(!rt.IsOccluded(c, a));
}

[Fact]
public void SimpleQuad_ShouldBeMissed() {
var vertices = new Vector3[] {
Expand Down

0 comments on commit f76c313

Please sign in to comment.