1
$\begingroup$

EDIT: I know this is a hack. The thing is why this hack works in Compositor and not as a texture?

I ran into an issue when editing OpenColorIO config file and I don't know if this is a bug or I misunderstood something. So I created this minimal example:

Let's say I have an image/texture in the 3D scene to serve as a reference - I want to see this image in the viewport with the original colors, while at the same time I would like to work on the 3D environment and render it in Filmic Log (in this example. Normally Filmic no-Log, but I will change the config file anyway, this is an ilustration).

So, the View Transform is sRGB / Filmic Log.

View Transform

If I load this image in Compositor and assign ALSO "Filmic Log" as its color space, the image is output perfectly intact. However, if I assign this image as a texture, again with Filmic Log colorspace, then there are wrong colors are on the output.

You can see the difference side-by-side here, left half of the parrot is the perfect one from the compositor, right half of the parrot is the washed-out texture.

Compositor

The material is simple Emission shader, the scene is otherwise empty, just camera and plane with texture.

Shader

I thought the textures is converted from preset color space (Filmic Log here) into to reference space (Linear) and then back to Filmic Log on the output, but it seems that something else is happening as well and I don't understand it. Thanks for any explanation! :)

$\endgroup$
5
  • $\begingroup$ Here is the .blend file with the texture, if you are interested in doing your own tests: pastel.cz/temp/color_spaces_test.zip $\endgroup$ Feb 7, 2021 at 15:57
  • $\begingroup$ If your image is not log encoded you should never set it to use log as color space. I presume the image is encoded as sRGB sot that is the only color space you can set it as. The issue is that log and filmic use a much larger dynamic range, while the jpeg you are importing is limited to display referred values. Start by reading the post on this site on filmic blender.stackexchange.com/questions/46825/… $\endgroup$
    – susu
    Feb 7, 2021 at 17:00
  • $\begingroup$ @susu Thank you for the reply! I am aware that what I do is cheating and not a perfect way. The problem is that there is no perfect way (that I know of). So this boils down to: Why Filmic Log texture is different than Filmic Log image in Compositor? This question is basically an extension of a my 6 months old question: blender.stackexchange.com/questions/187846/… $\endgroup$ Feb 7, 2021 at 17:11
  • $\begingroup$ No there is no perfect way, other than using images that are using scene referred values (log encoded or linear EXRs). Images encoded as sRGB are impossible to reverse to linear scene referred values, they can only be linearized to display referred linear. $\endgroup$
    – susu
    Feb 7, 2021 at 17:14
  • $\begingroup$ Nice thread, I missed that one, thanks! I will explore the answers. However, the more I think of it, the more it seems it should be doable. The image could be a random set of pixels and this just says "this is what we should get at the end". And since we know all the color transformations it should be simple to create an inversion of all of them, concatenate them and we get the texture colors we should use. There might be some rounding errors though. $\endgroup$ Feb 7, 2021 at 17:38

1 Answer 1

2
$\begingroup$

Images look correct only if they are displayed on the color space that they were encoded to use, or if the color transform to the display deals with the conversion to a different display or color space.

If your image is not log encoded you should never set it to use log as color space. I presume the image is encoded as sRGB sot that is the only color space you can set it as. The issue is that log and filmic use a much larger dynamic range, while the jpeg you are importing is limited to display referred values. Start by reading the post on this site on filmic

Render with a wider dynamic range in cycles to produce photorealistic looking images

and

How to mix a jpeg background image with a 3D scene generated using Filmic Blender?

By reading that you will realize that there is no perfect way to mix apples and oranges, other than using images that are using scene referred values (log encoded or linear EXRs). Images encoded as sRGB are impossible to reverse to linear scene referred values, they can only be linearized to display referred linear (form 0 to 1).

The problem lies in how display referred images are encoded, besides reversing the gamma curve (trivial issue), the way the highlights and shadows are encoded is already non-linear, as it is something that each individual camera does differentrly, and therefore not reversible to linear values accurately. You can play with curves and even with the ASC-CDL node to try to modify the values, but know that at that point is all hokus-pokus and unscientific as it gets, plus you will quickly run into issues where banding and other quantization errors will appear, particularly in 8bit images. Moreover, jpeg is a terrible format to begin with, and will also break once you start distorting the values that make such compression scheme work, showing macroblocks and fuzzy edges.

Display referred image created on a camera is already taking into consideration the fact that we perceive light in a non linear way, as we see better into the shadows than in the highlights, so those images are created to emulate that and therefore need to skew the way values for shadows and highlights are assigned. There are more bits used for the shadows. If you try to linearize the information you will find that at lot of the information on the highlights is just not there, and any tool will have a hard time inventing what is not there.

$\endgroup$
8
  • $\begingroup$ I appreciate your answer, but now I think we are talking about different things. The texture alone and the means of its obtaining are irrelevant. Let's say instead that I generate a set of random pixels in Blender and I want this exact colors to be on the output after all the render+view transformations. Since Blender knows all the transformations it is applying it should be simple matter to create inversion of those transformations (not the image acquisition/compression transformations) and get the colors that should be used as texture. $\endgroup$ Feb 7, 2021 at 18:16
  • $\begingroup$ It matters when you are using the texture as emission. An image used as texture on a diffuse shader will always be limited to 0 to 1, as the texture deals with albedo, the amount of light reflected, so the final value of each pixel will be dependent on the amount of light and to a great degree the angle of the surface to the camera and the light (fresnel), and after that there is still some subjective factors and artistic intent that can be dealt with "looks". $\endgroup$
    – susu
    Feb 7, 2021 at 18:22
  • $\begingroup$ But images used as emission can (and should) use much larger values their values will depend on the intensity of the emission. but they always will be rolled through some color transform to encode them into display referred values to be displayed on a monitor . $\endgroup$
    – susu
    Feb 7, 2021 at 18:23
  • $\begingroup$ But if your aim is to mix differently encoded imagery in the compositor, know that the compositor is limited in the ways it can interpret information. So mixing display referred and scene referred that are on different scales cannot be done accurately. If you want to remain in sRGB display referred values then set the color management section to use "standard" as view transform and sRGB as display device and the values will match 1=1 $\endgroup$
    – susu
    Feb 7, 2021 at 18:28
  • $\begingroup$ I see where you are heading. So even though I assign "Filmic Log" color space to the texture it will be still limited to that 0 to 1 range? (On the other hand the Compositor works flawlessly with the same Filmic render and texture settings [no need to go to Standard sRGB] and I was even able to add my monitor profile to the mix as described in my answer here: blender.stackexchange.com/questions/187846/… ) $\endgroup$ Feb 7, 2021 at 18:32

Not the answer you're looking for? Browse other questions tagged .