Skip to content

Instantly share code, notes, and snippets.

@Vipitis
Last active October 24, 2023 00:05
Show Gist options
  • Save Vipitis/0981436d889deb4d330768fa5843b9c8 to your computer and use it in GitHub Desktop.
Save Vipitis/0981436d889deb4d330768fa5843b9c8 to your computer and use it in GitHub Desktop.
wgpu-py shadertoy panic
from wgpu.utils.shadertoy import Shadertoy
# shadertoy source: https://www.shadertoy.com/view/dsGBWR
shader_code = """// step 1: a funciton with an inout input and some other return value
float fn(inout float a) {
a += 0.1;
return 0.2;
}
void mainImage( out vec4 fragColor, in vec2 fragCoord )
{
// step 2: first variable that is vec2/vec3 (float works)
vec2 cd = vec2(0.3, 0.4);
// step 3: second variable is assigned to the return value, using first variable as args.
float e = fn(cd.x);
// Output to screen
fragColor = vec4(e);
}
"""
shader = Shadertoy(shader_code, resolution=(800, 450))
if __name__ == "__main__":
shader.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment