Skip to content

Commit

Permalink
Update vulkan example
Browse files Browse the repository at this point in the history
Example now renders in 3D using the tracked HMD position and
shows cubes at the location of each hand controller.
  • Loading branch information
exrook committed Feb 22, 2021
1 parent 5283daa commit c62226f
Show file tree
Hide file tree
Showing 8 changed files with 493 additions and 65 deletions.
7 changes: 7 additions & 0 deletions openxr/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ libloading = { version = "0.7", optional = true }
[dev-dependencies]
ash = "0.31"
ctrlc = "3.1.5"
cgmath = { version = "0.18", features = ["mint"] }
# We can't have a dev dependency with the same name as a feature
mint_dev = { package = "mint", version = "0.5" }

[[example]]
name = "vulkan"
required-features = ["mint"]

[target.'cfg(windows)'.dependencies]
winapi = { version = "0.3", features = ["profileapi"] }
Expand Down
4 changes: 2 additions & 2 deletions openxr/examples/debug_pattern.frag
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#version 450
#extension GL_EXT_multiview : require

layout(location = 0) in vec2 screen_coords;
layout(location = 1) in vec3 vColor;
layout(location = 0) out vec4 color;

void main() {
color = vec4(screen_coords, gl_ViewIndex, 1);
color = vec4(vColor.r, (cos(vColor.gb * 4) + 1)/2.0, 1);
}
Binary file modified openxr/examples/debug_pattern.frag.spv
Binary file not shown.
8 changes: 0 additions & 8 deletions openxr/examples/fullscreen.vert

This file was deleted.

Binary file removed openxr/examples/fullscreen.vert.spv
Binary file not shown.
26 changes: 26 additions & 0 deletions openxr/examples/transform.vert
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#version 450
#extension GL_EXT_multiview : require

layout(location = 0) in vec3 vPosition;

layout(location = 0) out vec2 screen_coords;
layout(location = 1) out vec3 vColor;

layout(push_constant) uniform ModelTransform {
mat4 model;
};

struct Transform {
mat4 view_project;
};

layout(binding = 0) uniform Transforms {
Transform transform[2];
};

void main() {
vec4 world_pos = model * vec4(vPosition, 1.0);
vec4 pos = transform[gl_ViewIndex].view_project * world_pos;
gl_Position = pos;
vColor = vec3(gl_VertexIndex/10.0, world_pos.gb);
}
Binary file added openxr/examples/transform.vert.spv
Binary file not shown.
Loading

0 comments on commit c62226f

Please sign in to comment.