Welcome, Guest.
Username: Password: Remember me

TOPIC: Why static constants gives me comp error?

Why static constants gives me comp error? 4 months 3 weeks ago #1

What is wrong with this code? Why it gives me compilation errors like x3011 - initial value must be literal expression ?
// sRGB => XYZ => D65_2_D60 => AP1 => RRT_SAT
static const float3x3 ACESInputMat =
{
    {0.59719, 0.35458, 0.04823},
    {0.07600, 0.90834, 0.01566},
    {0.02840, 0.13383, 0.83777}
};

// ODT_SAT => XYZ => D60_2_D65 => sRGB
static const float3x3 ACESOutputMat =
{
    { 1.60475, -0.53108, -0.07367},
    {-0.10208,  1.10813, -0.00605},
    {-0.00327, -0.07276,  1.07602}
};

float3 RRTAndODTFit(float3 v)
{
    float3 a = v * (v + 0.0245786f) - 0.000090537f;
    float3 b = v * (0.983729f * v + 0.4329510f) + 0.238081f;
    return a / b;
}

float3 ACESFitted(float3 color)
{
    color = mul(ACESInputMat, color);

    // Apply RRT and ODT
    color = RRTAndODTFit(color);

    color = mul(ACESOutputMat, color);

    // Clamp to [0, 1]
    color = saturate(color);

    return color;
}
The administrator has disabled public write access.

Why static constants gives me comp error? 4 months 3 weeks ago #2

ReShade FX does not support the initializer list syntax. Do this instead:
static const float3x3 ACESOutputMat = float3x3(1.60475, ...);
Cheers, crosire =)
The administrator has disabled public write access.

Why static constants gives me comp error? 4 months 2 weeks ago #3

Is it possible to do the same with array?
static const float Weight[11] =
{
	0.082607,
	0.080977,
	0.076276,
	0.069041,
	0.060049,
	0.050187,
	0.040306,
	0.031105,
	0.023066,
	0.016436,
	0.011254
};
GitHub
If you want to buy me a coffee, donate :)
The administrator has disabled public write access.

Why static constants gives me comp error? 4 months 2 weeks ago #4

Nope. The constant folder doesn't understand arrays right now, so constant global arrays are not possible. You can however define a constant array locally inside a function scope (drop the "static" keyword in that case too).
Cheers, crosire =)
Last Edit: 4 months 2 weeks ago by crosire.
The administrator has disabled public write access.