Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix reset scripts being outdated/not the same as defaults... #106

Merged
merged 2 commits into from
Feb 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions assets/shaders/myshader.wgsl
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
//!
//! The default 3d Shader.
//!
#import bevy_pbr::forward_io::VertexOutput, FragmentOutput
#import bevy_pbr::mesh_view_bindings::globals
#import bevy_pbr::forward_io::VertexOutput
#import bevy_pbr::mesh_view_bindings::globals;
#import bevy_pbr::utils PI
#import bevy_render::view::View
#import shadplay::shader_utils::common NEG_HALF_PI, shader_toy_default, rotate2D

#import bevy_render::view::View

@group(0) @binding(0) var<uniform> view: View;

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

@fragment
fn fragment(in: VertexOutput) -> @location(0) vec4f {
fn fragment(in: VertexOutput) -> @location(0) vec4<f32> {
// ensure our uv coords match shadertoy/the-lil-book-of-shaders
let texture_uvs = in.uv;
let tex: vec4f = textureSample(texture, texture_sampler, texture_uvs);

let tex: vec4f = textureSample(texture, texture_sampler, texture_uvs); // textureSample is provided by wgsl?
return tex;
// return vec4f(1.0);
}

}
4 changes: 2 additions & 2 deletions assets/shaders/myshader_2d.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
const SPEED:f32 = 1.0;

@fragment
fn fragment(mesh: VertexOutput) -> @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 = mesh.uv;
var uv = in.uv;
uv = (uv * 2.0) - 1.0;
let resolution = view.viewport.zw;
let t = globals.time * SPEED;
Expand Down
7 changes: 4 additions & 3 deletions scripts/reset-2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#import bevy_sprite::mesh2d_view_bindings::globals
#import shadplay::shader_utils::common::{NEG_HALF_PI, shader_toy_default, rotate2D, TWO_PI}
#import bevy_render::view::View
#import bevy_pbr::forward_io::VertexOutput;
#import bevy_sprite::mesh2d_vertex_output::VertexOutput

@group(0) @binding(0) var<uniform> view: View;

Expand All @@ -15,13 +15,14 @@
@fragment
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;
var uv = in.uv;
uv = (uv * 2.0) - 1.0;
let resolution = view.viewport.zw;
let t = globals.time * SPEED;
uv.x *= resolution.x / resolution.y;
uv *= rotate2D(NEG_HALF_PI);

return vec4f(shader_toy_default(t, uv), 1.0);
return vec4f(shader_toy_default(t, uv), 0.3);
}

"""
Expand Down