Inverting Textures in OctaneRender for Cinema 4D

Hello children of the internet! Today we’ll bother ourselves with an exceptionally trivial topic – inverting image textures. It’s ridiculous we are wasting time with an article on this topic but you know.. it’s Octane so here we are. In case this sounds boring – chances are you are doing it wrong so leave at your own risk.

Let me start by asking you to import a regular image texture and invert it. For simplicity we’ll just work with a horizontal gradient I made in Photoshop.

8bit Gradient / Photoshop

8bit Gradient / Photoshop

So, show me what you got!

Image Texture - Invert

Image Texture – Invert


Image Texture and Invert Node

Image Texture and Invert Node


Image Texture and Color Correct Node

Image Texture and Color Correct Node


Image Texture and Gradient Node

Image Texture and Gradient Node

Still no.

Okay so what’s the deal here and why is none of the options above a valid, mathematically correct solution? Or a better question – why isn’t something as simple as this solved by the steps above?! First of all, all of those nodes and workflows – they all do the same thing and invert the values in the same way. So the result is always going to be the same. Here is how the gradient looks after the invertion:

Gradient - Before and After

Gradient – Before and After

For all of you that see nothing wrong here – I am sorry I wasted your time. You can move on to something more interesting. Here, I found an awesome looking potato you can take a look at. For everyone else – it may or may not be obvious but the inverted gradient clearly has the dark values squeezed all the way to the right. Tones in the original gradient are far more evenly distributed and you can’t really say any of them is being favored. This becomes a massive issue the second you start inverting grunge / dirt / imperfection / glossy / roughness / bump or whatever else non-color image textures. Is there something wrong with the invert function? No. Is there something wrong with the input data? No. Then what is it?

G to the A to the double M to the A again – GAMMA.

OctaneRender, and probably all other engines out there, perform their functions in a linear world where the gamma defaults to 1. This means all the shading related nodes, among other things, expect linear input in order to deliver correct and predictable output. But, and this is is big BUT, regular bitmap textures cannot be displayed in linear gamma because they would not look correct on our monitor screens. That is why the image node defaults to a gamma of 2.2. So now we have all Octane nodes expecting and working in linear while the image node delivers data in 2.2. That’s quite a pickle. So whatever twisted math happens between the image node and the invert will most certainly fail to deliver the result we expect. So how did OTOY solve this? They didn’t. Why not? Who knows. Will they ever? We hope. Did competitors address this? Yes. Are we fucked? No.

The solution.

Well it’s common sense really. All we need to do is linearize the image texture, perform the invert and then bring the gamma back to 2.2. Easy Peasy. First, I will write down the nodes in the correct order and then I will show you the node editor:

– image node, default gamma 2.2

– color correct node, gamma parameter set to 1/2.2 = approx 0.45 / This will bring the image gamma to 1 so now everyone lives in the same world.
– invert node
– color correct node, gamma parameter set to 1*2.2 = 2.2 / This will bring the image gamma to the default 2.2 so now it looks correct when rendered.

The Solution

The Solution

Gradient - Correct Inversion

Gradient – Correct Inversion

A few things worth mentioning if you don’t mind. You can, of course, override the default gamma of your image texture and set it to 1 – then your invert function will work correctly. However, re-using that very same image node in other channels will be compromised. It is always my recommendation to leave the default settings in the image node and do the gamma correction externally, as demonstrated above. This way you always have the source texture in its default state, ready to be used for whatever else purposes.

Finally, when inverting native Octane generators like Noise, Turbulence, Dirt or any of the rest – you DON’T have to compensate for anything! Their gamma is 1 by default. The whole point of this article is to address the inversion of regular srgb textures. Hope I made that clear enough.

What OTOY could do to simplify all that nonsense is introduce an additional parameter (a checkbox maybe) on the invert and color correct nodes that do this gamma compensation/conversion on demand. Otherwise, we add +3 nodes to the tree each time we need an inverted texture. Not cool. Peace

Hey, hopefully you enjoyed this post. If you did and think that the work I do is somewhat decent, chances are you may want to join the mailing list.
I keep it clean and on topic. No spam. Just saying.