Skip to content

Commit

Permalink
Merge pull request #12 from papadanku/dev
Browse files Browse the repository at this point in the history
cColor: Changed lightness changing
  • Loading branch information
papadanku authored Oct 26, 2024
2 parents 7b31d1a + 6d059c4 commit fb9eee0
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 46 deletions.
2 changes: 1 addition & 1 deletion shaders/cLens.fx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
uniform float _Time < source = "timer"; >;

uniform bool _UseTimeSeed <
ui_label = "Enable Time-Based Seed";
ui_label = "Enable Time Seed";
ui_type = "radio";
> = true;

Expand Down
56 changes: 28 additions & 28 deletions shaders/cRaySchism.fx
Original file line number Diff line number Diff line change
Expand Up @@ -99,28 +99,12 @@
> = false;
#endif

uniform float _GradePostExposure <
uniform float _GradeLightness <
ui_category = "Color Grading | Color Adjustments";
ui_label = "Post Exposure";
ui_label = "Post Lightness Bias";
ui_type = "drag";
> = 0.0;

uniform float _GradeContrast <
ui_category = "Color Grading | Color Adjustments";
ui_label = "Contrast";
ui_type = "slider";
ui_min = -1.0;
ui_max = 1.0;
> = 0.0;

uniform float3 _GradeColorFilter <
ui_category = "Color Grading | Color Adjustments";
ui_label = "Color Filter";
ui_type = "color";
ui_min = 0.0;
ui_max = 1.0;
> = 1.0;

uniform float _GradeHueShift <
ui_category = "Color Grading | Color Adjustments";
ui_label = "Hue Shift";
Expand All @@ -137,6 +121,22 @@ uniform float _GradeSaturation <
ui_max = 1.0;
> = 0.0;

uniform float _GradeContrast <
ui_category = "Color Grading | Color Adjustments";
ui_label = "Contrast";
ui_type = "slider";
ui_min = -1.0;
ui_max = 1.0;
> = 0.0;

uniform float3 _GradeColorFilter <
ui_category = "Color Grading | Color Adjustments";
ui_label = "Color Filter";
ui_type = "color";
ui_min = 0.0;
ui_max = 1.0;
> = 1.0;

uniform float _GradeTemperature <
ui_category = "Color Grading | White Balance";
ui_label = "Temperature";
Expand Down Expand Up @@ -198,55 +198,55 @@ uniform float3 _GradeMixBlue <
> = float3(0.0, 0.0, 1.0);

uniform float3 _GradeMidtoneShadowColor <
ui_category = "Color Grading | Shadows Midtones Hightlights";
ui_category = "Color Grading | Shadows, Midtones, Hightlights";
ui_label = "Shadow Color";
ui_type = "color";
ui_min = 0.0;
ui_max = 1.0;
> = float3(1.0, 1.0, 1.0);

uniform float3 _GradeMidtoneColor <
ui_category = "Color Grading | Shadows Midtones Hightlights";
ui_category = "Color Grading | Shadows, Midtones, Hightlights";
ui_label = "Midtone Color";
ui_type = "color";
ui_min = 0.0;
ui_max = 1.0;
> = float3(1.0, 1.0, 1.0);

uniform float3 _GradeMidtoneHighlightColor <
ui_category = "Color Grading | Shadows Midtones Hightlights";
ui_category = "Color Grading | Shadows, Midtones, Hightlights";
ui_label = "Highlight Color";
ui_type = "color";
ui_min = 0.0;
ui_max = 1.0;
> = float3(1.0, 1.0, 1.0);

uniform float _GradeMidtoneShadowStart <
ui_category = "Color Grading | Shadows Midtones Hightlights";
ui_category = "Color Grading | Shadows, Midtones, Hightlights";
ui_label = "Shadows Start";
ui_type = "slider";
ui_min = 0.0;
ui_max = 1.0;
> = 0.0;

uniform float _GradeMidtoneShadowEnd <
ui_category = "Color Grading | Shadows Midtones Hightlights";
ui_category = "Color Grading | Shadows, Midtones, Hightlights";
ui_label = "Shadows End";
ui_type = "slider";
ui_min = 0.0;
ui_max = 1.0;
> = 0.3;

uniform float _GradeMidtoneHighlightStart <
ui_category = "Color Grading | Shadows Midtones Hightlights";
ui_category = "Color Grading | Shadows, Midtones, Hightlights";
ui_label = "Highlights Start";
ui_type = "slider";
ui_min = 0.0;
ui_max = 1.0;
> = 0.55;

uniform float _GradeMidtoneHighlightEnd <
ui_category = "Color Grading | Shadows Midtones Hightlights";
ui_category = "Color Grading | Shadows, Midtones, Hightlights";
ui_label = "Highlights End";
ui_type = "slider";
ui_min = 0.0;
Expand Down Expand Up @@ -499,11 +499,11 @@ float4 PS_Composite(CShade_VS2PS_Quad Input) : SV_TARGET0
// Apply color-grading
CColor_ApplyColorGrading(
BaseColor,
_GradePostExposure,
_GradeContrast,
_GradeColorFilter,
_GradeLightness,
_GradeHueShift,
_GradeSaturation,
_GradeContrast,
_GradeColorFilter,
_GradeTemperature,
_GradeTint,
_GradeShadows,
Expand Down
33 changes: 16 additions & 17 deletions shaders/shared/cColor.fxh
Original file line number Diff line number Diff line change
Expand Up @@ -523,11 +523,11 @@

void CColor_ApplyColorGrading(
inout float3 Color,
float PostExposure, // [0.0, N); default = 0.0
float Contrast, // [-1.0, 1.0); default = 0.0
float3 ColorFilter, // [0.0, 1.0); default = 1.0
float Lightness, // [0.0, N); default = 0.0
float HueShift, // [-180.0, 180.0); default = 0.0
float Saturation, // [-1.0, 1.0); default = 0.0
float Contrast, // [-1.0, 1.0); default = 0.0
float3 ColorFilter, // [0.0, 1.0); default = 1.0
float Temperature, // [-1.0, 1.0); default = 0.0
float Tint, // [-1.0, 1.0); default = 0.0
float3 Shadows, // [0.0, 1.0); default = float3(0.5, 0.5, 0.5)
Expand All @@ -550,28 +550,18 @@

// Convert user-friendly uniform settings
float3x3 ChannelMixMat = float3x3(MixRed, MixGreen, MixBlue);
PostExposure = exp2(PostExposure);
Contrast += 1.0;
HueShift = (HueShift / 360.0) * CMath_GetPi();
Saturation += 1.0;
Temperature /= 10.0;
Tint /= 10.0;

// Apply post exposure
Color *= PostExposure;

// Apply contrast
Color = CColor_EncodeLogC(Color);
Color = (Color - ACEScc_MIDGRAY) * Contrast + ACEScc_MIDGRAY;
Color = CColor_DecodeLogC(Color);
Color = max(Color, 0.0);

// Apply color filter
Color *= ColorFilter;

// Convert RGB to OKLab
Color = CColor_GetOKLABfromRGB(Color);

// Apply lightness bias
Color.x += Lightness;

// Apply temperature shift
Color.z += Temperature;

Expand All @@ -590,6 +580,13 @@
// Convert OKLch to RGB
Color = CColor_GetRGBfromOKLCH(Color);

// Apply color filter
Color *= ColorFilter;

// Apply contrast
Color = CColor_EncodeLogC(Color);
Color = (Color - ACEScc_MIDGRAY) * Contrast + ACEScc_MIDGRAY;
Color = CColor_DecodeLogC(Color);
Color = max(Color, 0.0);

// Apply gamma-space split-toning
Expand All @@ -616,7 +613,9 @@

float3x3 MidtoneColorMatrix = float3x3
(
MidtoneShadowColor, MidtoneColor, MidtoneHightlightColor
MidtoneShadowColor,
MidtoneColor,
MidtoneHightlightColor
);

Color *= mul(MidtoneWeights, MidtoneColorMatrix);
Expand Down

0 comments on commit fb9eee0

Please sign in to comment.