Skip to content

Commit

Permalink
Expose gGaussQuality in GAUSSIAN.fx to the UI
Browse files Browse the repository at this point in the history
Also cleans up the earlier out of range array fix in a way that allows gGaussQuality to be adjusted safely.
  • Loading branch information
Mortalitas committed Apr 3, 2024
1 parent f3f3dac commit 401cdd7
Showing 1 changed file with 21 additions and 7 deletions.
28 changes: 21 additions & 7 deletions Shaders/GAUSSIAN.fx
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,17 @@

//GaussQuality
//0 = original, 1 = new. New is the same as original but has additional sample points in-between.
//When using 1, setting N_PASSES to 9 can help smooth wider bloom settings.
#define gGaussQuality 0
//When using 1, setting gGaussQuantity to 9 can help smooth wider bloom settings.
#ifndef gGaussQuality
#define gGaussQuality 0
#endif

//Use a separate uniform for each GaussQuality type to avoid out-of-range compile failures from user input.
#if (gGaussQuality == 0)
#define gGaussQuantity gN_PASSES
#else
#define gGaussQuantity gN_PASSES_NEW
#endif

uniform int gGaussEffect <
ui_label = "Gauss Effect";
Expand Down Expand Up @@ -81,16 +90,21 @@ uniform int gGaussBloomWarmth <
ui_items="Neutral\0Warm\0Hazy/Foggy\0";
> = 0;

//When gGaussQuality = 0, gGaussQuantity must be set to 3, 4, or 5. When using gGaussQuality = 1, gGaussQuantity must be set to 3,4,5,6,7,8, or 9.
#if (gGaussQuality == 0)
uniform int gN_PASSES <
ui_label = "Number of Gaussian Passes";
ui_tooltip = "When gGaussQuality = 0, gN_PASSES must be set to 3, 4, or 5.\nWhen using gGaussQuality = 1, gN_PASSES must be set to 3,4,5,6,7,8, or 9.\nStill fine tuning this. Changing the number of passes can affect brightness.";
ui_tooltip = "Still fine tuning this. Changing the number of passes can affect brightness.";
ui_type = "slider";
#if (gGaussQuality == 0)
ui_min = 3;
ui_max = 5;
ui_step = 1;
> = 5;
#else
uniform int gN_PASSES_NEW <
ui_label = "Number of Gaussian Passes";
ui_tooltip = "Still fine tuning this. Changing the number of passes can affect brightness.";
ui_type = "slider";
ui_min = 3;
ui_max = 9;
ui_step = 1;
Expand Down Expand Up @@ -163,7 +177,7 @@ float4 HGaussianBlurPS(in float4 pos : SV_Position, in float2 texcoord : TEXCOOR
#endif

float4 color = tex2D(ReShade::BackBuffer, texcoord) * sampleWeights[0];
for(int i = 1; i < gN_PASSES; ++i) {
for(int i = 1; i < gGaussQuantity; ++i) {
color += tex2Dlod(ReShade::BackBuffer, float4(texcoord + float2(sampleOffsets[i]*gBloomHW * PIXEL_SIZE.x, 0.0), 0.0, 0.0)) * sampleWeights[i];
color += tex2Dlod(ReShade::BackBuffer, float4(texcoord - float2(sampleOffsets[i]*gBloomHW * PIXEL_SIZE.x, 0.0), 0.0, 0.0)) * sampleWeights[i];
}
Expand All @@ -181,7 +195,7 @@ float4 VGaussianBlurPS(in float4 pos : SV_Position, in float2 texcoord : TEXCOOR
#endif

float4 color = tex2D(ReShade::BackBuffer, texcoord) * sampleWeights[0];
for(int i = 1; i < gN_PASSES; ++i) {
for(int i = 1; i < gGaussQuantity; ++i) {
color += tex2Dlod(ReShade::BackBuffer, float4(texcoord + float2(0.0, sampleOffsets[i]*gBloomVW * PIXEL_SIZE.y), 0.0, 0.0)) * sampleWeights[i];
color += tex2Dlod(ReShade::BackBuffer, float4(texcoord - float2(0.0, sampleOffsets[i]*gBloomVW * PIXEL_SIZE.y), 0.0, 0.0)) * sampleWeights[i];
}
Expand All @@ -199,7 +213,7 @@ float4 SGaussianBlurPS(in float4 pos : SV_Position, in float2 texcoord : TEXCOOR
#endif

float4 color = tex2D(ReShade::BackBuffer, texcoord) * sampleWeights[0];
for(int i = 1; i < gN_PASSES; ++i) {
for(int i = 1; i < gGaussQuantity; ++i) {
color += tex2Dlod(ReShade::BackBuffer, float4(texcoord + float2(sampleOffsets[i]*gBloomSW * PIXEL_SIZE.x, sampleOffsets[i] * PIXEL_SIZE.y), 0.0, 0.0)) * sampleWeights[i];
color += tex2Dlod(ReShade::BackBuffer, float4(texcoord - float2(sampleOffsets[i]*gBloomSW * PIXEL_SIZE.x, sampleOffsets[i] * PIXEL_SIZE.y), 0.0, 0.0)) * sampleWeights[i];
color += tex2Dlod(ReShade::BackBuffer, float4(texcoord + float2(-sampleOffsets[i]*gBloomSW * PIXEL_SIZE.x, sampleOffsets[i] * PIXEL_SIZE.y), 0.0, 0.0)) * sampleWeights[i];
Expand Down

0 comments on commit 401cdd7

Please sign in to comment.