Added egui display
This commit is contained in:
29
shader/mandelia.frag
Normal file
29
shader/mandelia.frag
Normal file
@@ -0,0 +1,29 @@
|
||||
#define cx_mul(a,b) vec2(a.x*b.x-a.y*b.y, a.x*b.y+a.y*b.x)
|
||||
#define cx_mag2(x) dot(x,x)
|
||||
|
||||
#define E 2.718281828
|
||||
|
||||
uniform int maxiter;
|
||||
uniform float escape2;
|
||||
|
||||
in vec2 base;
|
||||
in vec2 delta;
|
||||
|
||||
layout(location = 0) out vec4 diffuseColor;
|
||||
|
||||
void main() {
|
||||
vec2 pos = base;
|
||||
int i;
|
||||
for (i = 0; i < maxiter; i++) {
|
||||
if (cx_mag2(pos) > escape2) {
|
||||
break;
|
||||
}
|
||||
pos = cx_mul(pos, pos) + delta;
|
||||
}
|
||||
float mag = cx_mag2(pos);
|
||||
float sm_color = log(log(mag / 2.)) / log(escape2) * 2;
|
||||
|
||||
float shade = i - 1 + sm_color;
|
||||
// TODO: palette mapping
|
||||
diffuseColor = vec4(shade, shade, shade, 1);
|
||||
}
|
||||
Reference in New Issue
Block a user