Camera Exposure Controls

Per-Anders Cinema 4D, Tutorials

Now that you can key post effects in release 8 of Cinema 4D we have a whole host of new possibilities that just weren’t possible in previous releases. One of these is the ability to add extra controls to the objects in your scene. In this tutorial I’m going to show you how to control post effects with your objects using Xpresso, specifically simple exposure style controls for camera objects. To extend this we’re going to make our Xpresso network switch to different settings on each of the different cameras we look through.

For the purposes of this tutorial we’re going to use the simplest of setups. Of course your scene is likely to contain a lot more than this, and this Xpresso network is easily modifiable to cover that.

So to start off with make a simple scene such as this one with a camera and a stage object.

The way we will achieve our effect is to make user fields on the Stage Object and Camera’s in our scene. We will take this information into Xpresso and use it to control the post effect. I’ve set up our scene in as simple as possible a fashion so that I’m able to test and see that what I’m doing works, before bringing in more complex geometry.

For interests sake and to make things clearer when I change the settings I added a very basic material to the object of focus in my scene (a cube), I just used the Planet material on it’s default setting, this just make the changes in the post effect clearer and more interesting.

Now we want to add a control to the Stage Object so that we can use Xpresso to control the camera changes and the exposure settings. Choose the Stage Object and in the Attributes manager go to User Data->Add User Data… Change the settings in the pop up window to match these:

Name : Camera
Data Type : Integer
Interface : Integer
Unit : n/a
Min : 0
Max : Unchecked
Step : 1

Then press [OK] to add a User Data control field to the Stage Object named “Camera”

The cameras in our scene will also need User Data fields, after all it would be nice to be able to control the post effects on a camera by camera basis. So this is why we’ve only put in one camera to begin with. It’s much easier to set up the User Data fields on the one camera and then duplicate and rename that camera as many times as we need. That way we won’t repeat adding User Data fields for each and every camera.

Select the Camera object and in the Attributes Manager go to User Data->Add User Data… to add User Data fields, do this three times and set up the attributes in the Add User Data pop up window as follows:

First User Data

Name : Gamma
Data Type : Float
Interface : Float
Unit : Real
Min : 0.1
Max : 10
Step : 0.1

Second User Data

Name : Contrast
Data Type : (Float)
Interface : Float
Unit : Percent
Min : -100%
Max : 100%
Step : 1%

Third User Data

Name : Brightness
Data Type : (Float)
Interface : Float
Unit : Percent
Min : -100%
Max : 100%
Step : 1%

Now you should have three attributes on the Camera Object under the User Data tab of “Gamma”, “Contrast” and “Brightness”, we will use these as our exposure controls as they give us rather more control directly than just an exposure setting. At it’s simplest level changing the brightness of the gamma will give you a similar result to changing exposures, however in conjunction with contrast you will be able to get burnt out effects and much more without too much trouble.

For this to be worthwhile we need to add another camera to our scene at least, so just duplicate the existing Camera Object and rename the two cameras “Camera 1” and “Camera 2” so that we won’t get them mixed up. The duplicated camera will have all of the User Data fields that we added to the first camera, thus saving us the effort of having to replicate the process of adding them.

Now it’s time to start using Xpresso. So select the Stage Object and add an Xpresso Tag by right clicking on it and going New Expression->Xpresso Expression. We will construct the following Xresso network:

To do this start off by dragging the Stage Object from the Object Manager onto the Xpresso workspace twice so we end up with two “Stage” object nodes. Place one to the left and click on the right hand red square on the node to select an output channel. Select User Data->Camera from the drop down list to add this as an output channel. On the other “Stage” object node click on the blue square in the top left of the node to add an input channel to this node, select Object Properties->Camera to add this as the input. The stage objects Camera property allows you to switch between Cameras in a scene.

Right click somewhere on the Xpresso workspace and from the contextual menu select New Node->Xpresso->Logic->Condition and place it between the two “Stage” object nodes as shown. To connect the output from the Stage nodes “Camera” User data field to the Switch input on the Condition node simply click on the red dot next to Camera and drag a line to the blue dot next to Switch. Connect the Output from the Condition node to the Camera input of the second “Stage” Object Node this way too.

Select the Condition node and in the Attributes manager change it’s Data Type to Link.

Next click and drag the first Camera from the Object Manager to the first “Input” field in the Attributes Manager, do the same with the second Camera and put it in the second “Input” field.

If we were to have more Cameras in our scene we would simple click on the blue square in the top left hand corner of the Condition node in the Xpresso workspace and select Input from the drop down to add another input field. Then we’d drag that camera onto the new field.

The condition node takes an input value (in our case the value in the User Data field “Camera” from the Stage Object) and it outputs what ever’s in the input that matches that value. The values start at 0 and go up as high as you want, so it can output many many different things. Here we’re outputting a link to out camera objects, so when our User Data field is set to 0 then the camera we will be looking through is Camera 1, when it’s set to 1 the camera we will be looking through is Camera 2. When animation the way to change between Cameras will be to change the value of our User Data field “Camera” on the stage object, not by animating the normal “Camera” field on the stage object.

Ok so that’s simply set things up so that we can change the Camera using out User Data field, but we still need to set things up so that as that happens the exposure settings change between each camera.

To do we’ll use another Condition node to switch between the User Data fields that we added to the Camera objects. Because there are only three fields and they’re all Floating point types then we can convert the three streams into one Vector stream (which contains three floating point values) and get away with only having to use one Condition node

Start by adding the Camera 1 object to the Xpresso workspace. Add the following outputs User Data->Gamma, User Data->Contrast and User Data->Brightness to the “Camera 1” object node by selecting them from the drop down list that appears when you click on the Red Square on the node. Do exactly the same for Camera 2.

Right click on the Xpresso workspace and add from the contextual menu drop down select the following New Node->Xpresso->Adapter->Reals2Vector. Connect the outputs from the “Camera 1” Object node to the inputs on the Reals2Vector node. This node converts our three Floating point “Real” streams into a single “Vector” stream. Duplicate the Reals2Vector node by [CTRL] Click dragging it, and connect the outputs from “Camera 2” to the duplicate as shown in the diagram.

Add a new Condition node to the Xpresso workspace and in the Attributes Manager change it’s Data Type to “Vector”. Connect the output from the first “Stage” Object node to the “Switch” input of the new Condition node, as we want the Camera User Data field to control the switch here between different cameras exposure settings. Next connect the outputs of the two Reals2Vector nodes to the inputs of the Condition node (Again if we wanted to add more cameras to the scene we’d simply add them in the manner that we added the first two cameras, with the same connections and we’d just add another input to the Condition node to connect the new Reals2Vector nodes output to).

To add the Color correction node to our Xpresso workspace we need to create it using the Set Driver features of R8 as there’s no direct way to do this normally, go to your render settings. In the effects settings click the arrow in the top right hand corner next to and select “Color Correction” from the drop down list to add this post effect to our scene.

Make sure that “Color Correction” is selected from the list and click on the text “Gamma” in the post effects settings. It should highlight with a lighter gray box behind it. Right click on the word Gamma and from the contextual menu choose Animation->Set Driver. Then select the word contrast and right click on it to choose Animation->Set Driven(Absolute). This creates a new Null object with an Xpresso network for our Set Driven attributes. Really it’s not important which attributes are driven or which one drives, provided that an attribute from the “Color Correction” post effect is involved as what we’re doing here is creating an object node that represents “Color Correction”.

Double click on the Xpresso tag on the new Null Object that this created and you should see a network looking not dissimilar to this. Click on one of the Color Correction nodes to select it and hit [CTRL][C] or if you’re using a mac [Apple][C] to copy the node. Double click on the Xpresso tag on the Stage object in the Objects Manager to go back to our Xpresso workspace and paste the Color Correction node in by hitting (PC) [CTRL][V] or (Mac) [Apple][V].

Click on the Color Correction nodes Blue square and from the drop down select all the options (Gamma, Contrast and Brightness) in turn to add them as input channels on the node. Arrange them by clicking and dragging the names so that they match the outputs of the Camera Object nodes (Gamma, Contrast, Brightness). Next right click on the Xpresso workspace to add another node, this time go New Node->Xpresso->Adapter->Vector2Reals, this is exactly the opposite of the Reals2Vector node and converts a vector stream into a set of three individual Floating Point “Real” streams. Connect the output from the second Condition node to the input of the Vector2Reals node and the three outputs from the Vector2Reals node to the inputs of the Color Correction object node. The network is now complete. The final thing to do is to close the Xpresso workspace window and in the object manager select the Null object (probably named Expression) that was created when we made the set driven/driver expression in the render settings, and delete the Null Object and it’s Xpresso Tag.

Now to change cameras simply animate the User Data “Camera” field on the Stage Object and when you make cuts between cameras the exposure settings will change with each camera to what’s set on that cameras User Data settings, and of course the individual exposure settings can be animated on the camera objects over the course of the animation. Here’s a quick sample of each cameras view in my scene.


Default scene, no exposure settings.


Camera 1

Gamma : 0.5

Contrast : -38%

Brightness : 0%

Camera 2

Gamma : 2.6

Contrast : 100%

Brightness : 62%

The C4D file here (ZIP)