Skip to content

Commit

Permalink
Revert previous change
Browse files Browse the repository at this point in the history
  • Loading branch information
papadanku committed Jan 11, 2022
1 parent b47bb9c commit 891a695
Showing 1 changed file with 19 additions and 48 deletions.
67 changes: 19 additions & 48 deletions shaders/cBloom.fx
Original file line number Diff line number Diff line change
Expand Up @@ -25,43 +25,36 @@
SOFTWARE.
*/

uniform float3 _ColorShift <
ui_type = "color";
uniform float _Threshold <
ui_type = "drag";
ui_min = 0.0;
ui_label = "Color Shift";
> = 1.0;
ui_label = "Threshold";
> = 0.8;

uniform float _Intensity <
uniform float _Smooth <
ui_type = "drag";
ui_min = 0.0;
ui_label = "Color Intensity";
> = 1.0;

uniform int _Luminance <
ui_type = "combo";
ui_items = " Average\0 Max\0 Median\0 Length\0";
ui_label = "Luminance";
ui_tooltip = "Method of extracting brightness from the image";
> = 3;
ui_label = "Smoothing";
ui_max = 1.0;
> = 0.5;

uniform float _Saturation <
ui_type = "drag";
ui_min = 0.0;
ui_label = "Saturation";
> = 1.0;

uniform float _Smooth <
ui_type = "drag";
uniform float3 _ColorShift <
ui_type = "color";
ui_min = 0.0;
ui_label = "Smoothing";
ui_max = 1.0;
> = 0.5;
ui_label = "Color Shift";
> = 1.0;

uniform float _Threshold <
uniform float _Intensity <
ui_type = "drag";
ui_min = 0.0;
ui_label = "Threshold";
> = 0.8;
ui_label = "Color Intensity";
> = 1.0;

texture2D _RenderColor : COLOR;

Expand Down Expand Up @@ -341,31 +334,9 @@ float4 UpsamplePS(sampler2D Source, float4 TexCoord[3])
return Output / 16.0;
}

float Luminance(float3 Color)
float Med3(float x, float y, float z)
{
float OutputColor0;

switch(_Luminance)
{
case 0:
// Average
OutputColor0 = dot(Color.rgb, 1.0 / 3.0);
break;
case 1:
// Max
OutputColor0 = max(Color.r, max(Color.g, Color.b));
break;
case 2:
// Median
OutputColor0 = max(min(Color.r, Color.g), min(max(Color.r, Color.g), Color.b));
break;
case 3:
// Length
OutputColor0 = length(Color.rgb) * rsqrt(3.0);
break;
}

return OutputColor0;
return max(min(x, y), min(max(x, y), z));
}

void PrefilterPS(in float4 Position : SV_Position, in float2 TexCoord : TEXCOORD0, out float4 OutputColor0 : SV_Target0)
Expand All @@ -375,13 +346,13 @@ void PrefilterPS(in float4 Position : SV_Position, in float2 TexCoord : TEXCOORD
float4 Color = tex2D(_SampleColor, TexCoord);

// Under-threshold
float Brightness = Luminance(Color.rgb);
float Brightness = Med3(Color.r, Color.g, Color.b);
float ResponseCurve = clamp(Brightness - Curve.x, 0.0, Curve.y);
ResponseCurve = Curve.z * ResponseCurve * ResponseCurve;

// Combine and apply the brightness response curve
Color = Color * max(ResponseCurve, Brightness - _Threshold) / max(Brightness, 1e-10);
Brightness = Luminance(Color.rgb);
Brightness = Med3(Color.r, Color.g, Color.b);
OutputColor0 = saturate(lerp(Brightness, Color.rgb, _Saturation)) * _ColorShift;

// Set alpha to 1.0 so we can see the complete results in ReShade's statistics
Expand Down

0 comments on commit 891a695

Please sign in to comment.