Skip to content

Commit

Permalink
Merge pull request #63 from alphastrata/v0-12
Browse files Browse the repository at this point in the history
Update to Bevy 0.12
  • Loading branch information
alphastrata authored Nov 7, 2023
2 parents cadfdb7 + 4a78bd2 commit 5f0f8af
Show file tree
Hide file tree
Showing 38 changed files with 643 additions and 350 deletions.
732 changes: 520 additions & 212 deletions Cargo.lock

Large diffs are not rendered by default.

22 changes: 6 additions & 16 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,39 +11,29 @@ Shadplay is a simple, (WIP) application that provides a window where shader code

[features]
default = ["ui"]
wayland = []
ui = []

[dependencies]
bevy = { version = "0.11.3", features = [
"filesystem_watcher",
bevy = { version = "0.12.0", features = [
"file_watcher",
"dynamic_linking",
"bevy_dylib",
"wayland",
"jpeg",
] }
bevy_egui = { version = "0.21.0" }
bevy_panorbit_camera = "0.8.*"
bevy_egui = { git = "https://github.com/raffaeleragni/bevy_egui", branch = "bevy_0_12" } #, version = "0.22.0" }
bevy_panorbit_camera = { git = "https://github.com/Plonq/bevy_panorbit_camera", branch = "bevy-0.12" } #, version= "0.9.0"}
chrono = "0.4.31"
copypasta = "0.10.0"
directories = "5.0.1"
serde = { version = "1.0.190", features = ["derive"] }
toml = "0.8.6"

[dev-dependencies]

[profile.dev] # A little bit of optimisation for dev builds
opt-level = 1

[profile.dev.package."*"] # Always build dependencies with the highest level of optimisations possible.
opt-level = 3

# No dynamic linking for production releases.
[profile.production]
inherits = "release"

[profile.production.bevy]
version = "0.11.*"
features = ["filesystem_watcher"]


[build-dependencies]
glob = "0.3.1"
58 changes: 29 additions & 29 deletions all_wgsl.wgsl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#import bevy_pbr::mesh_vertex_output MeshVertexOutput
#import bevy_pbr::mesh_vertex_output VertexOutput
#import bevy_pbr::mesh_view_bindings view
#import bevy_pbr::pbr_types STANDARD_MATERIAL_FLAGS_DOUBLE_SIDED_BIT
#import bevy_core_pipeline::tonemapping tone_mapping
Expand All @@ -10,7 +10,7 @@
@fragment
fn fragment(
@builtin(front_facing) is_front: bool,
mesh: MeshVertexOutput,
mesh: VertexOutput,
) -> @location(0) vec4<f32> {
let layer = i32(mesh.world_position.x) & 0x3;

Expand Down Expand Up @@ -50,7 +50,7 @@ fn fragment(
}
#import bevy_pbr::mesh_view_bindings
#import bevy_pbr::mesh_bindings
#import bevy_pbr::mesh_vertex_output MeshVertexOutput
#import bevy_pbr::forward_io::VertexOutput

@group(1) @binding(0) var test_texture_1d: texture_1d<f32>;
@group(1) @binding(1) var test_texture_1d_sampler: sampler;
Expand All @@ -71,23 +71,23 @@ fn fragment(
@group(1) @binding(11) var test_texture_3d_sampler: sampler;

@fragment
fn fragment(in: MeshVertexOutput) {}
fn fragment(in: VertexOutput) {}
#import bevy_pbr::mesh_view_bindings view
#import bevy_pbr::mesh_vertex_output MeshVertexOutput
#import bevy_pbr::mesh_vertex_output VertexOutput
#import bevy_pbr::utils coords_to_viewport_uv

@group(1) @binding(0) var texture: texture_2d<f32>;
@group(1) @binding(1) var texture_sampler: sampler;

@fragment
fn fragment(
mesh: MeshVertexOutput,
mesh: VertexOutput,
) -> @location(0) vec4<f32> {
let viewport_uv = coords_to_viewport_uv(mesh.position.xy, view.viewport);
let color = texture_sample(texture, texture_sampler, viewport_uv);
return color;
}
#import bevy_pbr::mesh_vertex_output MeshVertexOutput
#import bevy_pbr::forward_io::VertexOutput

struct CustomMaterial {
color: vec4<f32>,
Expand All @@ -99,13 +99,13 @@ struct CustomMaterial {

@fragment
fn fragment(
mesh: MeshVertexOutput,
mesh: VertexOutput,
) -> @location(0) vec4<f32> {
return material.color * texture_sample(base_color_texture, base_color_sampler, mesh.uv);
}
#import bevy_pbr::mesh_view_bindings
#import bevy_pbr::mesh_bindings
#import bevy_pbr::mesh_vertex_output MeshVertexOutput
#import bevy_pbr::mesh_vertex_output VertexOutput
#import bevy_pbr::utils PI

#ifdef TONEMAP_IN_SHADER
Expand Down Expand Up @@ -148,7 +148,7 @@ fn continuous_hue(uv: vec2<f32>) -> vec3<f32> {

@fragment
fn fragment(
in: MeshVertexOutput,
in: VertexOutput,
) -> @location(0) vec4<f32> {
var uv = in.uv;
var out = vec3(0.0);
Expand Down Expand Up @@ -251,7 +251,7 @@ fn fragment(in: FullscreenVertexOutput) -> @location(0) vec4<f32> {
);
}

#import bevy_pbr::mesh_vertex_output MeshVertexOutput
#import bevy_pbr::forward_io::VertexOutput

struct CustomMaterial {
color: vec4<f32>,
Expand All @@ -261,7 +261,7 @@ struct CustomMaterial {

@fragment
fn fragment(
mesh: MeshVertexOutput,
mesh: VertexOutput,
) -> @location(0) vec4<f32> {
#ifdef IS_RED
return vec4<f32>(1.0, 0.0, 0.0, 1.0);
Expand Down Expand Up @@ -333,7 +333,7 @@ fn update(@builtin(global_invocation_id) invocation_id: vec3<u32>) {
storage_barrier();

texture_store(texture, location, color);
}#import bevy_pbr::mesh_vertex_output MeshVertexOutput
}#import bevy_pbr::forward_io::VertexOutput

#ifdef CUBEMAP_ARRAY
@group(1) @binding(0) var base_color_texture: texture_cube_array<f32>;
Expand All @@ -345,7 +345,7 @@ fn update(@builtin(global_invocation_id) invocation_id: vec3<u32>) {

@fragment
fn fragment(
mesh: MeshVertexOutput,
mesh: VertexOutput,
) -> @location(0) vec4<f32> {
let fragment_position_view_lh = mesh.world_position.xyz * vec3<f32>(1.0, 1.0, -1.0);
return texture_sample(
Expand All @@ -354,7 +354,7 @@ fn fragment(
fragment_position_view_lh
);
}
#import bevy_pbr::mesh_vertex_output MeshVertexOutput
#import bevy_pbr::forward_io::VertexOutput

struct LineMaterial {
color: vec4<f32>,
Expand All @@ -364,7 +364,7 @@ struct LineMaterial {

@fragment
fn fragment(
mesh: MeshVertexOutput,
mesh: VertexOutput,
) -> @location(0) vec4<f32> {
return material.color;
}
Expand Down Expand Up @@ -405,7 +405,7 @@ fn vertex(vertex: Vertex) -> VertexOutput {
fn fragment(in: VertexOutput) -> @location(0) vec4<f32> {
return in.color;
}
#import bevy_pbr::mesh_vertex_output MeshVertexOutput
#import bevy_pbr::forward_io::VertexOutput

@group(1) @binding(0) var textures: binding_array<texture_2d<f32>>;
@group(1) @binding(1) var nearest_sampler: sampler;
Expand All @@ -414,7 +414,7 @@ fn fragment(in: VertexOutput) -> @location(0) vec4<f32> {

@fragment
fn fragment(
mesh: MeshVertexOutput,
mesh: VertexOutput,
) -> @location(0) vec4<f32> {
// Select the texture to sample from using non-uniform uv coordinates
let coords = clamp(vec2<u32>(mesh.uv * 4.0), vec2<u32>(0u), vec2<u32>(3u));
Expand All @@ -425,7 +425,7 @@ fn fragment(
#import bevy_pbr::mesh_types
#import bevy_pbr::mesh_view_bindings globals
#import bevy_pbr::prepass_utils
#import bevy_pbr::mesh_vertex_output MeshVertexOutput
#import bevy_pbr::mesh_vertex_output VertexOutput

struct ShowPrepassSettings {
show_depth: u32,
Expand All @@ -441,7 +441,7 @@ fn fragment(
#ifdef MULTISAMPLED
@builtin(sample_index) sample_index: u32,
#endif
mesh: MeshVertexOutput,
mesh: VertexOutput,
) -> @location(0) vec4<f32> {
#ifndef MULTISAMPLED
let sample_index = 0u;
Expand Down Expand Up @@ -805,7 +805,7 @@ fn fragment() -> @location(0) vec4<f32> {
#import bevy_pbr::pbr_types as pbr_types
#import bevy_pbr::prepass_utils

#import bevy_pbr::mesh_vertex_output MeshVertexOutput
#import bevy_pbr::mesh_vertex_output VertexOutput
#import bevy_pbr::mesh_bindings mesh
#import bevy_pbr::mesh_view_bindings view, fog, screen_space_ambient_occlusion_texture
#import bevy_pbr::mesh_view_types FOG_MODE_OFF
Expand All @@ -820,7 +820,7 @@ fn fragment() -> @location(0) vec4<f32> {

@fragment
fn fragment(
in: MeshVertexOutput,
in: VertexOutput,
@builtin(front_facing) is_front: bool,
) -> @location(0) vec4<f32> {
var output_color: vec4<f32> = pbr_bindings::material.base_color;
Expand Down Expand Up @@ -986,7 +986,7 @@ fn fragment(
@group(1) @binding(12) var depth_map_sampler: sampler;
#define_import_path bevy_pbr::mesh_vertex_output

struct MeshVertexOutput {
struct VertexOutput {
// this is `clip position` when the struct is used as a vertex stage output
// and `frag coord` when used as a fragment stage input
@builtin(position) position: vec4<f32>,
Expand Down Expand Up @@ -1030,7 +1030,7 @@ struct MeshVertexOutput {
#import bevy_pbr::skinning
#import bevy_pbr::morph
#import bevy_pbr::mesh_bindings mesh
#import bevy_pbr::mesh_vertex_output MeshVertexOutput
#import bevy_pbr::mesh_vertex_output VertexOutput
#import bevy_render::instance_index get_instance_index

struct Vertex {
Expand Down Expand Up @@ -1081,8 +1081,8 @@ fn morph_vertex(vertex_in: Vertex) -> Vertex {
#endif

@vertex
fn vertex(vertex_no_morph: Vertex) -> MeshVertexOutput {
var out: MeshVertexOutput;
fn vertex(vertex_no_morph: Vertex) -> VertexOutput {
var out: VertexOutput;

#ifdef MORPH_TARGETS
var vertex = morph_vertex(vertex_no_morph);
Expand Down Expand Up @@ -1145,7 +1145,7 @@ fn vertex(vertex_no_morph: Vertex) -> MeshVertexOutput {

@fragment
fn fragment(
mesh: MeshVertexOutput,
mesh: VertexOutput,
) -> @location(0) vec4<f32> {
#ifdef VERTEX_COLORS
return mesh.color;
Expand Down Expand Up @@ -2693,7 +2693,7 @@ fn tone_mapping(in: vec4<f32>, color_grading: ColorGrading) -> vec4<f32> {

@group(0) @binding(1) var<uniform> globals: Globals;
#import bevy_sprite::mesh2d_types Mesh2d
#import bevy_sprite::mesh2d_vertex_output MeshVertexOutput
#import bevy_sprite::mesh2d_vertex_output VertexOutput
#import bevy_sprite::mesh2d_view_bindings view

#ifdef TONEMAP_IN_SHADER
Expand All @@ -2713,7 +2713,7 @@ const COLOR_MATERIAL_FLAGS_TEXTURE_BIT: u32 = 1u;

@fragment
fn fragment(
mesh: MeshVertexOutput,
mesh: VertexOutput,
) -> @location(0) vec4<f32> {
var output_color: vec4<f32> = material.color;
#ifdef VERTEX_COLORS
Expand Down
4 changes: 2 additions & 2 deletions assets/Gallery/lines/dotted_line.wgsl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#import bevy_pbr::mesh_view_bindings globals
#import bevy_pbr::mesh_vertex_output MeshVertexOutput
#import bevy_pbr::forward_io::VertexOutput

// If you're passing this in from bevy declare them over there.
struct DottedLineShader {
Expand All @@ -14,7 +14,7 @@ struct DottedLineShader {
var<uniform> material: DottedLineShader;

@fragment
fn fragment(in: MeshVertexOutput) -> @location(0) vec4<f32> {
fn fragment(in: VertexOutput) -> @location(0) vec4<f32> {
var uv: vec2<f32> = (in.uv * 2.0) - 1.0; // normalize uvs to [-1..1]
let t = globals.time; //TODO: animate.
var col: vec4<f32> = vec4(0.0); // Initialize to transparent
Expand Down
4 changes: 2 additions & 2 deletions assets/shaders/WIP-black-hole.wgsl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#import bevy_pbr::mesh_vertex_output MeshVertexOutput
#import bevy_pbr::mesh_vertex_output VertexOutput
#import bevy_pbr::utils PI
#import bevy_sprite::mesh2d_view_bindings globals
#import bevy_render::view View
Expand All @@ -21,7 +21,7 @@ const ANTI_ALIASING: i32 = 2;
// Porting https://www.shadertoy.com/view/tsBXW3 by set111:https://www.shadertoy.com/user/set111
@fragment
fn fragment(
in: MeshVertexOutput
in: VertexOutput
) -> @location(0) vec4<f32> {
let t = globals.time * SPEED;
let resolution = view.viewport.zw;
Expand Down
4 changes: 2 additions & 2 deletions assets/shaders/WIP-total_noob.wgsl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/// This is a port of 'total noob' by dynamite
/// Source material: https://www.shadertoy.com/view/XdlSDs
/// Authour: https://www.shadertoy.com/user/dynamite
#import bevy_pbr::mesh_vertex_output MeshVertexOutput
#import bevy_pbr::forward_io::VertexOutput
#import bevy_sprite::mesh2d_view_bindings globals
#import shadplay::shader_utils::common NEG_HALF_PI, shader_toy_default, rotate2D, TAU, PI

Expand All @@ -13,7 +13,7 @@ const CIRCLE_SIZE:f32 = 0.4;
const BEAM_ROT_SPEED:f32 = 0.2;

@fragment
fn fragment(in: MeshVertexOutput) -> @location(0) vec4<f32> {
fn fragment(in: VertexOutput) -> @location(0) vec4<f32> {
// ensure our uv coords match shadertoy/the-lil-book-of-shaders
var uv = in.uv;
uv *= rotate2D(PI);
Expand Down
4 changes: 2 additions & 2 deletions assets/shaders/electro_cube.wgsl
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#import bevy_pbr::mesh_view_bindings globals view
#import bevy_pbr::mesh_vertex_output MeshVertexOutput
#import bevy_pbr::forward_io::VertexOutput
#import bevy_pbr::utils PI HALF_PI
#import bevy_pbr::mesh_functions

const GRID_RATIO:f32 = 40.;


@fragment
fn fragment(in: MeshVertexOutput) -> @location(0) vec4<f32> {
fn fragment(in: VertexOutput) -> @location(0) vec4<f32> {
let t = globals.time;
var uv = in.uv - 0.5;
var col = vec3(0.0);
Expand Down
4 changes: 2 additions & 2 deletions assets/shaders/fast_dots.wgsl
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#import bevy_pbr::mesh_view_bindings globals
#import bevy_pbr::mesh_vertex_output MeshVertexOutput
#import bevy_pbr::forward_io::VertexOutput

@fragment
fn fragment(in: MeshVertexOutput) -> @location(0) vec4<f32> {
fn fragment(in: VertexOutput) -> @location(0) vec4<f32> {
let uv: vec2<f32> = in.uv;

var m = 0.;
Expand Down
4 changes: 2 additions & 2 deletions assets/shaders/four_to_the_floor.wgsl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#import bevy_pbr::mesh_view_bindings globals
#import bevy_pbr::mesh_vertex_output MeshVertexOutput
#import bevy_pbr::forward_io::VertexOutput

const TAU:f32 = 6.28318530718;

Expand All @@ -11,7 +11,7 @@ fn plot(st: vec2f, pct: f32) -> f32 {
}

@fragment
fn fragment(in: MeshVertexOutput) -> @location(0) vec4<f32> {
fn fragment(in: VertexOutput) -> @location(0) vec4<f32> {
// var uv = (in.uv * 2.0) - 1.0;
var uv = in.uv;
var col = vec3f(0.);
Expand Down
4 changes: 2 additions & 2 deletions assets/shaders/grid_with_colours.wgsl
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#import bevy_pbr::mesh_view_bindings globals view
#import bevy_pbr::mesh_vertex_output MeshVertexOutput
#import bevy_pbr::forward_io::VertexOutput
#import bevy_pbr::utils PI HALF_PI
#import bevy_pbr::mesh_functions

const GRID_RATIO:f32 = 40.;


@fragment
fn fragment(in: MeshVertexOutput) -> @location(0) vec4<f32> {
fn fragment(in: VertexOutput) -> @location(0) vec4<f32> {
let t = globals.time;

var uv = in.uv - 0.5;
Expand Down
Loading

0 comments on commit 5f0f8af

Please sign in to comment.