Skip to content

Commit

Permalink
Shared files bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
papadanku committed Jul 6, 2024
1 parent bf37479 commit 30cdee8
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 19 deletions.
9 changes: 5 additions & 4 deletions shaders/cAutoExposure.fx
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
#include "shared/cMacros.fxh"
#include "shared/cGraphics.fxh"

#define INCLUDE_CCAMERA_OPTIONS_EXPOSURE
#define INCLUDE_CCAMERA_INPUT
#define INCLUDE_CCAMERA_OUTPUT
#include "shared/cCamera.fxh"

#define INCLUDE_CTONEMAP_OPTIONS_TONEMAP
#define INCLUDE_CTONEMAP_OUTPUT
#include "shared/cTonemap.fxh"

/*
Expand Down Expand Up @@ -94,11 +95,11 @@ float3 PS_Exposure(VS2PS_Quad Input) : SV_TARGET0
float3 Color1 = ExposedColor.rgb;
float3 Color2 = lerp(Dot * 2.0, Color.rgb, Mask * 0.5);

return lerp(ApplyTonemap(Color1), Color2, Mask).rgb;
return lerp(ApplyOutputTonemap(Color1), Color2, Mask).rgb;
}
else
{
return ApplyTonemap(ExposedColor);
return ApplyOutputTonemap(ExposedColor);
}
}

Expand Down
7 changes: 4 additions & 3 deletions shaders/cBloom.fx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
#include "shared/cBuffers.fxh"
#include "shared/cGraphics.fxh"

#define INCLUDE_CCAMERA_OPTIONS_EXPOSURE
#define INCLUDE_CCAMERA_INPUT
#define INCLUDE_CCAMERA_OUTPUT
#include "shared/cCamera.fxh"

#define INCLUDE_CTONEMAP_OPTIONS_TONEMAP
#define INCLUDE_CTONEMAP_OUTPUT
#include "shared/cTonemap.fxh"

/*
Expand Down Expand Up @@ -369,7 +370,7 @@ float4 PS_Composite(VS2PS_Quad Input) : SV_TARGET0
float3 BloomColor = tex2D(SampleTempTex1, Input.Tex0).rgb;

float4 Color = 1.0;
Color.rgb = ApplyTonemap(BaseColor + (BloomColor * _Intensity));
Color.rgb = ApplyOutputTonemap(BaseColor + (BloomColor * _Intensity));
return Color;
}

Expand Down
22 changes: 12 additions & 10 deletions shaders/shared/cCamera.fxh
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,7 @@

// AutoExposure(): https://john-chapman.github.io/2017/08/23/dynamic-local-exposure.html

#if defined(INCLUDE_CCAMERA_OPTIONS_EXPOSURE)
uniform float _CShadeExposureBias <
ui_category = "Output: AutoExposure";
ui_label = "Exposure Bias";
ui_type = "slider";
ui_step = 0.001;
ui_min = 0.0;
ui_max = 8.0;
> = 1.0;

#if defined(INCLUDE_CCAMERA_INPUT)
uniform float _CShadeExposureSmoothingSpeed <
ui_category = "Output: AutoExposure";
ui_label = "Smoothing Speed";
Expand All @@ -31,6 +22,17 @@
float Delay = 1e-3 * FrameTime;
return float4(log(max(Luma, 1e-2)), saturate(Delay * _CShadeExposureSmoothingSpeed));
}
#endif

#if defined(INCLUDE_CCAMERA_OUTPUT)
uniform float _CShadeExposureBias <
ui_category = "Output: AutoExposure";
ui_label = "Exposure Bias";
ui_type = "slider";
ui_step = 0.001;
ui_min = 0.0;
ui_max = 8.0;
> = 1.0;

float3 ApplyAutoExposure(float3 Color, float Luma)
{
Expand Down
4 changes: 2 additions & 2 deletions shaders/shared/cTonemap.fxh
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@
return 0.5 * (D * SDR - sqrt(((D*D - 4.0*C*E) * SDR + 4.0*A*E-2.0*B*D) * SDR + B*B) - B) / (A - C * SDR);
}

#if defined(INCLUDE_CTONEMAP_OPTIONS_TONEMAP)
#if defined(INCLUDE_CTONEMAP_OUTPUT)
uniform int _CShadeTonemapOperator <
ui_category = "Output: Tonemapping";
ui_label = "Tonemap Operator";
Expand All @@ -137,7 +137,7 @@
ui_items = "None\0Reinhard\0Reinhard Squared\0Standard\0Exponential\0ACES Filmic Curve\0";
> = 5;

float3 ApplyTonemap(float3 HDR)
float3 ApplyOutputTonemap(float3 HDR)
{
switch (_CShadeTonemapOperator)
{
Expand Down

0 comments on commit 30cdee8

Please sign in to comment.