GithubHelp home page GithubHelp logo

fralonra / wgshadertoy Goto Github PK

View Code? Open in Web Editor NEW
88.0 3.0 6.0 1.21 MB

A WGSL playground inspired by Shadertoy.

License: MIT License

Rust 85.03% Fluent 14.97%
creative-coding egui generative-art shadertoy wgpu wgsl webgpu

wgshadertoy's Introduction

WgShadertoy Logo

WgShadertoy

Flathub AUR MIT

A WGSL playground inspired by Shadertoy.

preview

Installation

Windows

Check out the latest release for a msi installer.

MacOS

Available on MacPorts:

sudo port install wgshadertoy

Linux

Available on Flathub.

Download on Flathub Packaging status

For Arch Linux users, wgshadertoy is also available on AUR:

yay -S wgshadertoy

Wgs format

The application use a binary format wgs to save and load shaders and textures.

It helps to share your shaders amoung people.

You can find examples in wgs's repo.

Limits

Contributing

Credits

  • wgpu for rendering.
  • egui for UI.
  • binrw for binary data read/write.
  • shadertoy for the wonderful vertex shader.

wgshadertoy's People

Contributors

fralonra avatar monsieurlanza avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

wgshadertoy's Issues

Broken app and unsupported usage on macOS

Issues

  • The app installed by dmg is unable to open directly. When open with open -a WgShadertoy, it displayed:

    2023-06-11 10:00:24.163 open[26824:7814785] There was an error parsing the Info.plist for the bundle at URL <0x7f94ec604c80>: NSCocoaErrorDomain - 3840
    2023-06-11 10:00:24.163 open[26824:7814785] There was an error parsing the Info.plist for the bundle at URL <0x7f94ec6064b0>: NSCocoaErrorDomain - 3840
    
  • When try to execute the binary executable file, it crashed again:

    thread 'main' panicked at 'Error in Surface::configure: Validation Error
    
    Caused by:
        Requested usage is not supported
    ', /Users/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wgpu-0.16.1/src/backend/direct.rs:734:18
    

    Seems that wgpu::TextureUsages::COPY_SRC is unsupported at least on this machine.

Env

macOS 10.14.5
Radeon Pro 555X 4 GB
Intel UHD Graphics 630 1536 MB

Missing Fonts

wgshadertoy uses egui as UI framework, which by default can only use a limited number of fonts. This leads to the need to load additional fonts in order to properly display text in certain languages (such as Chinese, Arabic, etc.) in a multilingual environment.

To solve this problem, the current solution adopted by wgshadertoy is to pre-collect common fonts corresponding to the writing systems of various languages and load them at runtime. Since the font list cannot cover all fonts, it may cause characters to not display properly on some devices. If this happens, please provide feedback here, listing the language you use and the fonts available on your system. And a PR is always welcome.

Compute shaders

Thank you for the excellent WGSL shader toy. Is it possible to use the compute shaders and storage buffers in WgShadertoy? Compute shaders are considered an advantage over OpenGL.

By the way, is it possible to directly use Visual Studio Code as the code editor in WgShadertoy? The code editor in WgShadertoy is very limited for code editing, whereas VS Code provides powerful features, such as IntelliSense code completion and WGSL extensions for Naga code validation, among others.

Compiler spits out multiple warnings while compiling

warning: variant `Warning` is never constructed
 --> src/event.rs:8:5
  |
5 | pub enum AppStatus {
  |          --------- variant in this enum
...
8 |     Warning(String),
  |     ^^^^^^^
  |
  = note: `AppStatus` has derived impls for the traits `Debug` and `Clone`, but these are intentionally ignored during dead code analysis
  = note: `#[warn(dead_code)]` on by default

warning: associated items `from_style` and `store_in_memory` are never used
  --> src/ui/highlight/code_theme.rs:17:12
   |
16 | impl CodeTheme {
   | -------------- associated items in this implementation
17 |     pub fn from_style(style: &Style) -> Self {
   |            ^^^^^^^^^^
...
93 |     pub fn store_in_memory(self, ctx: &Context) {
   |            ^^^^^^^^^^^^^^^

warning: methods `editable`, `removable`, `rounding`, and `size` are never used
   --> src/ui/image_upload.rs:174:12
    |
159 | impl<'a> ImageUpload<'a> {
    | ------------------------ methods in this implementation
...
174 |     pub fn editable(mut self, editable: bool) -> Self {
    |            ^^^^^^^^
...
194 |     pub fn removable(mut self, removable: bool) -> Self {
    |            ^^^^^^^^^
...
204 |     pub fn rounding(mut self, rounding: f32) -> Self {
    |            ^^^^^^^^
...
209 |     pub fn size(mut self, size: f32) -> Self {
    |            ^^^^

warning: unused `Result` that must be used
  --> src/event.rs:49:9
   |
49 |         self.inner.send_event(event);
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: this `Result` may be an `Err` variant, which should be handled
   = note: `#[warn(unused_must_use)]` on by default
help: use `let _ = ...` to ignore the resulting value
   |
49 |         let _ = self.inner.send_event(event);
   |         +++++++

warning: unused `TextureHandle` that must be used
  --> src/ui.rs:87:9
   |
87 |         self.textures.remove(index);
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
help: use `let _ = ...` to ignore the resulting value
   |
87 |         let _ = self.textures.remove(index);
   |         +++++++

warning: unused `Result` that must be used
   --> src/ui.rs:232:29
    |
232 | ...                   select_system_locales();
    |                       ^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: this `Result` may be an `Err` variant, which should be handled
help: use `let _ = ...` to ignore the resulting value
    |
232 |                             let _ = select_system_locales();
    |                             +++++++

warning: unused `Result` that must be used
   --> src/ui.rs:244:33
    |
244 | ...                   select_locales(&[language.id]);
    |                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: this `Result` may be an `Err` variant, which should be handled
help: use `let _ = ...` to ignore the resulting value
    |
244 |                                 let _ = select_locales(&[language.id]);
    |                                 +++++++

warning: `wgshadertoy` (bin "wgshadertoy") generated 7 warnings
    Finished dev [unoptimized + debuginfo] target(s) in 52.28s

Compiling using the latest version throws these warnings, while not a detriment to the working order of the project, it will definitely harm confidence in the quality of the app and may turn people off entirely.

They should easy fixes though, as the compiler tells you how to fix most of them

Handle invalid shaders

Issues

Currently invalid shader input would panic at device.create_shader_module:

let fs_module = device.create_shader_module(wgpu::ShaderModuleDescriptor {

Thus makes the whole program to crash.

The approaches I've tried

  • use device.on_uncaptured_error to catch it:
    // device.on_uncaptured_error(|err| {

    However it would continuously generate errors and block the main thread:
[wgpu_core::present] No work has been submitted for this frame
[wgshadertoy::context] Validation Err

Helps needed

I'm glad to hear useful infomation about how to handle invalid shaders. Thanks a lot!

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.