Skip to content

Commit 6344b55

Browse files
authored
Fix reset scripts being outdated/not the same as defaults... (#106)
1 parent 4185311 commit 6344b55

File tree

3 files changed

+16
-13
lines changed

3 files changed

+16
-13
lines changed

assets/shaders/myshader.wgsl

+10-8
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
//!
22
//! The default 3d Shader.
33
//!
4-
#import bevy_pbr::forward_io::VertexOutput, FragmentOutput
5-
#import bevy_pbr::mesh_view_bindings::globals
4+
#import bevy_pbr::forward_io::VertexOutput
5+
#import bevy_pbr::mesh_view_bindings::globals;
66
#import bevy_pbr::utils PI
7-
#import bevy_render::view::View
87
#import shadplay::shader_utils::common NEG_HALF_PI, shader_toy_default, rotate2D
9-
8+
#import bevy_render::view::View
9+
1010
@group(0) @binding(0) var<uniform> view: View;
1111

1212
@group(2) @binding(100)var<uniform> color: vec4f;
@@ -16,9 +16,11 @@
1616
const SPEED:f32 = 1.0;
1717

1818
@fragment
19-
fn fragment(in: VertexOutput) -> @location(0) vec4f {
19+
fn fragment(in: VertexOutput) -> @location(0) vec4<f32> {
20+
// ensure our uv coords match shadertoy/the-lil-book-of-shaders
2021
let texture_uvs = in.uv;
21-
let tex: vec4f = textureSample(texture, texture_sampler, texture_uvs);
22+
23+
let tex: vec4f = textureSample(texture, texture_sampler, texture_uvs); // textureSample is provided by wgsl?
2224
return tex;
23-
// return vec4f(1.0);
24-
}
25+
26+
}

assets/shaders/myshader_2d.wgsl

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313
const SPEED:f32 = 1.0;
1414

1515
@fragment
16-
fn fragment(mesh: VertexOutput) -> @location(0) vec4<f32> {
16+
fn fragment(in: VertexOutput) -> @location(0) vec4<f32> {
1717
// ensure our uv coords match shadertoy/the-lil-book-of-shaders
18-
var uv = mesh.uv;
18+
var uv = in.uv;
1919
uv = (uv * 2.0) - 1.0;
2020
let resolution = view.viewport.zw;
2121
let t = globals.time * SPEED;

scripts/reset-2d.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#import bevy_sprite::mesh2d_view_bindings::globals
77
#import shadplay::shader_utils::common::{NEG_HALF_PI, shader_toy_default, rotate2D, TWO_PI}
88
#import bevy_render::view::View
9-
#import bevy_pbr::forward_io::VertexOutput;
9+
#import bevy_sprite::mesh2d_vertex_output::VertexOutput
1010
1111
@group(0) @binding(0) var<uniform> view: View;
1212
@@ -15,13 +15,14 @@
1515
@fragment
1616
fn fragment(in: VertexOutput) -> @location(0) vec4<f32> {
1717
// ensure our uv coords match shadertoy/the-lil-book-of-shaders
18-
var uv = (in.uv * 2.0) - 1.0;
18+
var uv = in.uv;
19+
uv = (uv * 2.0) - 1.0;
1920
let resolution = view.viewport.zw;
2021
let t = globals.time * SPEED;
2122
uv.x *= resolution.x / resolution.y;
2223
uv *= rotate2D(NEG_HALF_PI);
2324
24-
return vec4f(shader_toy_default(t, uv), 1.0);
25+
return vec4f(shader_toy_default(t, uv), 0.3);
2526
}
2627
2728
"""

0 commit comments

Comments
 (0)