Bacterium was my first shader of the week at Shadertoy in May 2015. This post describes a breakdown of the effect.
Modeling the Bacteria
The bacteria are distorted capsules that squiggle and rotate as a
function of position and time. Their distance field is a modified version of iq’s capsule/line
function
that uses modular arithmetic to achieve repetition. The squiggling
was done by slightly rotating the space around their local origin.
At a first glance, the overall motion of the bacteria may seem a
little bit random. But that’s just an effect of the combined motion of
the camera and their squiggling. Essentially, the difference in phase
of each capsule is just a constant offset, and you can easily spot that
in the shader if you pay attention.
Modeling the Viruses
The viruses are just spheres with attached cones. They are a good
example of how simple shapes can become an interesting object when
joined together. I applied modular arithmetic in polar coordinates to radially
repeat the cones and blended them with the sphere using iq’s smooth minimum.
Lighting and Shading
I started by applying on the models a cube map that is one of the default textures in Shadertoy.
But instead of using the sample as an albedo value, I made it an interpolation
factor between a green and a yellow color. The result was modulated by the contribution of a simple rim light model.
For conclusion, I thought the model still needed some details and decided to include a bump map. Both my cubeMap and bumpMap methods were based on some of iq’s shaders.