Skip to main content

ray_query

Macro ray_query 

Source
macro_rules! ray_query {
    (let $name:ident) => { ... };
    (let mut $name:ident) => { ... };
    (@inner $name:ident $(, $mut:tt)?) => { ... };
}
Expand description

Constructs an uninitialized ray query variable. Using the syntax let (mut)? <name>. Where name is the name of the ray query variable.

ยงExample

use spirv_std::glam::Vec3;
use spirv_std::ray_query;
use spirv_std::ray_tracing::{AccelerationStructure, CommittedIntersection, RayFlags, RayQuery};

fn is_hit(accel: &AccelerationStructure, origin: Vec3, direction: Vec3) -> bool {
    ray_query!(let mut query);
    unsafe {
        query.initialize(accel, RayFlags::OPAQUE, 0xff, origin, 0.0, direction, 1000.0);
        while query.proceed() {}
        query.get_committed_intersection_type() != CommittedIntersection::None
    }
}