Skip to content

Commit

Permalink
Merge pull request #974 from tychedelia/render-fn
Browse files Browse the repository at this point in the history
Add new render function for raw wgpu.
  • Loading branch information
tychedelia committed Sep 6, 2024
2 parents e6725b7 + cbe0da6 commit 384f42e
Show file tree
Hide file tree
Showing 47 changed files with 12,781 additions and 29 deletions.
25 changes: 25 additions & 0 deletions Cargo.lock

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

5 changes: 4 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ members = [
"nannou_new",
"nannou_osc",
"nannou_package",
"nannou_wgpu",
"nature_of_code",
"scripts/run_all_examples",
"scripts/set_version",
Expand All @@ -26,9 +27,11 @@ resolver = "2"
bevy = "0.14.0"
bevy_egui = "0.28.0"
bevy-inspector-egui = "0.25.0"
image = "0.25"
rayon = "1.10"
bevy_common_assets = "0.11.0"
serde = "1"
serde_json = "1"
toml = "0.8"
serde_yaml = "0.9"
serde_yaml = "0.9"
wgpu = "0.20"
22 changes: 21 additions & 1 deletion examples/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -230,4 +230,24 @@ required-features = ["video"]
[[example]]
name = "video_material"
path = "video/video_material.rs"
required-features = ["video"]
required-features = ["video"]

# WebGPU
[[example]]
name = "wgpu_compute_shader"
path = "wgpu/wgpu_compute_shader/wgpu_compute_shader.rs"
[[example]]
name = "wgpu_image"
path = "wgpu/wgpu_image/wgpu_image.rs"
[[example]]
name = "wgpu_image_sequence"
path = "wgpu/wgpu_image_sequence/wgpu_image_sequence.rs"
[[example]]
name = "wgpu_instancing"
path = "wgpu/wgpu_instancing/wgpu_instancing.rs"
[[example]]
name = "wgpu_teapot"
path = "wgpu/wgpu_teapot/wgpu_teapot.rs"
[[example]]
name = "wgpu_triangle"
path = "wgpu/wgpu_triangle/wgpu_triangle.rs"
22 changes: 22 additions & 0 deletions examples/wgpu/wgpu_compute_shader/shaders/cs.wgsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
struct Buffer {
data: array<f32>,
};

struct Uniforms {
time: f32,
freq: f32,
oscillator_count: u32,
};

@group(0) @binding(0)
var<storage, read_write> output: Buffer;
@group(0) @binding(1)
var<uniform> uniforms: Uniforms;

@compute @workgroup_size(1, 1, 1)
fn main(@builtin(global_invocation_id) id: vec3<u32>) {
let index: u32 = id.x;
let phase: f32 = uniforms.time + f32(index) * uniforms.freq / f32(uniforms.oscillator_count);
output.data[index] = sin(phase) * 0.5 + 0.5;
return;
}
Loading

0 comments on commit 384f42e

Please sign in to comment.