3ds Max tutorial: Get accurate colour with linear workflow

| Guides | Technique | Tutorials | 27/09/2012 12:44pm
No Comments

Create physically precise renders every time as Paul Hatton explains the theory behind linear workflow and how to put it into practice

In the 3D visualisation world a common language is emerging to ensure that images and colour are dealt with in a physically accurate way. This common language is often referred to as linear workflow, but it can also be known as physical workflow. Not everyone adopts this type of workflow, but at CADS 3D we choose to work to a linear or physical workflow, which means using a gamma of 1.0.

Working in this way ensures that you keep as much of the beautiful high-range colour information within the image as possible. This means that I throughout the visualisation process you need to keep your image and the maths behind it in the linear or physical 1.0 gamma space. I’ll work through each step, ensuring that you’re maintaining that workflow. I also recommend reading up about this workflow from other sources, because the more you understand, the easier it will become.

I must extend my thanks to several people for helping me to understand this process, especially Matt Gorner from www.pixsim.co.uk for providing the images in Stage 1. I’d also like to thank James Shaw, Matt Guetta, Lon Grohs and Jeff Mottle.

Download the support files for this tutorial here.

 

Video 1: An introduction to gamma and linear workflow

Before I get into the nitty-gritty of the subject, I need to start by answering the question, ‘What is gamma?’. Gamma involves ensuring that images on your monitor are displayed correctly. It’s a way of making sure that all the wonderful maths used to create the light and materials is calculated in a physically accurate manner. It involves your monitor, your 3ds Max settings, your materials, your colours and your lights – it involves your whole workflow. If you want physically accurate results, then it makes sense for you to work in a physically accurate manner throughout the process.

It’s also worth noting at this point that 3D visualisation is essentially an art form. Many of the best 3D artists in the world use some of this linear workflow, but then divert from it at different stages to create the results they’re after. Every person is different, but the benefit of having a strong linear workflow is most evident in a studio setting where you need every team member to be working in a consistent way. You want team members to be able to pick up files part-way through a project and understand what’s going on in them. Here, I’ll begin by looking at some of the theory behind gamma and its effect on your workflow.

00.00 The way monitors display light
Let’s start from the beginning. To display images on a monitor, an input voltage is applied that outputs as light intensity on the screen. Ideally, the input would equal the output in a linear fashion, but in reality it looks something like the image shown on the left, where the output is not the same as the input. A certain amount of energy is lost in the process, creating a drooped light intensity curve. This isn’t great: you need to get that light intensity back because you care about all of that beautiful colour information.

02.03 How and when to correct your output
You need to do something about this lost light intensity. Essentially, you want to bring the relationship between input voltage and screen light intensity back into linear. So how are you going to do this? To bring the light intensity back into linear you need to apply a curve to the input voltage. This curve can be referred to as ‘2.2 gamma’, and you’ll notice from the diagram that it’s a mirror image of your light intensity curve. This 2.2 gamma curve will therefore bring all the input values up from their old position to form your linear curve.

Now that you understand what you need to do to solve the problem of the lost light intensity, you need to know at what point in the process you apply this correction. You might think it’s as easy as applying this 2.2 gamma correction curve right at the end when you save the file out, but it’s not that simple. The textures and colours you’re using to make up your render will have already had gamma corrections baked into them so that they display properly on screen. If you then try to apply the gamma correction curve to everything at the end, your maths will be correct under the hood, but your textures and colours will have had two sets of 2.2 gamma correction applied.

03.32 Sort out your textures and colours
Before you fix the problem of your screen light intensity, you need to reverse the gamma that has previously been applied to your textures and colours. You essentially need to take the textures from 2.2 Gamma (or sRGB) and make them linear again. You do this by applying an inverse gamma curve (calculated as 1.0/2.2). Doing this brings your textures and colours into linear.

With that step completed you can rest assured that both the maths under the hood and the textures and colours that you’re using are all in linear space. You’re in full control of what’s going on. The final step at the end, when you come to render your image, is to bring the image into 2.2 Gamma sRGB. You do this because the light intensity of your screen is lower than it should be.

 

Video 2: How to set up linear workflow in 3ds Max

Now that you’ve covered some of the high-level theory, you need to make sure that 3ds Max is putting it into practice. In essence, 3ds Max must be set to working at 2.2 Gamma, and the textures that you import in from outside the program must also go through the inverse gamma correction discussed in the previous stage. You must know what’s coming in and out of your scene to ensure that your physically accurate values underneath the hood are being maintained. Without this attention to detail, you’ll no doubt get some unexpected and undesired results.

00.00 Set up the system units
For the light and the materials to be calculated in a physically accurate manner you must ensure that your scene is built to real-world measurements. To do this, go to Customize and then to Units Setup. Within this dialog box you can check and set your system units as well as your display units. We usually go for Millimeters on both options, but you can put what you feel most comfortable with depending on what you’re accustomed to.

00.53 3ds Max preference settings
Now you need to tell 3ds Max how to handle the material editor, the way it sees colour, how it brings in files and finally the way it outputs files. To do this, go to Customize and then to Preferences and navigate to the Gamma And LUT tab. For reference, LUT stands for look up table.

To start with, enable Gamma/LUT Correction. Set the Gamma to 2.2. This tells 3ds Max that you’re working with the 2.2 gamma space. This doesn’t tell V-Ray, though – that comes later in the Render Setup and Color Mapping rollout. Then enable Affect Color Selectors and Affect Material Editor. This ensures that the 3ds Max Material Editor is displaying colours and materials correctly.

Next, set Input Gamma to 2.2. You do this because bitmaps such as JPEGs, created with software such as Photoshop, will have the gamma 2.2 baked into them. The problem is that you want to work with them in linear in 1.0. Set it to 2.2 so that 3ds Max knows to apply the correction. As for the Output Gamma, I’d set this to 1.0. This is perfect for ensuring that your output is still in linear space and can be exported as a 16- or 32-bit image. If you want to output to an 8-bit image, such as a JPEG, then you can set this to 2.2 so that the gamma is burnt in.

 

Video 3: How to set up linear workflow in V-Ray

So far I’ve focused on setting up 3ds Max to work in your new linear or physical workflow. Now you need to move on to ensuring V-Ray is set up correctly too. You do this primarily by making sure that the colour mapping you’re using is correct.

It’s important to note that there’s still some variation here in the settings people use. I’ll therefore put forward what our studio uses and will welcome any contact from anyone who does it differently. As there isn’t a universal standard on this, it’s important to keep an open mind and to welcome correction if necessary, so feel free to speak up.

00.00 Color Mapping defaults
If you press [F10] then your Render Setup dialog box will appear. In the V-Ray tab scroll down to the Color Mapping rollout. You’ll notice that by default Type is set to Linear Multiply, the settings are set to 1.0 and the only checkbox selected is Affect Background.

The Type of colour mapping must be Linear Multiply to stay in a linear workflow where the maths and the compositing is correct. (Other types can be used at this stage but it would be deviating from the linear workflow.)

The Linear Multiply mode will simply multiply the final image colours based on their brightness levels. Colour components that are too bright (above 1.0 or 255) will be clipped. Note that this can result in burnt out spots near bright light sources. Make sure Dark Multiplier and Bright Multiplier are set to 1.0. (These are tone mapping multipliers.) These should be kept to 1.0 to maintain the linear workflow.

01.27 Color Mapping gamma
The Gamma parameter enables the user to control the gamma correction for the output image regardless of the colour mapping mode. Note that the value here is the inverse of the one used for the gamma correction colour mapping type. For example, to correct the image for a 2.2 gamma display, you should set this to 2.2.

02.08 Other Color Mapping settings
I don’t have enough room to go through the remaining Color Mapping settings in more detail, but in our linear workflow, we select Affect Background and Don’t Affect Colors (Adaptation Only). These ensure that the colour mapping isn’t applied to the final image, but that V-Ray will proceed with all its calculations as though colour mapping is applied (for example, the noise levels will be corrected accordingly).

 

Video 4: Rendering and saving your finished images

You’ve now got to the stage where you’ve set up all of your materials, lights and cameras; essentially your scene is finished. Everything has been done in linear space, in a physically accurate manner. You have control over everything and every setting is consistently physical.

That just leaves you to render the image and to bring the final image into 2.2 Gamma sRGB. You do this because, if you remember, the light intensity of your screen is lower than it should be and so isn’t displaying correctly on screen. V-Ray enables you to view your rendered image in 2.2 Gamma space without affecting any of the maths behind the scene.

00.00 Enable the V-Ray Frame Buffer
You’ll probably be aware that 3ds Max has a frame buffer that’s used to display your renderings. Well, V-Ray has a separate frame buffer, called the V-Ray Frame Buffer. This gives you some extra settings that are helpful when working with the linear workflow in V-Ray.

To enable the V-Ray frame buffer, press [F10] to bring up the render settings, scroll down to the V-Ray Frame Buffer rollout and make sure the Enable Built-in Frame Buffer checkbox is ticked. Next time you click Render you’ll notice that this new frame buffer appears instead.

00.20 Bring the image into 2.2 Gamma
Once the frame buffer has opened you can see that there are a set of buttons in the bottom left-hand corner. The one that you’re most concerned with is the sRGB button because this displays your render in 2.2 Gamma sRGB space. This enables you to see the image as it really is, without having to worry about losing light intensity. Note that this button simply enables a look up table, which adjusts the colours in the render. It’s not adjusting any of the maths under the hood – it’s purely for viewing purposes.

01.15 Save your image
In 3ds Max, you set the Output Gamma to 1.0. This means that if you save the image it won’t have the 2.2 gamma burnt into it. It will therefore save an image that looks identical to your V-Ray frame buffer, assuming you don’t have the sRGB button selected. If you want to burn the gamma in so that it displays correctly for a client, for example, then you need to click Save, choose JPEG and select the Override radio button in the bottom left of the Save dialog box. Finally, set that to 2.2 and click Save.

This will reduce the render into an 8-bit image, resulting in a certain amount of lost information. If, however, you want to keep all of that information, it makes sense to save the file as an EXR 16-bit image, using your Output Gamma of 1.0. This will ensure that you keep as much data as possible, and you have an image where the gamma isn’t burnt into the image. This provides you with great flexibility when making adjustments in a program such as Photoshop or After Effects.

About the author
Paul Hatton is the 3D team leader at CADS 3D, a design studio based on the east coast in Great Yarmouth, England

 

Check out 20 great examples of print in 3D on our sister site, Creative Bloq.


Posted on Thursday, September 27th, 2012 at 12:44 pm under Guides, Technique, Tutorials. You can subscribe to comments. You can leave a comment, or trackback from your own site.

Tags: ,

Share This Page