Skip to content

Commit

Permalink
Return if hit fails.
Browse files Browse the repository at this point in the history
  • Loading branch information
kugimasa committed Aug 21, 2023
1 parent d0370ea commit 250c0ac
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions resources/shader/compute-sample.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -276,15 +276,10 @@ fn intersect_tri(r: Ray, id: u32, closest: HitInfo) -> HitInfo {
hit = ray_dist < closest.dist &&
(0.0 <= u && u <= 1.0) &&
(0.0 <= v && (u + v) <= 1.0);

return HitInfo(
select(closest.dist, ray_dist, hit),
select(closest.pos, pos, hit),
select(closest.norm, norm, hit),
closest.uv,
select(closest.col, tri.col, hit),
select(closest.flags, flags, hit),
);
if (!hit) {
return closest;
}
return HitInfo(ray_dist, pos, norm, closest.uv, tri.col, flags);
}

fn intersect_quad(r: Ray, id: u32, closest: HitInfo) -> HitInfo {
Expand Down

0 comments on commit 250c0ac

Please sign in to comment.