This is ShaderToy recreated with GLVisualize.jl ,which means its all Julia + OpenGL. It's a nice playground to get started with OpenGL.
just use this little code snipped to make your shader run:
using ShaderToy
shadertoy("path_to_you_shader.frag")
Execute it in the REPL or via some editor. In the shader you only need this:
{{GLSL_VERSION}}
{{SHADERTOY_INPUTS}} //includes shadertoy inputs
void mainImage( out vec4 fragColor, in vec2 fragCoord ) {
vec2 uv = fragCoord.xy / iResolution.xy;
uv = uv * 2.0 - 1.0;
uv.x *= iResolution.x / iResolution.y;
fragColor = vec4(uv,0,1); // write something to fragColor.
//Important: You need also to write to the alpha channel,which is not the case for shadertoy.com
}
The fun part is, that when you run shadertoy
you can edit the shader code in any editor and the changes will be immediately visible.
You can also add arbitrary textures and uniforms like this:
shadertoy("submerged.frag", Dict{Symbol, Any}(
:iChannel0 => Texture(rand(Float32, 64,64), x_repeat=:repeat, minfilter=:linear),
:myuniform => Vec3f0(0,1,0),
:myanimated_uniform => bounce(0f0:0.001f0:50f0) # will bounce between 0 and 50 with a rate of 1/60 seconds
))
{{GLSL_VERSION}}
{{SHADERTOY_INPUTS}} //will include iChannel0
uniform vec3 myuniform;
uniform float myanimated_uniform; //voila, your data
If you migrate shader from ShaderToy, you also need to replace the function texture2D
with texture
.
That should be it, the rest is very similar to the shadertoy api:
It's just more flexible as you can do whatever you want with GLVisualize, GLAbstraction and Reactive.
just execute:
Pkg.clone("https://github.com/SimonDanisch/ShaderToy.jl.git")