shadertoy | This is an wgpu backed implementation of shadertoy | Graphics library

 by   adamnemecek Rust Version: Current License: No License

kandi X-RAY | shadertoy Summary

kandi X-RAY | shadertoy Summary

shadertoy is a Rust library typically used in User Interface, Graphics applications. shadertoy has no bugs, it has no vulnerabilities and it has low support. You can download it from GitHub.

This is an wgpu backed implementation of shadertoy. Edit the file shader.wgsl to change the shader. Shaders are rebuilt when you save shader.wgsl.
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              shadertoy has a low active ecosystem.
              It has 25 star(s) with 3 fork(s). There are 1 watchers for this library.
              OutlinedDot
              It had no major release in the last 6 months.
              There are 1 open issues and 0 have been closed. There are no pull requests.
              It has a neutral sentiment in the developer community.
              The latest version of shadertoy is current.

            kandi-Quality Quality

              shadertoy has 0 bugs and 0 code smells.

            kandi-Security Security

              shadertoy has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
              shadertoy code analysis shows 0 unresolved vulnerabilities.
              There are 0 security hotspots that need review.

            kandi-License License

              shadertoy does not have a standard license declared.
              Check the repository for any license declaration and review the terms closely.
              OutlinedDot
              Without a license, all rights are reserved, and you cannot use the library in your applications.

            kandi-Reuse Reuse

              shadertoy releases are not available. You will need to build from source code and install.

            Top functions reviewed by kandi - BETA

            kandi's functional review helps you automatically verify the functionalities of the libraries and avoid rework.
            Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of shadertoy
            Get all kandi verified functions for this library.

            shadertoy Key Features

            No Key Features are available at this moment for shadertoy.

            shadertoy Examples and Code Snippets

            No Code Snippets are available at this moment for shadertoy.

            Community Discussions

            QUESTION

            How can I project a 2d shader in a 3d object
            Asked 2022-Feb-28 at 22:16

            the title make it looks easy but I'm struggling to get this pie chart shader on my 3d model. For this I'm using three js. here is my code till now:

            index.html:

            ...

            ANSWER

            Answered 2022-Feb-28 at 22:16

            This is how you can do it, modifying a material with .onBeforeCompile():

            Source https://stackoverflow.com/questions/71297772

            QUESTION

            Drawing a circle using smoothstep() with dot() or length() produces different results
            Asked 2021-Dec-31 at 08:28

            Consider the simple shader below (header over to shadertoy.com/new and paste the code to try it out).

            Basically, I'm trying to figure out if it is possible to tweak the dot() version to get the exact same result for these two function calls:

            ...

            ANSWER

            Answered 2021-Dec-31 at 00:04

            They're different because x2 is not linear with respect to x.

            Let's say that x is the radius of the circle. (x/2) is halfway across the circle. Well, (x/2)2 is (x2)/4. This means that when the distance is halfway from the center to the edge, the dot(d, d) version will only act like it is one quarter of the way from the center to the edge.

            Using the square of the distance (what you get with dot) is only valid if you're trying to test if a point is within a circle, not where it is within the circle.

            Source https://stackoverflow.com/questions/70537724

            QUESTION

            smoothstep() returns different values for "identical" arguments
            Asked 2021-Dec-23 at 01:01

            Running a Surface Laptop 3 with Intel® Iris® Plus Graphics (driver version 30.0.101.1191). Perhaps I'm facing a bug in Intel's shader compiler. Though, I have limited experience of shaders in general, so perhaps the behavior below is expected.

            Head over to https://www.shadertoy.com/new and try the shader below. For some reason, defining a float d = 1.0 seems to produce different results compared to a compile-time constant of 1.0.

            ...

            ANSWER

            Answered 2021-Dec-23 at 00:48

            smoothstep requires that the first parameter edge0 is strictly less than the second parameter edge1. The results are undefined when edge0 >= edge1.

            The reason behind this is pretty simple. From the GL docs (https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/smoothstep.xhtml)

            The code looks something like this:

            Source https://stackoverflow.com/questions/70456528

            QUESTION

            TypeError: start_new_game() missing 1 required positional argument: 'max_health'
            Asked 2021-Nov-19 at 22:12

            So I have been trying to figure out why I keep getting this error, even though everything is run from my game_view.py module. Everytime I press the 1 key to start a game and test to see if the players health bar and hit points works, I get this error message. TypeError: start_new_game() missing 1 required positional argument: 'max_health'

            The sad part is, is that it reffers me to the start_view which doesn't have anything to do with anything else but running the start screen so players can choose to play solo or with another player. Below is the game_view and start_view so you guys can see where I'm going wrong. I wanted to test this out so this way I can add other enemies, bosses and power-ups later, but running into this error for the past several days is hindering progress. Anyway, code for both will be below. Thanks in advance for any and all help.

            ...

            ANSWER

            Answered 2021-Nov-19 at 22:12

            As your title says, your start game function requires 2 arguments: player_count and max_healh. And in your code, when using start_new_game, you aren't supplying the max_health argument, thus raising an error.

            Source https://stackoverflow.com/questions/70041418

            QUESTION

            GLSL artefacts when ray marching
            Asked 2021-Nov-15 at 15:07

            In the following shadertoy I illustrate an artefact that occurs when raymarching

            https://www.shadertoy.com/view/stdGDl

            This is my "scene" (see code fragment below). It renders a primitive "tunnel_fragment" which is an SDF (Signed Distance Function), and uses modulo on the coordinates to calculate "infinite" repetitions of these fragments. It then also calculates which disk we are in (odd/even) to displace them.

            I really don't understand why these artefacts occur when the disks (or rings -> see tunnel_fragment, if you remove a comment they become rings instead of disks) present these artefacts when the alternate movement in x direction becomes large.

            These artefacts don't appear when the disk structure moves to the right on its whole, it only appears when the disks alternate and the entire structure becomes more complex.

            What am I doing wrong? It's really boggling me.

            ...

            ANSWER

            Answered 2021-Nov-15 at 14:47

            The problem is illustrated with this diagram:

            When the current disk (based on modulo) is offset by more than the spacing between the disks, then the distance that you calculate is larger than the distance to the next disk. Consequently you risk in over-stepping the next disk.

            To solve this you need to either limit the offset (as said -- no more than the spacing between the disks), or sample odd/even disks separately and min() between them.

            Source https://stackoverflow.com/questions/69976100

            QUESTION

            Apply transformation in a fragment shader
            Asked 2021-Nov-13 at 11:19

            I know that I can perform a transformation(rotation,scale) in the vertex shader. However I wonder if I can do the similar thing in the fragment shader.

            shadertoy.com - transformation_in_fragment_shade

            I tried to apply transformation in fragment shader by multiply the uv but being confused by the result.

            ...

            ANSWER

            Answered 2021-Nov-13 at 10:39

            Texture coordinates are in range [0.0, 1.0]. (0, 0) is the bottom left and (1, 1) is the top right. The texture looks up the texture at a particular coordinate and returns the color from that coordinate. If you multiply the texture coordinates by 2, the coordinates will be in the range [0.0, 2.0]. The coordinates from 1.0 to 2.0 are not on the texture and clamped to 1.0.
            The fract function skips the integral part. For example, 1.5 becomes 0.5. So uv = fract(uv * 2.) maps the coordinates from the interval [0.0, 1.0] to 2 intervals [0.0, 1.0], [0.0, 1.0].
            If you want to zoom in (2x) to the center you need to project the texture between the coordinates (0.25, 0.25) and (0.75, 0.75) in the view:

            Source https://stackoverflow.com/questions/69953181

            QUESTION

            How to run a shader from shadertoy in your js file with webgl and glsl
            Asked 2021-Nov-03 at 17:24

            Im new to programming shaders and i want to create a shader with webgl and glsl. To see how it really works i want to test a shader from shadertoy. But how do you take the code from shadertoy and actually get to run it in a js file ? Do you just need to copy the code from shadertoy into the fragment shader or what. If you have an answer please help me.

            ...

            ANSWER

            Answered 2021-Nov-03 at 17:24

            See the following very basic example. You can put the Shadertoy code in the mainImage function in the fragment shader:

            Source https://stackoverflow.com/questions/69822784

            QUESTION

            Why do WebGL fragment shaders slow down over time on mobile?
            Asked 2021-Jul-30 at 03:49

            I cannot find any WebGL fragment shader that will maintain 60fps in a mobile browser. They will run smoothly at first, but over the course of a few minutes will inexorably slow and stutter.

            Here's a simple example to demonstrate the problem. http://glslsandbox.com/e#74134.2

            Here it is running for a few minutes on iPadOS. https://youtu.be/oVPVER9RCP0

            Are shaders like this simply not an option on mobile devices?

            Update: This apparently only applies to WebGL1 contexts. On websites that use WebGL2, such as ShaderToy, the shaders run smoothly.

            ...

            ANSWER

            Answered 2021-Jul-30 at 03:49

            I've figured it out. As pleup surmised, it was a problem of precision.

            On every single shader I tested, the motion in some way relied on a function that required a precise decimal value time input. As any floating-point value increases, it gets less precise on this scale. So when this happens to the time uniform, it gives the appearance of poor performance.

            So why does this only happen on mobile?

            It's because desktop devices sometimes just ignore the global precision setting and use highp anyway. mediump is not precise enough for a minutes-long time value, but you wouldn't be able to tell on a machine that doesn't use mediump anyway.

            So in the end, the fix is to force the precision of the time value by declaring it as uniform highp float time.

            Source https://stackoverflow.com/questions/68538717

            QUESTION

            How to implement this shadertoy in three.js?
            Asked 2021-Jul-26 at 14:52

            https://www.shadertoy.com/view/4tfXzl

            Fragment shader with minor changes:

            ...

            ANSWER

            Answered 2021-Jul-26 at 14:52

            QUESTION

            GLSL, SDF based Rounding Rectangle
            Asked 2021-Jul-04 at 16:18

            The app is based on PyOpenGL (core profile) and using orthographic projection. I have to draw several different 2d shapes on a quad(2 triangles).

            I have found a really great article on rendering 2d/3d shapes using SDF. The first shape I'm trying is a rounded rectangle with border. This Shadertoy example perfectly fits to my requirement. Here are my two shaders:

            VERTEX SHADER

            ...

            ANSWER

            Answered 2021-Jul-04 at 09:03

            Use a Uniform (rectSize) to to specify the size of the rectangle in pixel. The texture coordinates (tex_coord) need to be in range [0.0, 1.0]. Compute the pixel position in the rectangle (rectSize * tex_coord). Now you can specify the radius and the edge thickness in pixels:

            Source https://stackoverflow.com/questions/68241841

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network

            Vulnerabilities

            No vulnerabilities reported

            Install shadertoy

            You can download it from GitHub.
            Rust is installed and managed by the rustup tool. Rust has a 6-week rapid release process and supports a great number of platforms, so there are many builds of Rust available at any time. Please refer rust-lang.org for more information.

            Support

            For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries
            CLONE
          • HTTPS

            https://github.com/adamnemecek/shadertoy.git

          • CLI

            gh repo clone adamnemecek/shadertoy

          • sshUrl

            git@github.com:adamnemecek/shadertoy.git

          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link

            Explore Related Topics

            Consider Popular Graphics Libraries

            three.js

            by mrdoob

            pixijs

            by pixijs

            pixi.js

            by pixijs

            tfjs

            by tensorflow

            filament

            by google

            Try Top Libraries by adamnemecek

            WebMIDIKit

            by adamnemecekSwift

            zipline

            by adamnemecekSwift

            AnvilKit

            by adamnemecekSwift

            KoreMIDI

            by adamnemecekSwift

            femtovg

            by adamnemecekRust