48 lines
791 B
GLSL
48 lines
791 B
GLSL
// ----- 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);
|
|
}
|