Substance Painter Shader Guide part 2. – Adding to custom structure.

By implementing Alexa LogC converters (El 1000) inside the Substance Painter Shader, we will learn how to build a structure and directly declare the data type using the structure.

Usually, you can think of LogC as Alexa LogC.

Alexa Color Processing documents define:

Logarithmic Encoded Data
Log C (film matrix off)
The Log C curve was first introduced with the ARRIFLEX D-20 camera. It’s an encoding with a gray-scale characteristic similar to a scan from negative film.
Because of the fundamental differences between digital cameras and negatives, the color characteristics remain different, though.
The Log C curve is depicted below. You see that the relation between exposure measured in stops and the signal is linear (straight) over a wide range.
The slope of this part of the curve is called gamma. You see also the toe at the bottom of the curve. The toe occurs because the sensor can not see low light levels with the same quantization as higher levels.
The overall shape of the curve is similar to the exposure curves of film negatives.

In fact, this post is not intended to very deeper into LogC.
For a deeper understanding based on the above, take a look at the pdf file above.
Let’s see if we can add a shader that converts linear spatial information to LogC space in Substance Painter again.

There are five LogC parameters.
You need 7 parameter values, Cut and a to f.
Let’s define this as a structure.

//-------- LogC Color Conversion --------------------------------------//
//: param custom { "default": false, "label": "LogC" }
uniform bool b_logC;

struct ParamsLogC
    float cut;
    float a, b, c, d, e, f;

We defined a variable of type Bool as b_logC, and added a: param custom and bound it in a pair.
You can now turn it on and off in the shader inspector.
Let’s create a user-defined data type defined with a specific constant.

const ParamsLogC LogC =
            0.011361, // cut
            5.555556, // a
            0.047996, // b
            0.244161, // c
            0.386036, // d
            5.301883, // e
            0.092819  // f

ParamsLogC structure was used as data type.
The log10 () function is used for the final transformation calculation, but there is no log10 () math function in the Substance Painter shader library.
Let’s make it yourself.

float log10(float x)
  float o;
  o = (1 / log(10)) * log(x);
  return o;

Create a LinearToLogC_Precise () function.
This part referred to ConvertToLog.shader of Unity3D URP.

float LinearToLogC_Precise(float x)
    float o;
    if (x > LogC.cut)
        o = LogC.c * log10(LogC.a * x + LogC.b) + LogC.d;
        o = LogC.e * x + LogC.f;
    return o;

Let’s apply it to diffColor.

  { = vec3(LinearToLogC_Precise(diffColor.x), LinearToLogC_Precise(diffColor.y) ,  LinearToLogC_Precise(diffColor.z));

logC off.
LogC on.

Related Post.

Substance Painter Shader Guide part 2. – Adding to custom structure.”에 대한 1개의 생각

댓글 남기기

아래 항목을 채우거나 오른쪽 아이콘 중 하나를 클릭하여 로그 인 하세요: 로고

WordPress.com의 계정을 사용하여 댓글을 남깁니다. 로그아웃 /  변경 )

Twitter 사진

Twitter의 계정을 사용하여 댓글을 남깁니다. 로그아웃 /  변경 )

Facebook 사진

Facebook의 계정을 사용하여 댓글을 남깁니다. 로그아웃 /  변경 )

%s에 연결하는 중