To transform the Julia set rendering code into producing a moving Rorschach effect, we can modify the formula used to compute z and play with the color mapping to create visuals that resemble the symmetrical, inkblot patterns commonly associated with Rorschach tests. The basic idea of a moving Rorschach effect involves symmetric patterns that evolve over time, which can be achieved through mathematical manipulations.
Given the setup, the change to achieve a Rorschach effect might involve using symmetry and perhaps some oscillations in parameters to animate the effect. We can do this by manipulating z's initialization and the complex_sqr function or how it's applied.
Also, the initialization line ti.init(arch=ti.gpu) is incorrect due to the comment about using the CPU. It should be ti.init(arch=ti.cpu) to use the CPU. However, since you're likely seeking performance, and if GPU is available, keeping ti.init(arch=ti.gpu) is advantageous for graphical computing tasks like rendering images.
Here's an adjusted version of your script, focusing on modifying paint and adjusting the initiation of z to produce a symmetrical pattern, which will hint at a Rorschach test appearance:
import taichi as ti
# Use the GPU for better performance. Change to ti.cpu if GPU is not intended.
ti.init(arch=ti.gpu)
n = 320
pixels = ti.field(dtype=float, shape=(n * 2, n))
@ti.func
def complex_sqr(z):
return ti.Vector([z[0]**2 - z[1]**2, z[1] * z[0] * 2])
@ti.kernel
def paint(t: float):
for i, j in pixels: # Parallelized over all pixels
# Providing symmetry by mirroring coordinates
mirrored_i = n * 2 - 1 - i
sym_i = i if i < n else mirrored_i
c = ti.Vector([ti.sin(t) * 0.2, ti.cos(t) * 0.2])
z = ti.Vector([sym_i / n - 1, j / n - 0.5]) * 2
# Oscillation effect through time-dependent iterations
iterations = 0
limit = 25 + ti.sin(t) * 25 # Dynamic iteration limit for evolution
while z.norm() < 20 and iterations < limit:
z = complex_sqr(z) + c
iterations += 1
# Adjust the color mapping for a more distinct Rorschach effect
pixels[i, j] = iterations * 0.1 % 1.0 # Cycle colors with iterations
gui = ti.GUI("Rorschach Effect", res=(n * 2, n))
for frame in range(10000): # Adjust the iteration count as needed
paint(frame * 0.02) # Adjust the speed of evolution
gui.set_image(pixels)
gui.show()
This code introduces symmetrical patterns and uses time (t) to animate and vary the appearance, aiming to mimic a dynamic Rorschach test. Adjustments made include:
- Symmetry by mirroring pixel coordinates across the vertical axis.
- Time-variant parameter
c and iteration limit for evolving patterns.
- Color mapping that cycles through colors to enhance the visual effect.
Feel free to adjust parameters, especially in the paint kernel, to further refine the visuals and better suit your desired Rorschach effect appearance.
Remember, the essence of achieving a Rorschach-like effect lies in creating symmetrical, evolving images that invite interpretation, so experimentation with the parameters controlling symmetry, color, and evolution over time will be crucial.