Skip to content

Commit

Permalink
Merge pull request #6 from papadanku:dev
Browse files Browse the repository at this point in the history
Fix LogC naming
  • Loading branch information
papadanku authored Oct 9, 2024
2 parents 17c0fc6 + 1b62080 commit e00a11e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions shaders/cRaySchism.fx
Original file line number Diff line number Diff line change
Expand Up @@ -391,9 +391,9 @@ void ApplyColorGrading(inout float3 Color)
Color *= PostExposure;

// Apply contrast
Color = CCamera_EncodeLogC(Color);
Color = CColor_EncodeLogC(Color);
Color = (Color - ACEScc_MIDGRAY) * Contrast + ACEScc_MIDGRAY;
Color = CCamera_DecodeLogC(Color);
Color = CColor_DecodeLogC(Color);

// Apply color filter
Color *= _GradeColorFilter;
Expand Down
14 changes: 7 additions & 7 deletions shaders/shared/cColor.fxh
Original file line number Diff line number Diff line change
Expand Up @@ -331,14 +331,14 @@
https://www.arri.com/en/learn-help/learn-help-camera-system/image-science/log-c
*/

struct CCamera_LogC_Constants
struct CColor_LogC_Constants
{
float A, B, C, S, T;
};

CCamera_LogC_Constants CCamera_GetLogC_Constants()
CColor_LogC_Constants CColor_GetLogC_Constants()
{
CCamera_LogC_Constants Output;
CColor_LogC_Constants Output;
const float A = (exp2(18.0) - 16.0) / 117.45;
const float B = (1023.0 - 95.0) / 1023.0;
const float C = 95.0 / 1023.0;
Expand All @@ -353,18 +353,18 @@
}

// LogC4 Curve Encoding Function
float3 CCamera_EncodeLogC(float3 Color)
float3 CColor_EncodeLogC(float3 Color)
{
CCamera_LogC_Constants LogC = CCamera_GetLogC_Constants();
CColor_LogC_Constants LogC = CColor_GetLogC_Constants();
float3 A = (Color - LogC.T) / LogC.S;
float3 B = (log2(LogC.A * Color + 64.0) - 6.0) / 14.0 * LogC.B + LogC.C;
return lerp(B, A, Color < LogC.T);
}

// LogC4 Curve Decoding Function
float3 CCamera_DecodeLogC(float3 Color)
float3 CColor_DecodeLogC(float3 Color)
{
CCamera_LogC_Constants LogC = CCamera_GetLogC_Constants();
CColor_LogC_Constants LogC = CColor_GetLogC_Constants();
float3 A = Color * LogC.S + LogC.T;
float3 P = 14.0 * (Color - LogC.C) / LogC.B + 6.0;
float3 B = (exp2(P) - 64.0) / LogC.A;
Expand Down

0 comments on commit e00a11e

Please sign in to comment.