Rendering Alien DNA: Building 3D Glowing Helices in Py5
2026/8/5
Translating the biological elegance of DNA into generative art provides a fantastic exercise in 3D geometry and continuous motion. In this project, the goal was to simulate a microscopic view of an "alien" geometric DNA strand spinning slowly in a deep ocean abyss. Rather than aiming for strict scientific accuracy, the aesthetic focuses on glowing, neon nodes and semi-transparent bonds, creating an otherworldly, luminescent vibe.Python and Py5 are the perfect tools to build this structure procedurally. By utilizing simple trigonometric functions paired with organic noise, we can map rigid mathematical spirals into living, breathing art.
Visual and Aesthetic Approach
The animation is set against a dark, deep-sea green background, simulating the lightless depths where bioluminescence thrives. Additive blending (py5.blend_mode(py5.ADD)) is applied to the entire scene. This ensures that as the cyan and magenta spheres (representing the nucleotide backbones) rotate and overlap in 3D space, their colors combine to form intense, glowing hot-spots.The "base pairs" connecting the two strands are drawn as simple geometric lines. However, to give the structure a true sense of volumetric depth without relying on a complex lighting engine, the opacity of these lines and spheres fades dynamically based on their rotational angle relative to the camera. Strands curving into the background naturally dim, while those swinging to the forefront burn brightly.Code and Technical Breakdown
The structure is built within a single loop that stacks base pairs along the Y-axis. The fundamental shape of the double helix relies on calculating coordinates on a circle using math.cos and math.sin.num_pairs = 150
radius = 300
height_step = 20
# Draw helix
for i in range(num_pairs):
y = i * height_step
# Spiral angle based on index and global rotation
theta = i * 0.2 + angle * 2
x1 = math.cos(theta) * radius
z1 = math.sin(theta) * radius
# The opposite strand is offset by exactly PI (180 degrees)
x2 = math.cos(theta + py5.PI) * radius
z2 = math.sin(theta + py5.PI) * radiusIf we stopped here, the helix would look like a perfect, rigid machine part. To make it feel like organic material drifting in fluid, we introduce 1D Perlin noise to continuously modulate the radius.
# 1D noise for organic undulation
n = py5.noise(i * 0.05, py5.frame_count * 0.02) * 100
x1 = math.cos(theta) * (radius + n)
z1 = math.sin(theta) * (radius + n)
x2 = math.cos(theta + py5.PI) * (radius + n)
z2 = math.sin(theta + py5.PI) * (radius + n)By passing both the loop index i (spatial dimension) and the frame_count (time dimension) into py5.noise(), the radius smoothly bulges and contracts, rippling up and down the length of the strand.Finally, we calculate the dynamic depth fading. Since py5.sin(theta) oscillates between -1 and 1 depending on where the coordinate is in its circular path, we can map that directly to the alpha channel.
# Depth based fading
alpha = py5.remap(py5.sin(theta), -1, 1, 100, 255)
# Draw base pair connection
py5.stroke(250, 80, 100, alpha * 0.5)
py5.line(x1, y, z1, x2, y, z2)
# Draw strands
py5.no_stroke()
py5.push_matrix()
py5.translate(x1, y, z1)
py5.fill(180, 90, 100, alpha) # Teal
py5.sphere(15)
py5.pop_matrix()
Conclusion
Creating complex 3D structures often requires less code than one might think. A double helix is ultimately just a sine and cosine wave stretched along an axis. The true artistry comes from the finishing touches—using procedural noise to break up the rigid symmetry, and applying smart, math-driven opacity to fake volumetric lighting. The resulting alien DNA feels both highly structured and wonderfully alive.GitHub: https://github.com/asamiile/py5-media-art/tree/main/sketch/alien_geometric_dna_helix_3d
Purchase assets: Adobe Stock