mirror of
https://github.com/gfx-rs/wgpu.git
synced 2025-12-08 21:26:17 +00:00
Add more info to the ray tracing spec. (#8559)
This commit is contained in:
parent
119b4efada
commit
594bc69022
@ -25,7 +25,7 @@ A [`Blas`] can be created with [`Device::create_blas`].
|
|||||||
A [`Tlas`] can be created with [`Device::create_tlas`].
|
A [`Tlas`] can be created with [`Device::create_tlas`].
|
||||||
|
|
||||||
The [`Tlas`] reference can be placed in a bind group to be used in a shader. A reference to a [`Blas`] can
|
The [`Tlas`] reference can be placed in a bind group to be used in a shader. A reference to a [`Blas`] can
|
||||||
be used to create [`TlasInstance`] alongside a transformation matrix, a custom index
|
be used to create [`TlasInstance`] alongside a transformation matrix, custom data
|
||||||
(this can be any data that should be given to the shader on a hit) which only the first 24
|
(this can be any data that should be given to the shader on a hit) which only the first 24
|
||||||
bits may be set, and a mask to filter hits in the shader.
|
bits may be set, and a mask to filter hits in the shader.
|
||||||
|
|
||||||
@ -75,7 +75,7 @@ fn render(/*whatever args you need to render*/) {
|
|||||||
}
|
}
|
||||||
let mut encoder =
|
let mut encoder =
|
||||||
device.create_command_encoder(&wgpu::CommandEncoderDescriptor { label: None });
|
device.create_command_encoder(&wgpu::CommandEncoderDescriptor { label: None });
|
||||||
/* do other preparations on th TlasInstance.*/
|
/* do other preparations on the TlasInstance.*/
|
||||||
encoder.build_acceleration_structures(iter::empty(), iter::once(&tlas_package));
|
encoder.build_acceleration_structures(iter::empty(), iter::once(&tlas_package));
|
||||||
/* more render code */
|
/* more render code */
|
||||||
queue.submit(Some(encoder.finish()));
|
queue.submit(Some(encoder.finish()));
|
||||||
@ -93,11 +93,13 @@ fn render(/*whatever args you need to render*/) {
|
|||||||
|
|
||||||
## `naga`'s raytracing API:
|
## `naga`'s raytracing API:
|
||||||
|
|
||||||
`naga` supports ray queries (also known as inline raytracing) only. Ray tracing pipelines are currently unsupported.
|
`naga` supports ray queries (also known as inline raytracing) only. To enable basic ray query functions you must add
|
||||||
Naming is mostly taken from vulkan.
|
`enable wgpu_ray_query` to the shader, ray queries and acceleration structures also support tags which require extra
|
||||||
|
`enable` extensions (see Acceleration structure tags for more info). Ray tracing pipelines
|
||||||
|
are currently unsupported. Naming is mostly taken from vulkan.
|
||||||
|
|
||||||
```wgsl
|
```wgsl
|
||||||
// - Initializes the `ray_query` to check where (if anywhere) the ray defined by `ray_desc` hits in `acceleration_structure
|
// - Initializes the `ray_query` to check where (if anywhere) the ray defined by `ray_desc` hits in `acceleration_structure`
|
||||||
rayQueryInitialize(rq: ptr<function, ray_query>, acceleration_structure: acceleration_structure, ray_desc: RayDesc)
|
rayQueryInitialize(rq: ptr<function, ray_query>, acceleration_structure: acceleration_structure, ray_desc: RayDesc)
|
||||||
// Overload.
|
// Overload.
|
||||||
rayQueryInitialize(rq: ptr<function, ray_query<vertex_return>>, acceleration_structure: acceleration_structure<vertex_return>, ray_desc: RayDesc)
|
rayQueryInitialize(rq: ptr<function, ray_query<vertex_return>>, acceleration_structure: acceleration_structure<vertex_return>, ray_desc: RayDesc)
|
||||||
@ -268,3 +270,14 @@ const RAY_QUERY_INTERSECTION_GENERATED = 2;
|
|||||||
// if the ray intersects the bounding box for a custom object.
|
// if the ray intersects the bounding box for a custom object.
|
||||||
const RAY_QUERY_INTERSECTION_AABB = 3;
|
const RAY_QUERY_INTERSECTION_AABB = 3;
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Acceleration structure tags
|
||||||
|
|
||||||
|
These are tags that can be added to a acceleration structure (`acceleration_structure` ->
|
||||||
|
`acceleration_structure<... insert tags here! ...>`) and to a ray query (`ray_query` ->
|
||||||
|
`ray_query<... insert tags here! ...>`). These require more features.
|
||||||
|
|
||||||
|
|
||||||
|
| Tag | Requirements | Description |
|
||||||
|
| --- | ------------ | -- |
|
||||||
|
| `vertex_return`| `enable wgpu_ray_query_vertex_return` | Allows getting the vertices of the hit triangle when using ray queries |
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user