50 lines
958 B
GLSL
50 lines
958 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;
|
|
|
|
out vec4 color;
|
|
|
|
const int i_max = 200;
|
|
|
|
void main()
|
|
{
|
|
float m = 0.3;
|
|
vec2 c = vec2(0.5, 1.5);
|
|
|
|
vec2 z = vertex_pos * m;
|
|
|
|
int i = 0;
|
|
|
|
for(; 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;
|
|
|
|
/**** Begin of tasks ***
|
|
- 1.2.5
|
|
Implement the pseudo-code for calculating the julia fractal at a point.
|
|
To get the point you can declare a new "in" variable which contains the
|
|
position and just use the X- and Y- value.
|
|
|
|
*** End of tasks ***/
|
|
|
|
} |