Skip to content

Commit

Permalink
kVignette, cNoiseBlur: Added falloff offset
Browse files Browse the repository at this point in the history
  • Loading branch information
papadanku committed Jul 6, 2024
1 parent d329acb commit 6b3d73b
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
13 changes: 11 additions & 2 deletions shaders/cNoiseBlur.fx
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,19 @@ uniform float _Radius <
> = 0.5;

uniform float _Falloff <
ui_label = "Radius Falloff";
ui_category = "Radius Falloff";
ui_label = "Falloff Scale";
ui_type = "drag";
> = 0.5;

uniform float2 _FalloffOffset <
ui_label = "Falloff Offset";
ui_type = "slider";
ui_step = 0.001;
ui_min = -1.0;
ui_max = 1.0;
> = float2(0.0, 0.0);

uniform bool _EnableFalloff <
ui_label = "Enable Radius Falloff";
ui_type = "radio";
Expand Down Expand Up @@ -76,7 +85,7 @@ float4 PS_NoiseBlur(VS2PS_Quad Input) : SV_TARGET0
float AspectRatio = ScreenSize.y * (1.0 / ScreenSize.x);

// Compute optional radius falloff
float FalloffFactor = _EnableFalloff ? GetVignette(Input.Tex0, AspectRatio, _Falloff) : 1.0;
float FalloffFactor = _EnableFalloff ? GetVignette(Input.Tex0, AspectRatio, _Falloff, _FalloffOffset) : 1.0;
FalloffFactor = _InvertFalloff ? FalloffFactor : 1.0 - FalloffFactor;

float4 Weight = 0.0;
Expand Down
10 changes: 9 additions & 1 deletion shaders/kVignette.fx
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,22 @@ uniform float _Falloff <
ui_type = "drag";
> = 0.5;

uniform float2 _FalloffOffset <
ui_label = "Falloff Offset";
ui_type = "slider";
ui_step = 0.001;
ui_min = -1.0;
ui_max = 1.0;
> = float2(0.0, 0.0);

/*
[Pixel Shaders]
*/

float4 PS_Vignette(VS2PS_Quad Input) : SV_TARGET0
{
const float AspectRatio = float(BUFFER_WIDTH) / float(BUFFER_HEIGHT);
return GetVignette(Input.Tex0, AspectRatio, _Falloff);
return GetVignette(Input.Tex0, AspectRatio, _Falloff, _FalloffOffset);
}

technique CShade_KinoVignette
Expand Down
4 changes: 2 additions & 2 deletions shaders/shared/cCamera.fxh
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

float GetVignette(float2 Tex, float AspectRatio, float Falloff)
float GetVignette(float2 Tex, float AspectRatio, float Falloff, float2 FalloffOffset)
{
Tex = (Tex * 2.0 - 1.0) * AspectRatio;
Tex = ((Tex * 2.0 - 1.0) + FalloffOffset) * AspectRatio;
float Radius = length(Tex) * Falloff;
float Radius_2_1 = (Radius * Radius) + 1.0;
return 1.0 / (Radius_2_1 * Radius_2_1);
Expand Down

0 comments on commit 6b3d73b

Please sign in to comment.