max_iter = 20
    zoom = -0.7

    width, height = 7 * scale, 12 * scale
    depth = u_samples
    du = 1.0 / u_samples
    c = np.quaternion(0.45, -0.3, 0.2, 0.5)

    def source(q):
        val = mandel(q, q, max_iter)
        core = (val <= 0)
        illumination = exp(-0.39 * val)
        illumination = array(
            [0.8 * illumination, 0.5 * illumination, illumination * 0.99]) * 40
        illumination[:, core] = 0
        absorption = array([2.5 * core, 1.5 * core, core]) * 40
        return illumination, absorption

    def generate_subpixel_image(offset_x, offset_y):
        slices = generate_mesh_slices(width, height, depth, 0, 0, 0, 0, zoom,
                                      theta, phi, gamma, beta, offset_x,
                                      offset_y)
        image = illuminate_and_absorb(slices, source,
                                      array([0.35, 0.3, 0.4]) * 0.25, du)
        return image

    image = threaded_anti_alias(generate_subpixel_image, width, height,
                                anti_aliasing)

    imsave("/tmp/transdimensional_doorknob.png", make_picture_frame(image))
Esempio n. 2
0
            absorption = 2.5*exp(-0.3*val)
            absorption[core] = 4
            green += 40*core * dz
            green *= exp(-dz * absorption)

            absorption = 2*exp(-0.35*val)
            absorption[core] = 2.5
            blue += 30*core * dz
            blue *= exp(-dz * absorption)

        lock.acquire()
        result += array([red, green, blue])*0.1
        lock.release()


    ts = []
    offsets_x = np.arange(anti_aliasing) / anti_aliasing * dx
    offsets_y = np.arange(anti_aliasing) / anti_aliasing * dy
    for i in offsets_x:
        for j in offsets_y:
            ts.append(Thread(target=accumulate_subpixels, args=(i, j)))
            ts[-1].start()
    for t in ts:
        t.join()

    result /= anti_aliasing**2

    image = result
    imsave("/tmp/out.png", make_picture_frame(image))