diff options
| author | Sébastien Crozet <developer@crozet.re> | 2022-04-28 18:24:01 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-04-28 18:24:01 +0200 |
| commit | 488aad0af3f772e14fd85b27bfff6c1db5d23829 (patch) | |
| tree | 4c19f613750fcd8779714915dbb752ce369a4173 /src_testbed/lines/debuglines2d.wgsl | |
| parent | 21a31bc1026d17d30b3a5ac35e6bb716dc66be6e (diff) | |
| parent | 7dc038aec66783d72abda446d6251385e6ad30f4 (diff) | |
| download | rapier-488aad0af3f772e14fd85b27bfff6c1db5d23829.tar.gz rapier-488aad0af3f772e14fd85b27bfff6c1db5d23829.tar.bz2 rapier-488aad0af3f772e14fd85b27bfff6c1db5d23829.zip | |
Merge pull request #315 from dimforge/debug-renderer
Add a basic lines-based debug-renderer
Diffstat (limited to 'src_testbed/lines/debuglines2d.wgsl')
| -rw-r--r-- | src_testbed/lines/debuglines2d.wgsl | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src_testbed/lines/debuglines2d.wgsl b/src_testbed/lines/debuglines2d.wgsl new file mode 100644 index 0000000..9316531 --- /dev/null +++ b/src_testbed/lines/debuglines2d.wgsl @@ -0,0 +1,31 @@ +#import bevy_sprite::mesh2d_view_bind_group +[[group(0), binding(0)]] +var<uniform> view: View; + +struct Vertex { + //[[location(0)]] color: vec4<f32>; + [[location(0)]] place: vec3<f32>; + [[location(1)]] color: u32; +}; + +struct VertexOutput { + [[builtin(position)]] clip_position: vec4<f32>; + [[location(0)]] color: vec4<f32>; +}; + +[[stage(vertex)]] +fn vertex(vertex: Vertex) -> VertexOutput { + var out: VertexOutput; + out.clip_position = view.view_proj * vec4<f32>(vertex.place, 1.0); + // What is this craziness? + out.color = vec4<f32>((vec4<u32>(vertex.color) >> vec4<u32>(0u, 8u, 16u, 24u)) & vec4<u32>(255u)) / 255.0; + //out.color = vertex.color; + //out.color = vec4<f32>(1.0, 0.0, 0.0, 1.0); + + return out; +} + +[[stage(fragment)]] +fn fragment(in: VertexOutput) -> [[location(0)]] vec4<f32> { + return in.color; +} |
