Cinema 4D / BodyPaint 3D Program Documentation Tutorials MoGraph Tutorial
Function available in CINEMA 4D Broadcast, Studio

Creating a String of DNA Using Clones

In this tutorial we will create a string of DNA using clones. Thanks to MoGraph, this type of animation can be created in the blink of an eye. We will also use MoGraph to alternate the color of each string of DNA.

Start by opening the following file:


The first section of DNA has already been built - now all MoGraph has to do is generate clones to create a string of DNA.

Generating the clones

Each sphere already has its own material applied to it. The connecting rod will, however, be colored using a MoGraph shader.

We will begin by using clones to create the string of DNA. Create a Cloner by selecting the command of the same name from the MoGraph menu and make the DNA section a Child of this object. Make sure the Cloner object’s Mode to Linear to make sure the clones are aligned accordingly. Set the Count count to 30. Since we want to generate the clones stepwise will leave the second Mode parameter set to Per Step. The clones should each translate successively by a value of 45 so set the P.Y value to 45.

Of course the clones must also be rotated to form a spiral shape. This can also be done stepwise by, for example, setting the Setp Rotation.H value to -24°. This can also be done using a Step, as we will describe below.

An Effector can automatically be assigned to a specific Cloner object by simply selecting that Cloner object and creating an Effector from the MoGraph menu while this Cloner object is still selected. As mentioned above the Step Effector will be used to rotate our clones. Add a Step Effector and set its Heading Rotation value to -720.

Now that the string of DNA has its spiral shape we will turn our attention to the connecting rod’s material.

Random materials for the clones

We will primarily use MoGraph to apply random materials to the DNA. First, we will create a new material by double-clicking on an empty area of the Material Manager.

Select the Color channel in the material’s Attribute Manager settings and create a Multi Shader by clicking on the arrow next to the Texture parameter and selecting Multi Shader from the menu.

Click on the name of the shader you just created to make its parameters visible in the Attribute Manager. Here you can define colorful gradients for your DNA. The gradients defined here will later be randomly assigned by another Effector. In order for this Effector to be able to correctly access the gradients we will set the Shader Properties’ Mode setting to Color Brightness. A Random Effector will be used to select a shader based on the brightness of random colors.

The image above shows four different sample Gradient shaders (of course you can define any colors you like). Each of these shaders has a gradient consisting of two colors, which can be defined by simply clicking on the color handles and selecting the desired color combination.

Set each Gradient’s Type option to 2D-V to make the gradient run horizontally along the connecting bars.

Assign the material to the Cloner object - not to the Cylinder object. The Effector will then assign the material to the Cylinder object’s Child objects as well.

If we render the scene in the Viewport we will see the material on the clones but it does not vary. This is why we will now add a Random Effector.

To do so, select the Cloner object in the Object Manager and then select Random from the MoGraph menu. This will ensure that the Random Effector is automatically assigned to the selected Cloner object. Switch to the Parameter tab and disable all Transform modes. All we want this Effector to so is affect the color information. To do so, set the Color Mode option to On and enable the Use Alpha/Strength option.

Switch to the Effector tab and select a Random Mode of your choosing (for our sample scene - see link below - we have selected Turbulence).

Select Render View from the Render menu to see how the shader colors are randomly applied to the clones.

You can compare your results with our sample scene by clicking on the following link: