Skip to content

Commit

Permalink
fx ...
Browse files Browse the repository at this point in the history
  • Loading branch information
weihuoya committed Feb 1, 2019
1 parent 579ce89 commit 4d0f816
Show file tree
Hide file tree
Showing 5 changed files with 124 additions and 10 deletions.
114 changes: 114 additions & 0 deletions Data/Sys/Shaders/SEDI.glsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
/*
Simple Edge Directed Interpolation (SEDI) v1.0
Copyright (C) 2017 SimoneT - [email protected]
de Blur - Copyright (C) 2016 guest(r) - [email protected]
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/

// de Blur control
#define filterparam 5.0

float CLength(float3 c1)
{
float rmean = c1.r * 0.5;
c1 *= c1;
return sqrt((2.0 + rmean) * c1.r + 4.0 * c1.g + (3.0 - rmean) * c1.b);
}

float Cdistance(float3 c1, float3 c2)
{
float rmean = (c1.r + c2.r) * 0.5;
c1 = pow(c1 - c2, float3(2.0));
return sqrt((2.0 + rmean) * c1.r + 4.0 * c1.g + (3.0 - rmean) * c1.b);
}

float3 ColMin(float3 a, float3 b)
{
float dist = step(0.01, sign(CLength(a) - CLength(b)));
return mix(a, b, dist);
}

float3 ColMax(float3 a, float3 b)
{
float dist = step(0.01, sign(CLength(a) - CLength(b)));
return mix(b, a, dist);
}

float3 Blur(float2 TexCoord)
{
float2 shift = GetInvResolution() * 0.5;

float3 C06 = SampleLocation(TexCoord - shift.xy).rgb;
float3 C07 = SampleLocation(TexCoord + float2( shift.x,-shift.y)).rgb;
float3 C11 = SampleLocation(TexCoord + float2(-shift.x, shift.y)).rgb;
float3 C12 = SampleLocation(TexCoord + shift.xy).rgb;

float dif1 = Cdistance(C06, C12) + 0.00001;
float dif2 = Cdistance(C07, C11) + 0.00001;

dif1 = pow(dif1, filterparam);
dif2 = pow(dif2, filterparam);

float dif3 = dif1 + dif2;
return (dif1 * (C07 + C11) * 0.5 + dif2 * (C06 + C12) * 0.5) / dif3;
}

// de Blur code
float3 deBlur()
{
float2 Size = GetInvResolution();
float2 coord = GetCoordinates();
float2 dx = float2( Size.x, 0.0);
float2 dy = float2( 0.0, Size.y);
float2 g1 = float2( Size.x, Size.y);
float2 g2 = float2(-Size.x, Size.y);

float3 C0 = Blur(coord-g1).rgb;
float3 C1 = Blur(coord-dy).rgb;
float3 C2 = Blur(coord-g2).rgb;
float3 C3 = Blur(coord-dx).rgb;
float3 C4 = Blur(coord ).rgb;
float3 C5 = Blur(coord+dx).rgb;
float3 C6 = Blur(coord+g2).rgb;
float3 C7 = Blur(coord+dy).rgb;
float3 C8 = Blur(coord+g1).rgb;

float3 mn1 = ColMin(ColMin(C0, C1), C2);
float3 mn2 = ColMin(ColMin(C3, C4), C5);
float3 mn3 = ColMin(ColMin(C6, C7), C8);
mn1 = ColMin(ColMin(mn1, mn2), mn3);

float3 mx1 = ColMax(ColMax(C0, C1), C2);
float3 mx2 = ColMax(ColMax(C3, C4), C5);
float3 mx3 = ColMax(ColMax(C6, C7), C8);
mx1 = ColMax(ColMax(mx1, mx2), mx3);

float dif1 = Cdistance(C4, mn1) + 0.00001;
float dif2 = Cdistance(C4, mx1) + 0.00001;

dif1 = pow(dif1, filterparam);
dif2 = pow(dif2, filterparam);

float dif3 = dif1 + dif2;
return (dif1 * mx1 + dif2 * mn1) / dif3;
}

void main()
{
SetOutput(float4(deBlur(), 1.0));
}
Original file line number Diff line number Diff line change
Expand Up @@ -387,15 +387,15 @@ private void addGraphicsSettings(ArrayList<SettingsItem> sl)
sl.add(new CheckBoxSetting(SettingsFile.KEY_WAIT_FOR_SHADERS, Settings.SECTION_GFX_SETTINGS,
R.string.wait_for_shaders, R.string.wait_for_shaders_description, false,
waitForShaders));
sl.add(new CheckBoxSetting(SettingsFile.KEY_BACKEND_MULTITHREADING,
Settings.SECTION_GFX_SETTINGS,
R.string.backend_multithreading, R.string.backend_multithreading_description, false,
backendMultithreading));
sl.add(new SingleChoiceSetting(SettingsFile.KEY_ASPECT_RATIO, Settings.SECTION_GFX_SETTINGS,
R.string.aspect_ratio, 0, R.array.aspectRatioEntries,
R.array.aspectRatioValues, 0, aspectRatio));
sl.add(new SliderSetting(SettingsFile.KEY_DISPLAY_SCALE, Settings.SECTION_GFX_SETTINGS,
R.string.setting_display_scale, 0, 200, "%", 100, displayScale));
sl.add(new CheckBoxSetting(SettingsFile.KEY_BACKEND_MULTITHREADING,
Settings.SECTION_GFX_SETTINGS,
R.string.backend_multithreading, R.string.backend_multithreading_description, false,
backendMultithreading));
}

private void addEnhanceSettings(ArrayList<SettingsItem> sl)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,10 @@ public void setAxisIDs()
}
break;
case InputOverlay.SENSOR_WII_IR:
mFactors[0] = 1;
mFactors[1] = 1;
mFactors[2] = 1;
mFactors[3] = 1;
mFactors[0] = -1;
mFactors[1] = -1;
mFactors[2] = -1;
mFactors[3] = -1;

mAxisIDs[0] = NativeLibrary.ButtonType.WIIMOTE_IR + 1;
mAxisIDs[1] = NativeLibrary.ButtonType.WIIMOTE_IR + 2;
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/VideoCommon/OnScreenDisplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ void DrawMessages()
{
if (SConfig::GetInstance().bOnScreenDisplayMessages)
{
int left = 10, top = 28;
int left = 10, top = 32;
u32 now = Common::Timer::GetTimeMs();
std::lock_guard<std::mutex> lock(s_messages_mutex);
auto it = s_messages.begin();
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/VideoCommon/RenderBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ void Renderer::CheckForConfigChanges()
// Create On-Screen-Messages
void Renderer::DrawDebugText()
{
RenderText(m_debug_title_text, 10, 14, 0xFF00FFFF);
RenderText(m_debug_title_text, 10, 18, 0xFF00FFFF);
}

float Renderer::CalculateDrawAspectRatio() const
Expand Down

0 comments on commit 4d0f816

Please sign in to comment.