shadertoy | This is an wgpu backed implementation of shadertoy | Graphics library
kandi X-RAY | shadertoy Summary
kandi X-RAY | shadertoy Summary
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
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of shadertoy
shadertoy Key Features
shadertoy Examples and Code Snippets
Community Discussions
Trending Discussions on shadertoy
QUESTION
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:16QUESTION
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:04They'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.
QUESTION
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:48smoothstep
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:
QUESTION
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:12As 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.
QUESTION
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:47The 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.
QUESTION
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:39Texture 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:
QUESTION
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:24See the following very basic example. You can put the Shadertoy code in the mainImage
function in the fragment shader:
QUESTION
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:49I'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
.
QUESTION
https://www.shadertoy.com/view/4tfXzl
Fragment shader with minor changes:
...ANSWER
Answered 2021-Jul-26 at 14:52Try it like so:
QUESTION
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:03Use 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:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install shadertoy
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
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page