Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // T is used for iteration count
- float dist(vec2 p) {
- // returns distance from origin
- return sqrt((p.x * p.x) + (p.y * p.y));
- }
- vec2 cdot(vec2 i, vec2 j) {
- // returns the dot product of
- // two complex numbers, treating
- // them as vectors
- return vec2(i.x * j.x, i.y * j.y);
- }
- vec2 conj(vec2 p) {
- // conjugate of a complex number
- return vec2(p.x, -p.y);
- }
- vec2 cpow(vec2 value, float power)
- {
- // courtesy of ChatGPT
- // does an imaginary to the power of a real.
- float r = length(value);
- float theta = atan(value.y, value.x);
- float r_pow = pow(r, power);
- float theta_pow = theta * power;
- return vec2(r_pow * cos(theta_pow), r_pow * sin(theta_pow));
- }
- vec2 mapping(vec2 z) {
- vec2 c = z;
- vec2 p = vec2(a.x, b.x);
- for (float i = 0.0; i < 100.0; i+=1.0) {
- if(i > t.x) {break;}
- /// modify THIS line ///
- z = cmul(z, z) + c;
- }
- // DISTANCE based coloring
- // (needs variable h, range 0-4)
- //z = cmul(vec2(pow(dist(z)+0.5, 8.0), 0.0), cpow(vec2(0, 1), h.x));
- // INCREASE CONTRAST
- //z = vec2(pow(abs(z.x)+0.5, 8.0)*sign(z.x), pow(abs(z.y)+0.5, 8.0)*sign(z.y));
- return z;
- }
- // personal favorites:
- // z = cdiv(vec2(z.x, c.y), cdiv(cmul(z, z), cdot(c, c)) + cmul(c, p));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement