CGI/exercise1/glsl/shader.frag
2018-10-21 16:18:27 +02:00

41 lines
No EOL
721 B
GLSL

// This source code is property of the Computer Graphics and Visualization
// chair of the TU Dresden. Do not distribute!
// Copyright (C) CGV TU Dresden - All Rights Reserved
#version 130
in vec4 fragment_color;
in vec2 vertex_pos;
in vec2 julia_position;
out vec4 color;
uniform float m;
uniform vec2 c;
const int i_max = 200;
void main()
{
vec2 z = julia_position * m;
int i;
for(i = 0; i < i_max; i++) {
float x = (z.x * z.x - z.y * z.y) + c.x;
float y = (z.y * z.x + z.x * z.y) + c.y;
if ((x*x + y*y) > 4.0) {
break;
}
z.x = x;
z.y = y;
}
float alpha = 0.0;
if (i < i_max) {
alpha = float(i) / float(i_max);
}
color = vec4(alpha, alpha, alpha, alpha) * 10.0 * fragment_color;
}