diff options
| author | Loic Guegan <manzerbredes@mailbox.org> | 2020-07-09 13:02:31 +0200 |
|---|---|---|
| committer | Loic Guegan <manzerbredes@mailbox.org> | 2020-07-09 13:02:31 +0200 |
| commit | 12829892b262a0c7fcccba9198e5b6b31b2a8015 (patch) | |
| tree | 908152ccc4fd1f4ee2c16b4bb8e0bee215ebdae7 /resources/shaders/julia.frag | |
| parent | aac94e911b0bab8db5cdb5efb8d4d8f2d4072610 (diff) | |
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); +} |
