Code Monkey home page Code Monkey logo

tweak_shader's Introduction

Lib Tweak Shader

Documentation Crates.io

screenshot of use screenshot of use screenshot of use

Description

The tweak shader library provides a wgpu rendering and bookkeeping context for an interative screen shader format, it currently supports fragment and compute shaders. It allows users to create shaders reminiscent of ShaderToy or ISF shaders with any number custom uniforms, textures, buffers, and renderpasses that can be tweaked at runtime. This can be used for composable post processing effects, generative art, reactive visuals and animation, it is intended for inclusion in other wgpu based creative software.

Usage

Run any of the examples under tweak_shader_examples with

cargo run -- --file tweak_shader_examples/<file_name>

To include the library in your own WGPU based project, simply add it to your cargo.toml and use it like so:

 use tweak_shader::RenderContext;
 use wgpu::TextureFormat;

 let src =  r#"
#version 450

layout(location = 0) out vec4 out_color;

#pragma input(float, name="foo", default=0.0, min=0.0, max=1.0)
#pragma input(float, name="bar")
#pragma input(float, name="baz", default=0.5)
layout(set = 0, binding = 0) uniform Inputs {
    float foo;
    float bar;
    float baz;
};

void main()
{
    out_color = vec4(foo, bar, baz, 1.0);
}
"#;

 let format = TextureFormat::Rgba8UnormSrgb;
 let device = // your wgpu::Device here;
 let queue = // your wgpu::Queue here;

 let render_context = RenderContext::new(src, format, &device, &queue).unwrap();

 let input = render_context.get_input_as<f32>("foo")?;
 input = 0.5;

 // congratulations! you now have a 255x255 pink square.
 let output = render_context.render_to_vec(&queue, &device, 255, 255);

See the documentation on creates.io or in the tweak_shader subdirectory for more info.

tweak_shader's People

Contributors

mobile-bungalow avatar

Stargazers

 avatar

Watchers

 avatar

tweak_shader's Issues

Naga Error Messages are really nondescript.

Naga error messages don't chase pointers to the spans of code they are compiling. so they just print numbers instead of expressions. This is terrible UX. There is probably a feature on wgpu or naga that allows for pointer chasing and more descriptive error messages.

Upgrade to WGPU 0.20.2

currently windows 11 will throw tons of access violation errors on anything except the most recent WGPU.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.