Skip to content

Commit

Permalink
Merge pull request #68 from alphastrata/fix/sed-the-old-meshvertexout…
Browse files Browse the repository at this point in the history
…puts

Update the readmes to reference the new VertexOutput struct, replacin…
  • Loading branch information
alphastrata authored Nov 16, 2023
2 parents 5018048 + 9b28fb1 commit 8a23a58
Show file tree
Hide file tree
Showing 21 changed files with 53 additions and 53 deletions.
4 changes: 2 additions & 2 deletions assets/Gallery/cosmic/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
```rust
/// A shadertoy port of 'Cosmic' https://www.shadertoy.com/view/msjXRK, by Xor.
/// I have sligthly adjusted the colours, and used a smoothstep to improve the contrast too.
#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, rotate2D

Expand All @@ -16,7 +16,7 @@


@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;
uv *= 220.; // equivalent of zooming out.
uv *= rotate2D(NEG_HALF_PI);
Expand Down
4 changes: 2 additions & 2 deletions assets/Gallery/flame/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
/// This is a port of 'Flame' by XT95 https://www.shadertoy.com/view/MdX3zr
/// ***************************** ///

#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 rotate2D, PI

Expand All @@ -18,7 +18,7 @@


@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;
let resolution = view.viewport.zw;
uv *= rotate2D(PI);
Expand Down
6 changes: 3 additions & 3 deletions assets/Gallery/kishimisu-palette/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@

```rust
#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> {
return kishimisu(in);
}

// This is a port/cover of Kimishisu's awesome YT tutotial: https://www.youtube.com/watch?v=f4s1h2YETNY
fn kishimisu(in: MeshVertexOutput) -> vec4<f32> {
fn kishimisu(in: VertexOutput) -> vec4<f32> {
let uv0 = ((in.uv.xy) * 2.0) - 1.0;
var uv = (in.uv.xy) ;

Expand Down
2 changes: 1 addition & 1 deletion assets/Gallery/lines/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ This one turned out really, really well.

```rust
@fragment
fn fragment(in: MeshVertexOutput) -> @location(0) vec4<f32> {
fn fragment(in: VertexOutput) -> @location(0) vec4<f32> {
let uv = (in.uv * 2.0) - 1.0;
var col = vec4f(0.0);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
### fragment

```rust
#import bevy_pbr::mesh_vertex_output MeshVertexOutput
#import bevy_pbr::forward_io::VertexOutput
#import bevy_sprite::mesh2d_view_bindings globals
#import bevy_render::view View
#import bevy_pbr::utils PI
Expand All @@ -20,7 +20,7 @@ const NEG_HALF_PI:f32 = -1.57079632679;

// From #05 in the little-book-of-shaders https://thebookofshaders.com/05/
@fragment
fn fragment(in: MeshVertexOutput) -> @location(0) vec4<f32> {
fn fragment(in: VertexOutput) -> @location(0) vec4<f32> {
let resolution: vec2f = view.viewport.xy;
var uv = in.uv.xy * -2.0 + 1.0; // either do uv.yx and then rotate or just flip em here..
var col = vec3f(0.0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
### fragment

```rust
#import bevy_pbr::mesh_vertex_output MeshVertexOutput
#import bevy_pbr::forward_io::VertexOutput
#import bevy_sprite::mesh2d_view_bindings globals
#import bevy_render::view View
#import bevy_pbr::utils PI
Expand All @@ -20,7 +20,7 @@ const NEG_HALF_PI:f32 = -1.57079632679;

// From #05 in the little-book-of-shaders https://thebookofshaders.com/05/
@fragment
fn fragment(in: MeshVertexOutput) -> @location(0) vec4<f32> {
fn fragment(in: VertexOutput) -> @location(0) vec4<f32> {
let resolution: vec2f = view.viewport.xy;
var uv = in.uv.xy * -2.0 + 1.0; // either do uv.yx and then rotate or just flip em here..
var col = vec3f(0.0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
### fragment

```rust
#import bevy_pbr::mesh_vertex_output MeshVertexOutput
#import bevy_pbr::forward_io::VertexOutput
#import bevy_sprite::mesh2d_view_bindings globals
#import bevy_render::view View
#import bevy_pbr::utils PI
Expand All @@ -20,7 +20,7 @@ const NEG_HALF_PI:f32 = -1.57079632679;

// From #05 in the little-book-of-shaders https://thebookofshaders.com/05/
@fragment
fn fragment(in: MeshVertexOutput) -> @location(0) vec4<f32> {
fn fragment(in: VertexOutput) -> @location(0) vec4<f32> {
let resolution: vec2f = view.viewport.xy;
var uv = in.uv.xy * -2.0 + 1.0; // either do uv.yx and then rotate or just flip em here..
var col = vec3f(0.0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
### fragment

```rust
#import bevy_pbr::mesh_vertex_output MeshVertexOutput
#import bevy_pbr::forward_io::VertexOutput
#import bevy_sprite::mesh2d_view_bindings globals
#import bevy_render::view View
#import bevy_pbr::utils PI
Expand All @@ -20,7 +20,7 @@ const NEG_HALF_PI:f32 = -1.57079632679;

// From #05 in the little-book-of-shaders https://thebookofshaders.com/05/
@fragment
fn fragment(in: MeshVertexOutput) -> @location(0) vec4<f32> {
fn fragment(in: VertexOutput) -> @location(0) vec4<f32> {
let resolution: vec2f = view.viewport.xy;
var uv = in.uv.xy * -2.0 + 1.0; // either do uv.yx and then rotate or just flip em here..
var col = vec3f(0.0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
### fragment

```rust
#import bevy_pbr::mesh_vertex_output MeshVertexOutput
#import bevy_pbr::forward_io::VertexOutput
#import bevy_sprite::mesh2d_view_bindings globals
#import bevy_render::view View
#import bevy_pbr::utils PI
Expand All @@ -20,7 +20,7 @@ const NEG_HALF_PI:f32 = -1.57079632679;

// From #05 in the little-book-of-shaders https://thebookofshaders.com/05/
@fragment
fn fragment(in: MeshVertexOutput) -> @location(0) vec4<f32> {
fn fragment(in: VertexOutput) -> @location(0) vec4<f32> {
let resolution: vec2f = view.viewport.xy;
var uv = in.uv.xy * -2.0 + 1.0; // either do uv.yx and then rotate or just flip em here..
var col = vec3f(0.0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
### fragment

```rust
#import bevy_pbr::mesh_vertex_output MeshVertexOutput
#import bevy_pbr::forward_io::VertexOutput
#import bevy_sprite::mesh2d_view_bindings globals
#import bevy_render::view View
#import bevy_pbr::utils PI
Expand All @@ -20,7 +20,7 @@ const NEG_HALF_PI:f32 = -1.57079632679;

// From #05 in the little-book-of-shaders https://thebookofshaders.com/05/
@fragment
fn fragment(in: MeshVertexOutput) -> @location(0) vec4<f32> {
fn fragment(in: VertexOutput) -> @location(0) vec4<f32> {
let resolution: vec2f = view.viewport.xy;
var uv = in.uv.xy * -2.0 + 1.0; // either do uv.yx and then rotate or just flip em here..
var col = vec3f(0.0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
### fragment

```rust
#import bevy_pbr::mesh_vertex_output MeshVertexOutput
#import bevy_pbr::forward_io::VertexOutput
#import bevy_sprite::mesh2d_view_bindings globals
#import bevy_render::view View
#import bevy_pbr::utils PI
Expand All @@ -20,7 +20,7 @@ const NEG_HALF_PI:f32 = -1.57079632679;

// From #05 in the little-book-of-shaders https://thebookofshaders.com/05/
@fragment
fn fragment(in: MeshVertexOutput) -> @location(0) vec4<f32> {
fn fragment(in: VertexOutput) -> @location(0) vec4<f32> {
let resolution: vec2f = view.viewport.xy;
var uv = in.uv.xy * -2.0 + 1.0; // either do uv.yx and then rotate or just flip em here..
var col = vec3f(0.0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
### fragment

```rust
#import bevy_pbr::mesh_vertex_output MeshVertexOutput
#import bevy_pbr::forward_io::VertexOutput
#import bevy_sprite::mesh2d_view_bindings globals
#import bevy_render::view View
#import bevy_pbr::utils PI
Expand All @@ -20,7 +20,7 @@ const NEG_HALF_PI:f32 = -1.57079632679;

// From #05 in the little-book-of-shaders https://thebookofshaders.com/05/
@fragment
fn fragment(in: MeshVertexOutput) -> @location(0) vec4<f32> {
fn fragment(in: VertexOutput) -> @location(0) vec4<f32> {
let resolution: vec2f = view.viewport.xy;
var uv = in.uv.xy * -2.0 + 1.0; // either do uv.yx and then rotate or just flip em here..
var col = vec3f(0.0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
### fragment

```rust
#import bevy_pbr::mesh_vertex_output MeshVertexOutput
#import bevy_pbr::forward_io::VertexOutput
#import bevy_sprite::mesh2d_view_bindings globals
#import bevy_render::view View
#import bevy_pbr::utils PI
Expand All @@ -20,7 +20,7 @@ const NEG_HALF_PI:f32 = -1.57079632679;

// From #05 in the little-book-of-shaders https://thebookofshaders.com/05/
@fragment
fn fragment(in: MeshVertexOutput) -> @location(0) vec4<f32> {
fn fragment(in: VertexOutput) -> @location(0) vec4<f32> {
let resolution: vec2f = view.viewport.xy;
var uv = in.uv.xy * -2.0 + 1.0; // either do uv.yx and then rotate or just flip em here..
var col = vec3f(0.0);
Expand Down
4 changes: 2 additions & 2 deletions assets/Gallery/sailing-beyond/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
/// This is a port of 'Sailing beyond' by patu https://www.shadertoy.com/view/4t2cR1
/// ***************************** ///

#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 rotate2D, PI, TAU

Expand All @@ -35,7 +35,7 @@ fn d2r(angle: f32) -> f32 {
}

@fragment
fn fragment(in: MeshVertexOutput) -> @location(0) vec4<f32> {
fn fragment(in: VertexOutput) -> @location(0) vec4<f32> {
let resolution = view.viewport.zw;
var uv = (in.uv * 2.0) - 1.0;

Expand Down
4 changes: 2 additions & 2 deletions assets/Gallery/semi-circle-waves/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
//
// This is a port of the Semi-circle Wave Animation by Shane https://www.shadertoy.com/view/cdycRt
//
#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, rotate2D, HALF_PI, PI, TAU

Expand All @@ -20,7 +20,7 @@ const NUM_ITERATIONS: f32 = 14.0;
const LINE_GIRTH:f32 = 0.4;

@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;
let resolution = view.viewport.zw;
let time = globals.time * SPEED;
Expand Down
4 changes: 2 additions & 2 deletions assets/Gallery/smoothstep-colouring-a-2dCircle/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
### fragment

```rust
#import bevy_pbr::mesh_vertex_output MeshVertexOutput
#import bevy_pbr::forward_io::VertexOutput
#import bevy_sprite::mesh2d_view_bindings globals
#import bevy_pbr::utils PI

Expand All @@ -16,7 +16,7 @@ const SPEED:f32 = 1.80;
const SIZE: f32 = 1.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 * 2.0) - 1.0;
let resolution = view.viewport.zw;
Expand Down
4 changes: 2 additions & 2 deletions assets/Gallery/w10/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
### fragment

```rust
#import bevy_pbr::mesh_vertex_output MeshVertexOutput
#import bevy_pbr::forward_io::VertexOutput
#import bevy_sprite::mesh2d_view_bindings globals
#import bevy_render::view View
#import bevy_pbr::utils PI
Expand All @@ -23,7 +23,7 @@ const WBCOL2: vec3f = vec3f(0.15, 0.8, 1.7);

// this is an attempted port of 'w10' https://www.shadertoy.com/view/lllSR2 by https://www.shadertoy.com/user/gyabo
@fragment
fn fragment(in: MeshVertexOutput) -> @location(0) vec4<f32> {
fn fragment(in: VertexOutput) -> @location(0) vec4<f32> {
var frag_color: vec4<f32> = vec4<f32>(0.0080);
var uv = (in.uv.xy * 2.0)- 1.0;
uv.y -= 0.55; // To keep the logo centered.
Expand Down
4 changes: 2 additions & 2 deletions assets/Gallery/warp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
///
/// This is a port of "WARP" by Alro https://www.shadertoy.com/view/ttlGDf
///
#import bevy_pbr::mesh_vertex_output MeshVertexOutput;
#import bevy_pbr::forward_io::VertexOutput;
#import bevy_sprite::mesh2d_view_bindings globals;
#import bevy_render::view View;

Expand All @@ -18,7 +18,7 @@ const STRENGTH: f32 = 0.4; // Controls the strength of the waves
const SPEED: f32 = 0.33333; // Controls the speed at which the waves run

@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;
let resolution: vec2<f32> = view.viewport.zw;
let time: f32 = globals.time * SPEED;
Expand Down
4 changes: 2 additions & 2 deletions assets/Gallery/water-caustics/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
/// I have been unable to find the original.
/// ***************************** ///

#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

Expand All @@ -21,7 +21,7 @@ const MAX_ITER: i32 = 3;
const SPEED:f32 = 1.0;

@fragment
fn fragment(in: MeshVertexOutput) -> @location(0) vec4<f32> {
fn fragment(in: VertexOutput) -> @location(0) vec4<f32> {
let time: f32 = globals.time * 0.5 + 23.0;
var uv: vec2<f32> = in.uv;

Expand Down
12 changes: 6 additions & 6 deletions bevy-shaders-cheatsheet.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ ______________________________________________________________________

```rust
// 'uv's are in the MeshVertexOutput
#import bevy_pbr::mesh_vertex_output MeshVertexOutput
#import bevy_pbr::forward_io::VertexOutput

@fragment
fn fragment(in: MeshVertexOutput) -> vec4<f32> {
fn fragment(in: VertexOutput) -> vec4<f32> {
// usually you'll see them used in your fragment shaders thusly:
let uv = in.uv;
let normalised_uv = (in.uv.xy * 2.0) - 1.0; // If you want 0,0 to be at the 'center' of your Mesh's geometry.
Expand All @@ -55,7 +55,7 @@ You'll usually need this when you go to say, draw a `sdCircle` or other `sdf` sh
@group(0) @binding(0) var<uniform> view: View;

@fragment
fn fragment(in: MeshVertexOutput) -> vec4<f32> {
fn fragment(in: VertexOutput) -> vec4<f32> {
// example, shader-toyesk normalise and account for aspect ratio:
var uv = (in.uv.xy * 2.0) - 1.0;
let resolution = view.viewport.zw;
Expand All @@ -76,12 +76,12 @@ ______________________________________________________________________

```rust
#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;

@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 col = vec3f(0.);

Expand Down Expand Up @@ -116,7 +116,7 @@ ______________________________________________________________________
@group(0) @binding(0) var<uniform> view: View;

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

Expand Down
Loading

0 comments on commit 8a23a58

Please sign in to comment.