diff options
Diffstat (limited to 'resources/shaders/julia.frag')
| -rw-r--r-- | resources/shaders/julia.frag | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/resources/shaders/julia.frag b/resources/shaders/julia.frag new file mode 100644 index 0000000..12d923b --- /dev/null +++ b/resources/shaders/julia.frag @@ -0,0 +1,48 @@ +// ----- Vertex Shader ----- +#version 410 core + +layout(location = 0) in vec3 position; +uniform mat4 projection; +uniform mat4 model; + +void main(){ + gl_Position = projection * model * vec4(position,1); +} + +// ----- Fragment Shader ----- + +#version 410 core + +uniform vec2 resolution; +uniform float time; + +out vec3 color; + +#define ACCURACY 1000 +#define LIMIT 1000 + +vec2 cmult(vec2 z1,vec2 z2){ + return(vec2(z1.x*z2.x-z1.y*z2.y,z1.x*z2.y+z1.y*z2.x)); +} + +vec2 IsDiverging(vec2 coord){ + vec2 z=vec2(coord.x,coord.y); + int i; + for(i=0;i<ACCURACY;i++){ + z=cmult(z,z)+vec2(-0.3,0.5); + if(length(z) > LIMIT) + break; + + } + return(z); +} + + +void main() +{ + vec2 coord=gl_FragCoord.xy/resolution.xy; + coord-=0.5; + coord/=(time/10); + float d=length(IsDiverging(coord)); + color=vec3(LIMIT/(d*2),0,0); +} |
