Impl julia fractal
This commit is contained in:
parent
db5d8220fc
commit
8e8fb66873
2 changed files with 31 additions and 1 deletions
|
@ -4,12 +4,40 @@
|
|||
#version 130
|
||||
|
||||
in vec4 fragment_color;
|
||||
in vec2 vertex_pos;
|
||||
|
||||
out vec4 color;
|
||||
|
||||
const int i_max = 200;
|
||||
|
||||
void main()
|
||||
{
|
||||
color = fragment_color;
|
||||
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
|
||||
|
|
|
@ -10,9 +10,11 @@ uniform mat4 view;
|
|||
uniform mat4 proj;
|
||||
|
||||
out vec4 fragment_color;
|
||||
out vec2 vertex_pos;
|
||||
|
||||
void main()
|
||||
{
|
||||
vertex_pos = in_position.xy;
|
||||
gl_Position = proj * view * in_position;
|
||||
|
||||
fragment_color = in_color;
|
||||
|
|
Loading…
Reference in a new issue