Skip to content

Commit

Permalink
Gallery cleanups (#49)
Browse files Browse the repository at this point in the history
* docs: make the previously versioned wgsls into individual md docs per shader in the Gallery

* chore: add a top level toc style thing for the Gallery
  • Loading branch information
alphastrata authored Oct 27, 2023
1 parent 2c6f0df commit 3b5965c
Show file tree
Hide file tree
Showing 62 changed files with 349 additions and 722 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
_shaders
screenshots/*
_deprecated

# Generated by Cargo
# will have compiled files and executables
Expand Down
2 changes: 2 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
- [Contributing Rust](#contributing-rust)

______________________________________________________________________

## What should I do?

- if you're stuck, checkout existing [Issues](https://github.com/alphastrata/shadplay/issues), if it's your first time contributing to an OS project, or you're feeling like some help may be required try stuff tagged with 'good first issue'!

______________________________________________________________________
Expand Down
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ A secondary goal is to flesh out a relatively comprehensive 'port' of existing c

A tertiary goal is to surface the builtins/existing library code that Bevy's codebase provides.

---
______________________________________________________________________

### Why?

> I have found, and continue to find the shader-universe impenetrable, however: I'd rather attempt to write up and document the content I _wish_ I'd been able to find in my first google search, than complain.
---
______________________________________________________________________

## Features

Expand Down Expand Up @@ -73,7 +73,7 @@ The app has some simple hotkeys:
| <kbd>8</kbd> | Select the `texture` at index 8 |
| <kbd>9</kbd> | Select the `texture` at index 9 |

---
______________________________________________________________________

### To run shadplay, you'll need the following:

Expand All @@ -92,21 +92,21 @@ then:

- Then edit the `myshader.wgsl`, or `myshader_2d.wgsl`(if in 2d/shadertoy-mode) file in real time. (<kbd>h</kbd>, and <kbd>t</kbd> to move between 2d/3d).

---
______________________________________________________________________

## Contributing:

See the [guide](./CONTRIBUTING.md)

---
______________________________________________________________________

## TODO:

- \[\] More shader examples (the entirety of shadertoy ported!)
- \[\] drag n drop obj/stl/gltf opening?
- \[\] left/right arrows to swap between shaders from the assets' dir

---
______________________________________________________________________

## Resources:

Expand All @@ -116,7 +116,7 @@ See the [guide](./CONTRIBUTING.md)
- [Shadertoy](https://www.shadertoy.com/)
- [pcf swap by DGriffin91](https://github.com/DGriffin91/bevy_mod_standard_material/tree/pcf)

---
______________________________________________________________________

# Gallery:

Expand Down Expand Up @@ -150,7 +150,7 @@ See the [guide](./CONTRIBUTING.md)
</tr>
</table>

---
______________________________________________________________________

# LICENSE:

Expand Down
21 changes: 21 additions & 0 deletions assets/Gallery/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
| Link | Screenshot |
| -------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------- |
| [cosmic](cosmic/README.md) | <img src="cosmic/screenshot.png" width="256" alt="screenshot"> |
| [water-caustics](water-caustics/README.md) | <img src="water-caustics/screenshot.png" width="256" alt="screenshot"> |
| [flame](flame/README.md) | <img src="flame/screenshot.png" width="256" alt="screenshot"> |
| [smoothstep-colouring-a-2dCircle](smoothstep-colouring-a-2dCircle/README.md) | <img src="smoothstep-colouring-a-2dCircle/screenshot.png" width="256" alt="screenshot"> |
| [lines](lines/README.md) | <img src="lines/screenshot.png" width="256" alt="screenshot"> |
| [semi-circle-waves](semi-circle-waves/README.md) | <img src="semi-circle-waves/screenshot.png" width="256" alt="screenshot"> |
| [playing-with-builtin-maths-functions/21-49-23](playing-with-builtin-maths-functions/21-49-23/README.md) | <img src="playing-with-builtin-maths-functions/21-49-23/screenshot.png" width="256" alt="screenshot"> |
| [playing-with-builtin-maths-functions/21-48-43](playing-with-builtin-maths-functions/21-48-43/README.md) | <img src="playing-with-builtin-maths-functions/21-48-43/screenshot.png" width="256" alt="screenshot"> |
| [playing-with-builtin-maths-functions/21-49-02](playing-with-builtin-maths-functions/21-49-02/README.md) | <img src="playing-with-builtin-maths-functions/21-49-02/screenshot.png" width="256" alt="screenshot"> |
| [playing-with-builtin-maths-functions/21-49-07](playing-with-builtin-maths-functions/21-49-07/README.md) | <img src="playing-with-builtin-maths-functions/21-49-07/screenshot.png" width="256" alt="screenshot"> |
| [playing-with-builtin-maths-functions/21-48-58](playing-with-builtin-maths-functions/21-48-58/README.md) | <img src="playing-with-builtin-maths-functions/21-48-58/screenshot.png" width="256" alt="screenshot"> |
| [playing-with-builtin-maths-functions/21-48-16](playing-with-builtin-maths-functions/21-48-16/README.md) | <img src="playing-with-builtin-maths-functions/21-48-16/screenshot.png" width="256" alt="screenshot"> |
| [playing-with-builtin-maths-functions/21-49-38](playing-with-builtin-maths-functions/21-49-38/README.md) | <img src="playing-with-builtin-maths-functions/21-49-38/screenshot.png" width="256" alt="screenshot"> |
| [playing-with-builtin-maths-functions/21-48-52](playing-with-builtin-maths-functions/21-48-52/README.md) | <img src="playing-with-builtin-maths-functions/21-48-52/screenshot.png" width="256" alt="screenshot"> |
| [playing-with-builtin-maths-functions/21-49-33](playing-with-builtin-maths-functions/21-49-33/README.md) | <img src="playing-with-builtin-maths-functions/21-49-33/screenshot.png" width="256" alt="screenshot"> |
| [kishimisu-palette](kishimisu-palette/README.md) | <img src="kishimisu-palette/screenshot.png" width="256" alt="screenshot"> |
| [sailing-beyond](sailing-beyond/README.md) | <img src="sailing-beyond/screenshot.png" width="256" alt="screenshot"> |
| [warp](warp/README.md) | <img src="warp/screenshot.png" width="256" alt="screenshot"> |
| [w10](w10/README.md) | <img src="w10/screenshot.png" width="256" alt="screenshot"> |
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## cosmic

![photo](screenshot.png)

### fragment

```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
Expand Down Expand Up @@ -48,3 +55,7 @@ fn cosmic(uv: vec2f, r: vec2f) -> vec4f {

return col;
}

```

your comments go here...
File renamed without changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## flame

![photo](screenshot.png)

### fragment

```rust
/// ***************************** ///
/// This is a port of 'Flame' by XT95 https://www.shadertoy.com/view/MdX3zr
/// ***************************** ///
Expand Down Expand Up @@ -76,3 +83,7 @@ fn raymarch(org: vec3<f32>, dir: vec3<f32>) -> vec4<f32> {
return vec4<f32>(p, glow);
}


```

your comments go here...
File renamed without changes
52 changes: 52 additions & 0 deletions assets/Gallery/kishimisu-palette/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
## kishimisu-palette

![photo](screenshot.png)

### fragment

```rust
#import bevy_pbr::mesh_view_bindings globals
#import bevy_pbr::mesh_vertex_output MeshVertexOutput


@fragment
fn fragment(in: MeshVertexOutput) -> @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> {
let uv0 = ((in.uv.xy) * 2.0) - 1.0;
var uv = (in.uv.xy) ;

var output = vec3(0.0);

for (var i = 0.0; i < 1.0; i += 1.0) {
uv = fract((uv * .0982)) - 1.225;

var d = length(uv) * exp(-length(uv0));

var col = palette(length(uv0) + (i * 4.3) + (globals.time * .4));

d = sin(d * 8. + globals.time) / 4.;
d = abs(d);

d = pow(0.01 / d, 1.8);

output += col * d;
}

return vec4<f32>(output, 1.0);
}

fn palette(t: f32) -> vec3<f32> {
let a = vec3<f32>(0.5, 0.5, 0.5);
let b = vec3<f32>(0.5, 0.5, 0.5);
let c = vec3<f32>(1.0, 1.0, 1.0);
let d = vec3<f32>(0.263, 0.416, 0.557);

return a + b * cos(6.28318 * (c * t + d));
}
```

your comments go here...
File renamed without changes.
File renamed without changes.
File renamed without changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## 21-48-16

![photo](screenshot.png)

### fragment

```rust
#import bevy_pbr::mesh_vertex_output MeshVertexOutput
#import bevy_sprite::mesh2d_view_bindings globals
#import bevy_render::view View
Expand Down Expand Up @@ -37,3 +44,7 @@ fn plot(st: vec2f, pct: f32) -> f32 {

return smoothstep(l, pct, st.y) - smoothstep(pct, r, st.y);
}

```

your comments go here...
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## 21-48-43

![photo](screenshot.png)

### fragment

```rust
#import bevy_pbr::mesh_vertex_output MeshVertexOutput
#import bevy_sprite::mesh2d_view_bindings globals
#import bevy_render::view View
Expand Down Expand Up @@ -37,3 +44,7 @@ fn plot(st: vec2f, pct: f32) -> f32 {

return smoothstep(l, pct, st.y) - smoothstep(pct, r, st.y);
}

```

your comments go here...
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## 21-48-52

![photo](screenshot.png)

### fragment

```rust
#import bevy_pbr::mesh_vertex_output MeshVertexOutput
#import bevy_sprite::mesh2d_view_bindings globals
#import bevy_render::view View
Expand Down Expand Up @@ -37,3 +44,7 @@ fn plot(st: vec2f, pct: f32) -> f32 {

return smoothstep(l, pct, st.y) - smoothstep(pct, r, st.y);
}

```

your comments go here...
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## 21-48-58

![photo](screenshot.png)

### fragment

```rust
#import bevy_pbr::mesh_vertex_output MeshVertexOutput
#import bevy_sprite::mesh2d_view_bindings globals
#import bevy_render::view View
Expand Down Expand Up @@ -37,3 +44,7 @@ fn plot(st: vec2f, pct: f32) -> f32 {

return smoothstep(l, pct, st.y) - smoothstep(pct, r, st.y);
}

```

your comments go here...
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## 21-49-02

![photo](screenshot.png)

### fragment

```rust
#import bevy_pbr::mesh_vertex_output MeshVertexOutput
#import bevy_sprite::mesh2d_view_bindings globals
#import bevy_render::view View
Expand Down Expand Up @@ -37,3 +44,7 @@ fn plot(st: vec2f, pct: f32) -> f32 {

return smoothstep(l, pct, st.y) - smoothstep(pct, r, st.y);
}

```

your comments go here...
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## 21-49-07

![photo](screenshot.png)

### fragment

```rust
#import bevy_pbr::mesh_vertex_output MeshVertexOutput
#import bevy_sprite::mesh2d_view_bindings globals
#import bevy_render::view View
Expand Down Expand Up @@ -37,3 +44,7 @@ fn plot(st: vec2f, pct: f32) -> f32 {

return smoothstep(l, pct, st.y) - smoothstep(pct, r, st.y);
}

```

your comments go here...
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## 21-49-23

![photo](screenshot.png)

### fragment

```rust
#import bevy_pbr::mesh_vertex_output MeshVertexOutput
#import bevy_sprite::mesh2d_view_bindings globals
#import bevy_render::view View
Expand Down Expand Up @@ -37,3 +44,7 @@ fn plot(st: vec2f, pct: f32) -> f32 {

return smoothstep(l, pct, st.y) - smoothstep(pct, r, st.y);
}

```

your comments go here...
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## 21-49-33

![photo](screenshot.png)

### fragment

```rust
#import bevy_pbr::mesh_vertex_output MeshVertexOutput
#import bevy_sprite::mesh2d_view_bindings globals
#import bevy_render::view View
Expand Down Expand Up @@ -37,3 +44,7 @@ fn plot(st: vec2f, pct: f32) -> f32 {

return smoothstep(l, pct, st.y) - smoothstep(pct, r, st.y);
}

```

your comments go here...
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## 21-49-38

![photo](screenshot.png)

### fragment

```rust
#import bevy_pbr::mesh_vertex_output MeshVertexOutput
#import bevy_sprite::mesh2d_view_bindings globals
#import bevy_render::view View
Expand Down Expand Up @@ -37,3 +44,7 @@ fn plot(st: vec2f, pct: f32) -> f32 {

return smoothstep(l, pct, st.y) - smoothstep(pct, r, st.y);
}

```

your comments go here...
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## sailing-beyond

![photo](screenshot.png)

### fragment

```rust
/// ***************************** ///
/// This is a port of 'Sailing beyond' by patu https://www.shadertoy.com/view/4t2cR1
/// ***************************** ///
Expand Down Expand Up @@ -235,3 +242,7 @@ fn trace(o: vec3<f32>, d: vec3<f32>) -> Geometry {

return mp;
}

```

your comments go here...
Loading

0 comments on commit 3b5965c

Please sign in to comment.