Switch for Linear or Gamma Corrected Lighting Output of the PBR Node


would it be possible to include the option to switch between a linear and gamma corrected Lighting-Output of the PBR Node?

Best Regards

1 Like

Adding @PatrickRyan to this one.

Note that summing all the outputs except for lighting will get you the lighting in linear space: the lighting output is simply a shortcut for the sum of all the other outputs converted to gamma space.

Note also that enabling post processing on the scene/material will make the lighting output to be in linear space too, as the gamma conversion will be done in a later stage.

Does that mean that using Post processing in a Scene will alter the behaviour of my PBR Lighting Output?
If so. Does that mean I have to avoid any modification the the light /colors behind the PBR Node
( in a material) if this materail can be used in scenes with and in scenes without Post Processing?

No, because the gamma correction will still be done, but in a later stage, not directly in the PBR shader itself.

1 Like

@Mr_TT, is there a specific problem you are trying to solve with the color space conversion of the PBR node? @Evgeni_Popov’s solution of using either the individual lighting component outputs in linear space vs the lighting output in gamma space is a good starting point if you are doing any other calculations post PBR node. You also have the ability to convert color space right at the fragment out, if you like so you can wait until the end to convert to gamma. Or if you want to make sure your shader is in linear space for any reason, you can enable that as well. But I am curious as to what you are trying to solve so that we can identify if there’s a gap in the tool.

1 Like

Hi Patrick,

thanks a lot for your fast response!

What i want to do is add addional light to the PBR lighting ,which I calculate in a separate node path. In my current case it’s a rimlight and/or Matcap, which i want to add for more stylistic control.

1 Like

@Mr_TT, I understand what you are going for. If you want to add in more operations after the PBRMetallicRoughness node before connecting to the FragmentOutput, such as rim lighting, matcap, or emissive color, I would use the following workflow. Take the individual component outputs from the PBRMetallicRoughness node - i.e. diffuseDir, diffuseInd, specularDir, specularInd, etc. - and sum them before adding in your additional operations. This way they are already in linear space which is preferable for additional operations in your shader.

For your additional operations, you just need to make sure everything is in linear space, but we have controls for that. If you are using a matcap operation and need a texture, you can convert the texture to linear right on the node:

We have both conversion operations on the node so you should be covered for any kind of texture you import. For a color3 or color4, there are also a conversion toggles on the node:

So you should be able to convert everything to linear space for your computations and then switch back at the end using the convert to gamma toggle on the FragmentOutput.

I hope this workflow helps.