Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support getting hit vertex positions. #7141

Closed
wants to merge 401 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
401 commits
Select commit Hold shift + click to select a range
3765def
apply clippy and rustfmt changes
Vecvec Dec 12, 2023
986d520
fix some memory leaks
Vecvec Dec 13, 2023
859f6c5
Merge from gfx-rs/trunk
Vecvec Dec 13, 2023
07f6e1a
Merge remote-tracking branch 'gfx-rs/trunk' into ray-tracing
Vecvec Dec 17, 2023
817e545
fix incompatibility with new wgpu trunk changes
Vecvec Dec 17, 2023
e0b6724
fix clippy & fmt
Vecvec Dec 17, 2023
d66fcaa
fix clippy errors on github
Vecvec Dec 17, 2023
9980d45
Merge remote-tracking branch 'gfx-rs/trunk' into ray-tracing
Vecvec Dec 18, 2023
c288e08
update to trunk
Vecvec Dec 18, 2023
8e606c2
remove a line that printed log "Created blas ..." in device create tlas
Vecvec Dec 18, 2023
a9d12af
Merge remote-tracking branch 'gfx-rs/trunk' into ray-tracing
Vecvec Dec 20, 2023
ea77c34
Merge remote-tracking branch 'gfx-rs/trunk' into ray-tracing
Vecvec Dec 21, 2023
0f3c84b
Merge remote-tracking branch 'gfx-rs/trunk' into ray-tracing
Vecvec Jan 2, 2024
909f366
Merge remote-tracking branch 'gfx-rs/trunk' into ray-tracing
Vecvec Jan 7, 2024
ccc6969
fix merge issues
Vecvec Jan 7, 2024
8c82cc5
Merge remote-tracking branch 'gfx-rs/trunk' into ray-tracing
Vecvec Jan 8, 2024
f2d5734
Merge remote-tracking branch 'gfx-rs/trunk' into ray-tracing
Vecvec Jan 14, 2024
8734e03
fix merge
Vecvec Jan 14, 2024
316f0e2
fix fmt
Vecvec Jan 14, 2024
f39a44c
Merge pull request #2 from Vecvec/ray-tracing
daniel-keitel Jan 17, 2024
1b4f220
restored example ray scene functionality
daniel-keitel Jan 17, 2024
78f399b
Merge commit 'c038b5c433aeb3bc55f2091da56216e3f1c07e74' into ray-tracing
JMS55 Feb 3, 2024
41133c4
WIP fix rebase
JMS55 Feb 3, 2024
41fe261
Fix compile issues
JMS55 Feb 4, 2024
d94cbeb
More fixes
JMS55 Feb 4, 2024
13c09f9
Merge commit '004e3efe84a320d9331371ed31fa50baa2414911' into ray-tracing
JMS55 Feb 18, 2024
b60f318
Fix rebase
JMS55 Feb 18, 2024
91b7546
Add wgls backend write_value_type AccelerationStructure
JMS55 Feb 18, 2024
972d9cb
Merge commit '5b9ade82233deac341c577ec02b70e7b3e518933' into ray-tracing
JMS55 Feb 25, 2024
2bc105d
Add back xtask Cargo.lock
JMS55 Feb 25, 2024
f3fa301
Revert serde path
JMS55 Feb 25, 2024
96877cc
Doc typos
JMS55 Feb 25, 2024
b459f37
Add -diff
JMS55 Feb 25, 2024
4a1080a
Revert more serde
JMS55 Feb 25, 2024
991c2c4
Revert serde again?
JMS55 Feb 25, 2024
e042a86
Fix doc typo
JMS55 Feb 25, 2024
8a7ee4f
initial commit: add naga get vertex (not fully tested)
Vecvec Mar 2, 2024
c6e4018
fix crash on generating SPIR-V (still untested)
Vecvec Mar 5, 2024
9c43954
clippy & fmt
Vecvec Mar 5, 2024
c85c4c5
fix missed clippy issue
Vecvec Mar 5, 2024
714650f
fix missed clippy issue (again)
Vecvec Mar 5, 2024
ab9b4f5
hopefully fix tests
Vecvec Mar 6, 2024
a55fbd1
rework vertex return so that it is easier to generate valid spirv
Vecvec Mar 8, 2024
b4a2fb3
example (WIP)
Vecvec Mar 8, 2024
28405cc
change name
Vecvec Mar 8, 2024
9ea6303
Revert "rework vertex return so that it is easier to generate valid s…
Vecvec Mar 9, 2024
a4e3067
fix reverting (revert was bc I was looking at glsl docs not spirv)
Vecvec Mar 9, 2024
b26cad7
finalise example (it works!)
Vecvec Mar 9, 2024
1201e5b
clippy
Vecvec Mar 9, 2024
9379e62
test
Vecvec Mar 9, 2024
11c8e24
fmt
Vecvec Mar 9, 2024
c79797d
screenshot
Vecvec Mar 9, 2024
8dbf57e
checks for invalid flags
Vecvec Mar 21, 2024
5db9cda
Merge remote-tracking branch 'origin/ray-tracing-get-vertex' into ray…
Vecvec Mar 21, 2024
03a0c68
clippy & fmt
Vecvec Mar 21, 2024
40fd0e4
fix readme
Vecvec Mar 21, 2024
a9fd82e
upside down normals fixed
Vecvec Mar 23, 2024
f81e214
Merge remote-tracking branch 'origin/ray-tracing-get-vertex' into ray…
Vecvec Mar 23, 2024
4823bba
update screenshot
Vecvec Mar 23, 2024
584de62
attempt to add a missing capability
Vecvec Mar 31, 2024
850fe77
attempt to add a missing capability (vulkan)
Vecvec Apr 5, 2024
abdbb40
Merge branch 'trunk' into ray-tracing
atlv24 Apr 14, 2024
67710d7
Fix problems
atlv24 Apr 14, 2024
f2511b5
fix validation
Vecvec Apr 26, 2024
6166c86
Merge pull request #1 from Vecvec/ray-tracing-fix-validation
atlv24 May 1, 2024
1aefc53
Merge commit 'fb3b33d09233140533a9e431256a8690bf4c5d42' into ray-trac…
JMS55 May 2, 2024
d0238b2
Merge pull request #2 from JMS55/ray-tracing2
atlv24 May 4, 2024
7a51685
Merge remote-tracking branch 'refs/remotes/gfx-rs/trunk' into ray-tra…
Vecvec Jun 1, 2024
a63b8d4
fix merge
Vecvec Jun 1, 2024
0c54402
fmt
Vecvec Jun 1, 2024
936c49d
Merge remote-tracking branch 'refs/remotes/origin/ray-tracing-updated…
Vecvec Jun 1, 2024
8b0a212
fix merge
Vecvec Jun 1, 2024
73835c7
dedupe Features & fmt
Vecvec Jun 1, 2024
ebf5dab
delete a test that is in the wrong branch
Vecvec Jun 1, 2024
d079bd0
Merge remote-tracking branch 'refs/remotes/gfx-rs/trunk' into ray-tra…
Vecvec Jun 15, 2024
7050d34
fix merge
Vecvec Jun 15, 2024
a5365bf
use staging buffer trackers in creating the ray-tracing staging buffe…
Vecvec Jun 16, 2024
9aaab3f
change one missed staging buffer's tracker
Vecvec Jun 17, 2024
c33de62
Merge remote-tracking branch 'refs/remotes/gfx-rs/trunk' into ray-tra…
Vecvec Jul 1, 2024
3ad91f2
fix merge
Vecvec Jul 3, 2024
8555869
clippy
Vecvec Jul 3, 2024
3eb8835
merge & fix
Vecvec Jul 7, 2024
b524bb2
remove some uses of blas ids
Vecvec Jul 8, 2024
f02507d
fmt
Vecvec Jul 8, 2024
4afba3b
Merge remote-tracking branch 'refs/remotes/gfx-rs/trunk' into ray-tra…
Vecvec Jul 9, 2024
7cb078b
fix merge
Vecvec Jul 9, 2024
d659a41
Merge pull request #3 from Vecvec/ray-tracing-updated
atlv24 Jul 26, 2024
d40b0fc
deduplicate code shared between command_encoder_build_acceleration_st…
Vecvec Jul 28, 2024
cafc0b0
clippy
Vecvec Jul 29, 2024
0cb14f5
Merge pull request #4 from Vecvec/ray-tracing-refactor
atlv24 Aug 9, 2024
523756a
Merge remote-tracking branch 'refs/remotes/gfx-rs/trunk' into ray-tra…
Vecvec Aug 14, 2024
9706f3c
fix merge
Vecvec Aug 14, 2024
49cfa7d
fix warnings
Vecvec Aug 14, 2024
2810f13
clippy & fmt
Vecvec Aug 14, 2024
d7141de
Merge remote-tracking branch 'refs/remotes/origin/ray-tracing-updated…
Vecvec Aug 15, 2024
f14a0d4
fix merge
Vecvec Aug 15, 2024
9fc8e0c
Merge remote-tracking branch 'refs/remotes/gfx-rs/trunk' into ray-tra…
Vecvec Nov 17, 2024
a6bbe46
fix merge
Vecvec Nov 17, 2024
c6a2993
fmt
Vecvec Nov 17, 2024
4f0411d
Merge remote-tracking branch 'refs/remotes/gfx-rs/trunk' into ray-tra…
Vecvec Nov 17, 2024
069538c
use nen-srgb to show normals better
Vecvec Nov 18, 2024
a009cfb
improve comments
Vecvec Dec 2, 2024
0922011
Merge remote-tracking branch 'refs/remotes/gfx-rs/trunk' into ray-tra…
Vecvec Dec 12, 2024
ed9a384
fix merge
Vecvec Dec 13, 2024
81b360e
use correct matrix transposed
Vecvec Dec 16, 2024
d0236a6
swap places of multiply
Vecvec Dec 18, 2024
96c7a63
Merge remote-tracking branch 'refs/remotes/gfx-rs/trunk' into ray-tra…
Vecvec Dec 18, 2024
c7b97f2
fix merge
Vecvec Dec 18, 2024
39b7c3e
Merge remote-tracking branch 'origin/ray-tracing-get-vertex' into ray…
Vecvec Dec 31, 2024
ac50798
Merge remote-tracking branch 'trunk/trunk' into ray-tracing-get-vertex
Vecvec Jan 16, 2025
d8af969
Fix merge.
Vecvec Jan 16, 2025
c5da888
Clippy, format.
Vecvec Jan 16, 2025
78a1ef9
Merge remote-tracking branch 'refs/remotes/gfx-rs/trunk' into ray-tra…
Vecvec Feb 7, 2025
f2e88e5
Format & regen snapshots.
Vecvec Feb 8, 2025
a26a211
Support candidate get vertex
Vecvec Feb 8, 2025
4188527
Add to spec.
Vecvec Feb 8, 2025
8f697fb
Note undefined behaviour.
Vecvec Feb 8, 2025
872b845
Remove dead code.
Vecvec Feb 8, 2025
be693c2
Merge remote-tracking branch 'refs/remotes/gfx-rs/trunk' into ray-tra…
Vecvec Feb 8, 2025
04898b8
Remove unnecessary features.
Vecvec Feb 8, 2025
9a71454
Not feature is experimental.
Vecvec Feb 8, 2025
ba3c790
Fix docs.
Vecvec Feb 8, 2025
910526b
Don't output dot.
Vecvec Feb 8, 2025
12bfe8f
Output dot (turns out it's not a shading language).
Vecvec Feb 8, 2025
a80c130
Add tests.
Vecvec Feb 9, 2025
b8bb8e3
Update specs.
Vecvec Feb 9, 2025
d399990
Format.
Vecvec Feb 9, 2025
3379b07
Update some comments.
Vecvec Feb 14, 2025
4c710d3
Merge remote-tracking branch 'refs/remotes/gfx-rs/trunk' into ray-tra…
Vecvec Feb 14, 2025
606acbc
Changelog.
Vecvec Feb 14, 2025
5302365
Clippy.
Vecvec Feb 14, 2025
dd46ed4
Clippy.
Vecvec Feb 14, 2025
78155a5
Allow comma or no flag.
Vecvec Feb 14, 2025
189c12a
Merge branch 'trunk' into ray-tracing-get-vertex
Vecvec Feb 14, 2025
225aa5a
Merge branch 'trunk' into ray-tracing-get-vertex
Vecvec Feb 14, 2025
070827d
Fix merge
Vecvec Feb 14, 2025
5e18822
Merge branch 'trunk' into ray-tracing-get-vertex
Vecvec Feb 15, 2025
1e280c1
Merge remote-tracking branch 'refs/remotes/gfx-rs/trunk' into ray-tra…
Vecvec Feb 15, 2025
60a7054
Merge remote-tracking branch 'trunk/trunk' into ray-tracing-get-vertex
Vecvec Feb 17, 2025
b5e32ce
add `max_shader_model` to `Dx12Compiler` (#7167)
teoxoy Feb 18, 2025
7e42040
Add validation tests ensuring destroyed textures and buffers cause su…
jamienicol Feb 19, 2025
ff547aa
Rebase
expenses Sep 3, 2022
922a82b
Woo! building an AS works
expenses Sep 11, 2022
a89b5c3
Fix alignment for amdpro driver
expenses Sep 11, 2022
11c3d59
Ray tracing works in shaders!
expenses Sep 12, 2022
8c0265a
Major clean up, allow for acceleration structure updates
expenses Sep 15, 2022
bb2d6d0
Put larger function call param lists into descriptors for easier dumm…
expenses Sep 15, 2022
805ccd5
Fix example, hopefully have fixed metal code
expenses Sep 18, 2022
88fa478
Shuffle some code around, add a dummy implementation for DX12 with so…
expenses Sep 15, 2022
1d21b14
unsafe blocks in unsafe functions
daniel-keitel Feb 21, 2023
de4a4cf
WIP api change get_acceleration_structure_build_sizes
daniel-keitel Feb 28, 2023
bdbc24d
added aabbs and geometry flag support
daniel-keitel Mar 1, 2023
8e3ad42
renamed to build_acceleration_structure
daniel-keitel Mar 1, 2023
92df5b5
multiple AS builds at once
daniel-keitel Mar 19, 2023
4a5019a
switched to using smallvec
daniel-keitel Mar 19, 2023
53b68f3
small api change + documentation
daniel-keitel Mar 19, 2023
9c1dcd7
added to changelog
daniel-keitel Mar 19, 2023
d1d270a
example skeleton
daniel-keitel Mar 27, 2023
dd53bd7
WIP
daniel-keitel Mar 27, 2023
7c2304d
WIP build blas/tlas
daniel-keitel Mar 28, 2023
9d01cec
WIP blas build should work
daniel-keitel Mar 29, 2023
6c320ac
WIP tlas build should work
daniel-keitel Mar 29, 2023
0c112b0
"working" example
daniel-keitel Mar 30, 2023
e8725a9
iterators as inputs
daniel-keitel Mar 30, 2023
a54fcd9
some cleanup
daniel-keitel Mar 30, 2023
8779a23
build validation
daniel-keitel Mar 31, 2023
9dd8121
drop and destroy
daniel-keitel Mar 31, 2023
9db19ca
clippy
daniel-keitel Apr 1, 2023
ebdffce
better example with test
daniel-keitel Apr 1, 2023
fa77f93
WIP working safe build (destruction missing)
daniel-keitel Apr 4, 2023
0c7c05e
build age validation
daniel-keitel Apr 5, 2023
928b1c3
added acceleration structure barriers
daniel-keitel Apr 5, 2023
f62d0e9
instances in examples + barrier "fix"
daniel-keitel Apr 5, 2023
0445cd0
clippy
daniel-keitel Apr 6, 2023
34da60f
WIP validation (alignments)
daniel-keitel Apr 7, 2023
5e51fb6
new example + example changes
daniel-keitel Apr 9, 2023
0f1d729
extracted into ray_tracing module in wgpu
daniel-keitel Apr 9, 2023
5d45fb0
simplified example
daniel-keitel Apr 9, 2023
fa9520e
WIP build api changes
daniel-keitel Apr 10, 2023
9a70c55
WIP new example
daniel-keitel Apr 10, 2023
74abdec
WIP example multiple blas in single build
daniel-keitel Apr 10, 2023
056cdbe
API change made TriangleGeometries owning
daniel-keitel Apr 10, 2023
87e0ccf
WIP scene
daniel-keitel Apr 10, 2023
553e52e
package tlas access + WIP scene materials
daniel-keitel Apr 11, 2023
302eafd
Fixes
JMS55 Aug 26, 2023
488b117
fixed ray-scene example
daniel-keitel Sep 4, 2023
e99a2f3
first dedicated ray-tracing test
daniel-keitel Sep 6, 2023
a1373f1
implemented requested changes
daniel-keitel Dec 1, 2023
d8dc810
fix test
Vecvec Dec 10, 2023
9e3fbe5
fix clippy (again)
Vecvec Dec 10, 2023
31055d0
add #[allow(dead_code)] to some structs to fix clippy on web assembly
Vecvec Dec 11, 2023
4c16cf7
move ray_cube_cube example and fix bugs
Vecvec Dec 12, 2023
002b5f9
move other examples
Vecvec Dec 12, 2023
21f0da1
fix test
Vecvec Dec 12, 2023
fa16051
apply clippy and rustfmt changes
Vecvec Dec 12, 2023
8416321
restored example ray scene functionality
daniel-keitel Jan 17, 2024
44b837e
Doc typos
JMS55 Feb 25, 2024
968e781
initial commit: add naga get vertex (not fully tested)
Vecvec Mar 2, 2024
38b96f1
fix crash on generating SPIR-V (still untested)
Vecvec Mar 5, 2024
e242519
clippy & fmt
Vecvec Mar 5, 2024
6f0210f
fix missed clippy issue (again)
Vecvec Mar 5, 2024
fa922a3
hopefully fix tests
Vecvec Mar 6, 2024
225f47e
rework vertex return so that it is easier to generate valid spirv
Vecvec Mar 8, 2024
934bdd3
example (WIP)
Vecvec Mar 8, 2024
d3c50b2
change name
Vecvec Mar 8, 2024
4bb1cc8
Revert "rework vertex return so that it is easier to generate valid s…
Vecvec Mar 9, 2024
716d3fe
fix reverting (revert was bc I was looking at glsl docs not spirv)
Vecvec Mar 9, 2024
85ee77b
finalise example (it works!)
Vecvec Mar 9, 2024
b438281
test
Vecvec Mar 9, 2024
591aa0f
fmt
Vecvec Mar 9, 2024
195366e
screenshot
Vecvec Mar 9, 2024
9886146
upside down normals fixed
Vecvec Mar 23, 2024
e70117e
checks for invalid flags
Vecvec Mar 21, 2024
e6589a4
clippy & fmt
Vecvec Mar 21, 2024
ac3d3de
fix readme
Vecvec Mar 21, 2024
2e71177
update screenshot
Vecvec Mar 23, 2024
526a9a6
attempt to add a missing capability
Vecvec Mar 31, 2024
80b9473
Fix problems
atlv24 Apr 14, 2024
b814fc4
fix merge
Vecvec Jun 1, 2024
eeeb1e4
fix merge
Vecvec Jun 1, 2024
49663bd
dedupe Features & fmt
Vecvec Jun 1, 2024
1a8c4ee
delete a test that is in the wrong branch
Vecvec Jun 1, 2024
6f8ee4d
fix merge
Vecvec Aug 14, 2024
071192f
fix warnings
Vecvec Aug 14, 2024
e079af6
clippy & fmt
Vecvec Aug 14, 2024
c8723fd
fix merge
Vecvec Aug 15, 2024
6ff2366
fix merge
Vecvec Nov 17, 2024
de7e8d8
fmt
Vecvec Nov 17, 2024
66ad4b5
use nen-srgb to show normals better
Vecvec Nov 18, 2024
26e89dc
improve comments
Vecvec Dec 2, 2024
96c2b1b
fix merge
Vecvec Dec 13, 2024
5c030da
use correct matrix transposed
Vecvec Dec 16, 2024
22aca7b
swap places of multiply
Vecvec Dec 18, 2024
79b2063
fix merge
Vecvec Dec 18, 2024
d090239
Fix merge.
Vecvec Jan 16, 2025
af47726
Clippy, format.
Vecvec Jan 16, 2025
74d6400
Format & regen snapshots.
Vecvec Feb 8, 2025
3114b62
Support candidate get vertex
Vecvec Feb 8, 2025
b7d1060
Add to spec.
Vecvec Feb 8, 2025
3a596d1
Note undefined behaviour.
Vecvec Feb 8, 2025
37fc3c3
Remove dead code.
Vecvec Feb 8, 2025
42b4f65
Not feature is experimental.
Vecvec Feb 8, 2025
2ee5c80
Add tests.
Vecvec Feb 9, 2025
a194b2b
Format.
Vecvec Feb 9, 2025
07e241c
Changelog.
Vecvec Feb 14, 2025
3425ffc
Clippy.
Vecvec Feb 14, 2025
b34c7a2
Clippy.
Vecvec Feb 14, 2025
1367fc7
Allow comma or no flag.
Vecvec Feb 14, 2025
f6a298d
Fix merge
Vecvec Feb 14, 2025
6aebbb0
Merge remote-tracking branch 'origin/ray-tracing-get-vertex' into ray…
Vecvec Feb 19, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ By @cwfitzgerald in [#7030](https://github.com/gfx-rs/wgpu/pull/7030).
- Add `util::StagingBelt::allocate()` so the staging belt can be used to write textures. By @kpreid in [#6900](https://github.com/gfx-rs/wgpu/pull/6900).
- Added `CommandEncoder::transition_resources()` for native API interop, and allowing users to slightly optimize barriers. By @JMS55 in [#6678](https://github.com/gfx-rs/wgpu/pull/6678).

- Support getting vertices of the hit triangle when raytracing. By @Vecvec in [#7141](https://github.com/gfx-rs/wgpu/pull/7141) .

#### Naga

- Support @must_use attribute on function declarations. By @turbocrime in [#6801](https://github.com/gfx-rs/wgpu/pull/6801).
Expand Down Expand Up @@ -2180,6 +2182,20 @@ By @cwfitzgerald in [#3671](https://github.com/gfx-rs/wgpu/pull/3671).
- Added basic ray-tracing api for acceleration structures, and ray-queries @daniel-keitel (started by @expenses) in [#3507](https://github.com/gfx-rs/wgpu/pull/3507)


### Added/New Features

#### General
- Added feature flags for ray-tracing (currently only hal): `RAY_QUERY` and `RAY_TRACING` @daniel-keitel (started by @expenses) in [#3507](https://github.com/gfx-rs/wgpu/pull/3507)

#### Vulkan

- Implemented basic ray-tracing api for acceleration structures, and ray-queries @daniel-keitel (started by @expenses) in [#3507](https://github.com/gfx-rs/wgpu/pull/3507)

#### Hal

- Added basic ray-tracing api for acceleration structures, and ray-queries @daniel-keitel (started by @expenses) in [#3507](https://github.com/gfx-rs/wgpu/pull/3507)


### Changes

#### General
Expand Down
6 changes: 6 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ gpu-descriptor = "0.3"
# DX12 dependencies
gpu-allocator = { version = "0.27", default-features = false }
range-alloc = "0.1"
mach-dxcompiler-rs = { version = "0.1.4", default-features = false }
mach-dxcompiler-rs = { version = "0.1.4", default-features = false } # remember to increase max_shader_model if applicable
windows-core = { version = "0.58", default-features = false }

# Gles dependencies
Expand Down
19 changes: 19 additions & 0 deletions etc/specs/ray_tracing.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ Naming is mostly taken from vulkan.
```wgsl
// - 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)
// Overload.
rayQueryInitialize(rq: ptr<function, ray_query<vertex_return>>, acceleration_structure: acceleration_structure<vertex_return>, ray_desc: RayDesc)

// - Traces the ray in the initialized ray_query (partially) through the scene.
// - Returns true if a triangle that was hit by the ray was in a `Blas` that is not marked as opaque.
Expand All @@ -63,6 +65,8 @@ rayQueryInitialize(rq: ptr<function, ray_query>, acceleration_structure: acceler
// - Calling this function multiple times will cause the ray traversal to continue if it was interrupted by a `Candidate`
// intersection.
rayQueryProceed(rq: ptr<function, ray_query>) -> bool
// Overload.
rayQueryProceed(rq: ptr<function, ray_query<vertex_return>>) -> bool

// - Generates a hit from procedural geometry at a particular distance.
rayQueryGenerateIntersection(hit_t: f32)
Expand All @@ -75,9 +79,19 @@ rayQueryTerminate()

// - Returns intersection details about a hit considered `Committed`.
rayQueryGetCommittedIntersection(rq: ptr<function, ray_query>) -> RayIntersection
// Overload.
rayQueryGetCommittedIntersection(rq: ptr<function, ray_query<vertex_return>>) -> RayIntersection

// - Returns intersection details about a hit considered `Candidate`.
rayQueryGetCandidateIntersection(rq: ptr<function, ray_query>) -> RayIntersection
// Overload.
rayQueryGetCandidateIntersection(rq: ptr<function, ray_query<vertex_return>>) -> RayIntersection

// - Returns the vertices of the hit triangle considered `Committed`.
getCommittedHitVertexPositions(rq: ptr<function, ray_query<vertex_return>>) -> array<vec3<f32>, 3>

// - Returns the vertices of the hit triangle considered `Candidate`.
getCandidateHitVertexPositions(rq: ptr<function, ray_query<vertex_return>>) -> array<vec3<f32>, 3>
```

> [!CAUTION]
Expand All @@ -89,6 +103,11 @@ rayQueryGetCandidateIntersection(rq: ptr<function, ray_query>) -> RayIntersectio
> `Candidate`.
> - Calling `rayQueryGetCandidateIntersection` when `rayQueryProceed`'s latest return on this ray query is considered
> `Committed`.
> - Calling `getCommittedHitVertexPositions` when `rayQueryProceed`'s latest return on this ray query is considered
> `Candidate`.
> - Calling `getCandidateHitVertexPositions` when `rayQueryProceed`'s latest return on this ray query is considered
> `Committed`.
> - Calling `get*HitVertexPositions` when the last `rayQueryProceed` did not hit a triangle
> - Calling `rayQueryProceed` when `rayQueryInitialize` has not previously been called on this ray query
> - Calling `rayQueryGenerateIntersection` on a query with last intersection kind not being
> `RAY_QUERY_INTERSECTION_AABB`,
Expand Down
4 changes: 4 additions & 0 deletions examples/features/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ pub mod msaa_line;
pub mod multiple_render_targets;
pub mod ray_cube_compute;
pub mod ray_cube_fragment;
pub mod ray_cube_normals;
pub mod ray_scene;
pub mod ray_shadows;
pub mod ray_traced_triangle;
Expand All @@ -31,6 +32,9 @@ pub mod texture_arrays;
pub mod timestamp_queries;
pub mod uniform_values;
pub mod water;
pub mod ray_cube_compute;
pub mod ray_cube_fragment;
pub mod ray_scene;

#[cfg(test)]
wgpu_test::gpu_test_main!();
6 changes: 6 additions & 0 deletions examples/features/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,12 @@ const EXAMPLES: &[ExampleDesc] = &[
webgl: false,
webgpu: false,
},
ExampleDesc {
name: "ray_cube_normals",
function: wgpu_examples::ray_cube_normals::main,
webgl: false, // No Ray-tracing extensions
webgpu: false, // No Ray-tracing extensions (yet)
},
];

fn get_example_name() -> Option<String> {
Expand Down
14 changes: 14 additions & 0 deletions examples/features/src/ray_cube_normals/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# ray-cube

This example renders a ray traced cube with hardware acceleration.
A separate compute shader is used to perform the ray queries.

## To Run

```
cargo run --bin wgpu-examples ray_cube_normals
```

## Screenshots

![Cube example](screenshot.png)
52 changes: 52 additions & 0 deletions examples/features/src/ray_cube_normals/blit.wgsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
struct VertexOutput {
@builtin(position) position: vec4<f32>,
@location(0) tex_coords: vec2<f32>,
};

// meant to be called with 3 vertex indices: 0, 1, 2
// draws one large triangle over the clip space like this:
// (the asterisks represent the clip space bounds)
//-1,1 1,1
// ---------------------------------
// | * .
// | * .
// | * .
// | * .
// | * .
// | * .
// |***************
// | . 1,-1
// | .
// | .
// | .
// | .
// |.
@vertex
fn vs_main(@builtin(vertex_index) vertex_index: u32) -> VertexOutput {
var result: VertexOutput;
let x = i32(vertex_index) / 2;
let y = i32(vertex_index) & 1;
let tc = vec2<f32>(
f32(x) * 2.0,
f32(y) * 2.0
);
result.position = vec4<f32>(
tc.x * 2.0 - 1.0,
1.0 - tc.y * 2.0,
0.0, 1.0
);
result.tex_coords = tc;
return result;
}

@group(0)
@binding(0)
var r_color: texture_2d<f32>;
@group(0)
@binding(1)
var r_sampler: sampler;

@fragment
fn fs_main(vertex: VertexOutput) -> @location(0) vec4<f32> {
return textureSample(r_color, r_sampler, vertex.tex_coords);
}
Loading
Loading