Traffic Lights

Posted in Cinema4D Misc on January 27th, 2012 by Tim

Here is a quick post to share a piece of python code that I use in nearly every C4D scene these days. It is really simple and all it does is take the current state of the objects “Visible in Editor” parameter and apply it to the same objects “Visible in Render” parameter.

I use this to hide objects that I don’t want to render. You can of course simply keyframe both parameters, but this means you only need to key the Visible in Editor parameter. Another option is to use a Display tag which will also allow you to keyframe the object visibility. So it is nothing revolutionary that I’m offering (sorry about that ;)

The reason I use this is simply because you have a visual indicator in the Object Manager of the current state of an objects visibility, you don’t get this with the Display Tag unfortunately. Would be kinda cool if the eyeball closed to indicate visibility, similar to PS layer switches.

Anyway here’s the code, simply copy and paste this into a Python Tag and then choose File > Save Tag Preset in the Object Manager. The tag will be there for you every time you need it.

Start copying here…

import c4d
#Welcome to the world of Python

def main():

# get object tag is attached to
obj = op.GetObject()

# get visibility from editor
visibility = obj[c4d.ID_BASEOBJECT_VISIBILITY_EDITOR]

# pass editor visibility to renderer visibility
obj[c4d.ID_BASEOBJECT_VISIBILITY_RENDER] = visibility

…Stop copying here

Thanks to Patrick Goski who actually wrote this little snippet of code.

By the way if you get errors when you copy and paste this, it may be because of the formatting, so make sure you don’t use tabs and that it looks like this..

pythontag

Python Tag

Tags: , , , , , ,

Linear Workflow in Cinema4D and After Effects

Posted in Cinema4D Rendering on February 3rd, 2011 by Tim

Linear Workflow is a relatively new feature for Cinema4D. Before the introduction of Linear Workflow in C4D Release12 it was only possible through the use of third party plugins such as DeGamma by The Third Party.

This article aims to explain the concept behind Linear Workflow (LWF) and in the process look at the correct techniques, file formats and procedures when using LWF in your studio pipeline.

The information in the following post comes from an extremely informative and helpful document which was written by Philip Losch. Philip is one of the mastermind geniuses responsible for Maxon’s Cinema4D.

I’d like to thank Philip for giving me permission to use his material here.

Why LWF?

Today’s monitors are not capable of showing colors how they really are. Let’s take a look at an example:

Gamma

Which of the two colors at the bottom resembles the top one the best?

The surprising answer is: not the right one. The left one should – depending on your monitor – be pretty close.
Why is this surprising? We’ll see that when we zoom into the image:

Gamma Large

The same image scaled up 600%

At the top is a regular pattern of black & white pixels. At the bottom left the grey has a value of 192 (= 75%) and at the bottom right of 128 (= 50%).

Now… shouldn’t an even mix of 0% black and 100% white pixels blend into something like the bottom right grey of 50%?
At least that’s what we were taught in math: (0% + 100%) * 1⁄2 = 50%.

Unfortunately monitors do not work that way. The do not show colors linearly. The center of 0% and 100% is not 50% on a monitor. Monitors display the incoming signal with a so called gamma curve (actually it is even more complicated, but we’ll stick with this easier idea for a moment).

Monitor Gamma Curve

Monitor Gamma Curve

From left to right is your input image color. From bottom to top the actually shown color. So if the image color is 50% gray the real color shown is only about 18%. And to have a 50% gray displayed, you need an image value of about 75% (you can see the red dotted line).

As mentioned above the reality unfortunately is even more complicated. Monitors have so called ‘color profiles’. A color profile is such a curve definition – however with a possible interaction of Red, Green and Blue components. A color profile can do anything – e.g. it can substitue red for 50% green, it can add red and green and assign it blue… As an image looks widely different on devices with different color profiles many image formats allow to embed a colorprofile that ‘records’ under which conditions an image was created.

Most images nowadays are created with a so called sRGB color profile. sRGB roughly looks like the above curve and affects Red, Green and Blue components independently.

But isn’t it a dumb idea to build monitors that don’t show colors linearly and not “how they really are”? The answer is yes and no – unfortunately our human eye sees light intensities in a nonlinear way too and is more susceptible to certain ranges of intensities.

This would not matter as much if we had displays with unlimited color resolution (floating point or ‘HDR’ displays), but monitor technology for the most part is still stuck at 8 bit color depth per channel (or sometimes 10 bit for medical displays).

So now that we know we have to make do with this existing technology, we have to look for a better solution. Actually, there is the possibility to correct this with software – this is where Linear Workflow comes in.

The main problem of renderings created without LWF: lights are overblown and colours mix badly (‘unnaturally’). While the artist can compensate for parts of it by adjusting lights, falloffs, colours etc., this is only possible to a certain extent.

How LWF works

CINEMA 4D is clever enough to offer you a “one button” solution – and by default LWF is automatically activated in new scenes.  If you are wondering where abouts you find this one button solution.  Open the project settings (Control-D or via the Edit Menu).

Project Settings

Look for Linear Workflow in project Settings

It helps to understand how this works internally, especially when you need to use your rendered images in other applications later. Let’s focus on the upper path in the following image (LWF on):

LWF vs Non-LWF

LWF vs Non-LWF

LWF works in three steps:

Step 1: Before rendering all so called ‘assets’ (which are any colors, bitmaps or external references) are transformed from their colorspace (or sRGB colorspace, if they do not have a colorspace assigned) into linear colorspace.

Step 2: The render engine does all its calculations in linear colorspace.

Step 3: The rendered image is transformed from linear colorspace into the colorspace that the user chose for image output. The colorspace –if the image format permits- is embedded into the image.

There is no rule without exception: if your texture or colour is in a bump channel, alpha channel, normal channel or displacement channel the ‘raw’ image data is used (so step 1 is omitted). The reason for this, is that other applications like Z-Brush expect their images to work a certain way and contain direct height information (so e.g. black equals 0m height, white equals 100m and 50% gray equals 50m). You can also think of it this way: all material channels that don’t have anything to do with direct material colors (bump and normal channels change lighting only, alpha cuts out parts of the material and displacement changes the elevation) do not undergo this first conversion step.

Here’s a concrete example of this process:

Step 1: A sphere’s texture is an 8-bit image with no color profile embedded.

As the image has no color profile C4D assumes it is using sRGB (the the most commonly used profile).

Let’s also assume the sphere’s texture is 75% blue.

C4D now transforms this color from sRGB colorspace into linear colorspace. So the value of 75% becomes 50%.

Step 2: C4D does all lighting calculations linearly (and this is why the images will be so much superior – there is no color ‘distortion’ happening anymore).

Let’s assume a pixel is 50% illuminated. So we get 50% * 50% = 25% blue.

Step 3: The calculated image is converted into output color space, which in this example shall be sRGB again.

Our 25% become roughly 56% blue after transformation by applying the sRGB curve.

So the end result for our pixel is 56%, while in traditional rendering it would have been 75% * 50% = 37%.

And so they used LWF and lived happily ever after..

Not so fast! If you thought we only had to deal with !%§!$ hardware I have to disappoint you – as we’re also unfortunately living with !%§!$ software! It will take years and years until most software can properly handle colour profiles, linear workflow etc.

Fortunately Cinema4D, AfterEffects and Photoshop (and several modern compositing applications, for example Nuke) can play nice together – as long as you choose the right settings.

Let’s go through the limitations and problems step by step.

1.) Windows and Mac OS X

The operating systems now have some support for colour profiles. While OS X does a pretty good job evaluating image profiles, Windows 7 works for some image formats, older versions of Windows do not evaluate colour profiles. To view images, it is best use C4D’s Picture Viewer – as it always supports colour profiles.  If you check the View menu, you will see there is an option to view the image with the Colour Profile or without.  Select the Information Tab, and you can see the Colour Profile assigned to the image currently being viewed.

Picture Viewer

Cinema4D Picture Viewer

2.) Image formats

Lots of image formats do not support embedding of color profiles. While this is no problem when you render images to sRGB colourspace (as most applications naturally assume this) it becomes a big problem especially in combination with Multipass renderings and linear workflow where the image colour profiles must be linear.

You can choose your desired output Colour Profile in the Cinema4D Render Settings – Save options.

C4D Save Options

Choose your output Colour Profile in Cinema4D Render - Save dialogue

Always try to choose a format that supports colourspace information, unless

• You render a regular image to sRGB colorspace

• You render Multipasses, but don’t have LWF activated

• You render Multipasses, but know how to adjust the settings in your compositing application

The following image formats do not support colourspace information:

BMP
DPX (8- and 16-bit)
OpenEXR (8- and 16-bit)
IFF
RLA
RPF
TGA
Quicktime xxx (xxx = any format)
AVI Movies
Quicktime Movies

3.) 32-bit images

A specialty applies when you use 32-bit images for in- or output. By definition a 32-bit image is always saved in linear colourspace.  C4D takes care of this for you automatically. If you choose 32-bit output the colour space option for the saved image is automatically disabled and linear colourspace is used.

4.) Photoshop CS 4 and higher

Photoshop reads and writes regular images without any problems. Single-File Multipass images are also handled correctly with one exception: if you render without LWF and output to 32-bit Photoshop can no longer composite the image properly. This comes from the above mentioned limitation that 32-bit image formats do not contain any colour profiles.

5.) AfterEffects CS 4 and higher

The most important setting in AfterEffects that needs to be adjusted is “Linearize Working space” in your project settings.

AE Project Settings

Linearize Working Space - After Effects Project Settings

If you render with LWF in C4D this option needs to be enabled; if you render without LWF in C4D it needs to be disabled.

The reason for this is: Multipasses ‘outsource’ calculations to a compositing application. This only works though if the compositing application does the same mathematical calculations as the render engine, which means the colourspace they’re operating in needs to be identical.

Once you have Colour Management enabled in your After Effects projects, when you select a footage item, it will show you the Colour Profile in the top of the Project Window next to the thumbnail.  You can check here to ensure the profile is being read correctly.

After Effects Project Window

The interpreted Colour Profile visible at the top of AE's Project Window

Try to use 16-bit colour depth or higher to avoid the occurrence of banding – as multipasses sum up multiple layers and then have the result transformed into monitor colourspace 8-bit usually isn’t enough.

For special passes like UVW data, Normals maps etc. activate the setting “Preserve RGB” in the “Interpret Footage” dialog to use the “raw” uncorrected data (not influenced by any color profile).

Interpret Footage

Colour Management inside the AE Interpret Footage dialogue

So there you have it. Linear Workflow with Cinema4D and After Effects in a nutshell. Hopefully this article helps to clear up any questions you may have had regarding LWF and C4D. Once again, huge thanks to Philip Losch for originally preparing this information and allowing me to post it up on helloluxx.

Tags: , , , , , , , , , , , ,

ENVY: C4D Interiors for VRAY & Advanced Render.

Posted in Cinema4D Misc, Cinema4D Rendering on July 18th, 2010 by Tim

I was recently contacted by Envy Studio who asked if I’d make a blog post regarding a new product they’d released for Cinema4D. Being the charitable type and always looking to support independent entrepreneurs, I agreed.   Plus it looks like a pretty good deal to me.  So here it is…

ENVY: C4D INTERIORS FOR ADVANCED RENDER 3 AND VRAY – volume 1.

envy image 01

These products are available as a downloadable version on the ENVY website.

- 10 professional interior scenes
- various light setups
- incorporates Linear Workflow for gamma correct results
- high quality lighting and render settings for optimum results
- 10 scenes for only 40 euros

envy image 02

Tags: , , ,

Reflection Falloff?

Posted in Cinema4D Rendering on December 4th, 2009 by Tim

There was a question over at The Motion Exchange about how to create a falloff type effect with reflections in Cinema4D.

Well there are a few methods to achieve this, some are more accurate than others, but because of this, they are a little more costly with render times.

Reflection Blur

Reflection Blur

The first and perhaps the most obvious way is to use the reflection channel blurriness parameter. This will however increase your render times somewhat if you are after a smooth grain free result. Also it isn’t necessarily the result you may be after.

Reflection with Ambient Occlusion Shader

Reflection with Ambient Occlusion Shader

Another option is to use Ambient Occlusion in the reflection channel as Harry Frank from Graymachine shows here on The Motion Exchange. This is quite a cool trick, but again it can be a little slow to render.

Reflection using Distance Falloff shader

Reflection using Distance Falloff shader

There is also a shader available online that will allow you to achieve this called Distance Falloff. Possibly the least accurate way, but also the quickest. I think a lot of you will find this to be the answer when you want a quick result and have no problem with a little inaccuracy. Lucky for us the shader is written in c.o.f.f.e.e. so it still works fine with r11.5.

The guy who wrote this plugin all those years ago is Matt Savard. You can download the plugin with a simple example scene from here.

Thanks Matt for a really useful shader.

Tags: , , , , , ,