Skip to content

Commit

Permalink
cAutoExposureBloom: Make grading configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
papadanku committed Jan 13, 2025
1 parent 03a650e commit b796281
Showing 1 changed file with 185 additions and 177 deletions.
362 changes: 185 additions & 177 deletions shaders/cAutoExposureBloom.fx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
#define ENABLE_AUTOEXPOSURE 1
#endif

#ifndef ENABLE_GRADING
#define ENABLE_GRADING 1
#endif

// Bloom-specific settings
#if ENABLE_BLOOM
uniform int _BloomRenderMode <
Expand Down Expand Up @@ -91,159 +95,161 @@
> = false;
#endif

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

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

uniform float _GradeHueShift <
ui_category = "Color Grading | Color Adjustments";
ui_label = "Hue";
ui_type = "slider";
ui_min = -1.0;
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";
ui_type = "slider";
ui_min = -1.0;
ui_max = 1.0;
> = 0.0;

uniform float _GradeTint <
ui_category = "Color Grading | White Balance";
ui_label = "Tint";
ui_type = "slider";
ui_min = -1.0;
ui_max = 1.0;
> = 0.0;

uniform float3 _GradeShadows <
ui_category = "Color Grading | Split Toning";
ui_label = "Shadows";
ui_type = "color";
> = float3(0.5, 0.5, 0.5);

uniform float3 _GradeHighLights <
ui_category = "Color Grading | Split Toning";
ui_label = "Highlights";
ui_type = "color";
> = float3(0.5, 0.5, 0.5);

uniform float _GradeBalance <
ui_category = "Color Grading | Split Toning";
ui_label = "Balance";
ui_type = "slider";
ui_min = -1.0;
ui_max = 1.0;
> = 0.0;

uniform float3 _GradeMixRed <
ui_category = "Color Grading | Channel Mixer";
ui_label = "Red";
ui_type = "color";
ui_min = 0.0;
ui_max = 1.0;
> = float3(1.0, 0.0, 0.0);

uniform float3 _GradeMixGreen <
ui_category = "Color Grading | Channel Mixer";
ui_label = "Green";
ui_type = "color";
ui_min = 0.0;
ui_max = 1.0;
> = float3(0.0, 1.0, 0.0);

uniform float3 _GradeMixBlue <
ui_category = "Color Grading | Channel Mixer";
ui_label = "Blue";
ui_type = "color";
ui_min = 0.0;
ui_max = 1.0;
> = float3(0.0, 0.0, 1.0);

uniform float3 _GradeMidtoneShadowColor <
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_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_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_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_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_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_label = "Highlights End";
ui_type = "slider";
ui_min = 0.0;
ui_max = 1.0;
> = 1.0;
#if ENABLE_GRADING
uniform float _GradeLightness <
ui_category = "Color Grading | Color Adjustments";
ui_label = "Lightness";
ui_type = "drag";
> = 0.0;

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

uniform float _GradeHueShift <
ui_category = "Color Grading | Color Adjustments";
ui_label = "Hue";
ui_type = "slider";
ui_min = -1.0;
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";
ui_type = "slider";
ui_min = -1.0;
ui_max = 1.0;
> = 0.0;

uniform float _GradeTint <
ui_category = "Color Grading | White Balance";
ui_label = "Tint";
ui_type = "slider";
ui_min = -1.0;
ui_max = 1.0;
> = 0.0;

uniform float3 _GradeShadows <
ui_category = "Color Grading | Split Toning";
ui_label = "Shadows";
ui_type = "color";
> = float3(0.5, 0.5, 0.5);

uniform float3 _GradeHighLights <
ui_category = "Color Grading | Split Toning";
ui_label = "Highlights";
ui_type = "color";
> = float3(0.5, 0.5, 0.5);

uniform float _GradeBalance <
ui_category = "Color Grading | Split Toning";
ui_label = "Balance";
ui_type = "slider";
ui_min = -1.0;
ui_max = 1.0;
> = 0.0;

uniform float3 _GradeMixRed <
ui_category = "Color Grading | Channel Mixer";
ui_label = "Red";
ui_type = "color";
ui_min = 0.0;
ui_max = 1.0;
> = float3(1.0, 0.0, 0.0);

uniform float3 _GradeMixGreen <
ui_category = "Color Grading | Channel Mixer";
ui_label = "Green";
ui_type = "color";
ui_min = 0.0;
ui_max = 1.0;
> = float3(0.0, 1.0, 0.0);

uniform float3 _GradeMixBlue <
ui_category = "Color Grading | Channel Mixer";
ui_label = "Blue";
ui_type = "color";
ui_min = 0.0;
ui_max = 1.0;
> = float3(0.0, 0.0, 1.0);

uniform float3 _GradeMidtoneShadowColor <
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_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_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_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_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_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_label = "Highlights End";
ui_type = "slider";
ui_min = 0.0;
ui_max = 1.0;
> = 1.0;
#endif

#include "shared/cShadeHDR.fxh"
#if ENABLE_AUTOEXPOSURE
Expand Down Expand Up @@ -490,30 +496,32 @@ float4 PS_Composite(CShade_VS2PS_Quad Input) : SV_TARGET0
: BloomColor;
#endif

// Apply color-grading
CColor_ApplyColorGrading(
BaseColor,
_GradeLightness,
_GradeHueShift,
_GradeSaturation,
_GradeContrast,
_GradeColorFilter,
_GradeTemperature,
_GradeTint,
_GradeShadows,
_GradeHighLights,
_GradeBalance,
_GradeMixRed,
_GradeMixGreen,
_GradeMixBlue,
_GradeMidtoneShadowColor,
_GradeMidtoneColor,
_GradeMidtoneHighlightColor,
_GradeMidtoneShadowStart,
_GradeMidtoneShadowEnd,
_GradeMidtoneHighlightStart,
_GradeMidtoneHighlightEnd
);
#if ENABLE_GRADING
// Apply color-grading
CColor_ApplyColorGrading(
BaseColor,
_GradeLightness,
_GradeHueShift,
_GradeSaturation,
_GradeContrast,
_GradeColorFilter,
_GradeTemperature,
_GradeTint,
_GradeShadows,
_GradeHighLights,
_GradeBalance,
_GradeMixRed,
_GradeMixGreen,
_GradeMixBlue,
_GradeMidtoneShadowColor,
_GradeMidtoneColor,
_GradeMidtoneHighlightColor,
_GradeMidtoneShadowStart,
_GradeMidtoneShadowEnd,
_GradeMidtoneHighlightStart,
_GradeMidtoneHighlightEnd
);
#endif

// Apply tonemapping
BaseColor = CTonemap_ApplyOutputTonemap(BaseColor);
Expand Down

0 comments on commit b796281

Please sign in to comment.