Skip to content

Commit

Permalink
Fix per game setting and pack setting in vec4
Browse files Browse the repository at this point in the history
  • Loading branch information
iota97 committed May 16, 2020
1 parent 6c9eb47 commit b07874c
Show file tree
Hide file tree
Showing 13 changed files with 66 additions and 158 deletions.
38 changes: 10 additions & 28 deletions Core/Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -768,30 +768,6 @@ static ConfigSetting graphicsSettings[] = {
ReportedConfigSetting("HardwareTessellation", &g_Config.bHardwareTessellation, false, true, true),
ReportedConfigSetting("PostShader", &g_Config.sPostShaderName, "Off", true, true),

ReportedConfigSetting("PostShaderSettingName1", &g_Config.sPostShaderSettingName1, "", true, true),
ReportedConfigSetting("PostShaderSettingValue1", &g_Config.fPostShaderSettingValue1, 0.0f, true, true),
ConfigSetting("PostShaderSettingMaxValue1", &g_Config.fPostShaderMaxSettingValue1, 1.0f, true, true),
ConfigSetting("PostShaderSettingMinValue1", &g_Config.fPostShaderMinSettingValue1, -1.0f, true, true),
ConfigSetting("PostShaderSettingStep1", &g_Config.fPostShaderSettingStep1, 0.01f, true, true),

ReportedConfigSetting("PostShaderSettingName2", &g_Config.sPostShaderSettingName2, "", true, true),
ReportedConfigSetting("PostShaderSettingValue2", &g_Config.fPostShaderSettingValue2, 0.0f, true, true),
ConfigSetting("PostShaderSettingMaxValue2", &g_Config.fPostShaderMaxSettingValue2, 1.0f, true, true),
ConfigSetting("PostShaderSettingMinValue2", &g_Config.fPostShaderMinSettingValue2, -1.0f, true, true),
ConfigSetting("PostShaderSettingStep2", &g_Config.fPostShaderSettingStep2, 0.01f, true, true),

ReportedConfigSetting("PostShaderSettingName3", &g_Config.sPostShaderSettingName3, "", true, true),
ReportedConfigSetting("PostShaderSettingValue3", &g_Config.fPostShaderSettingValue3, 0.0f, true, true),
ConfigSetting("PostShaderSettingMaxValue3", &g_Config.fPostShaderMaxSettingValue3, 1.0f, true, true),
ConfigSetting("PostShaderSettingMinValue3", &g_Config.fPostShaderMinSettingValue3, -1.0f, true, true),
ConfigSetting("PostShaderSettingStep3", &g_Config.fPostShaderSettingStep3, 0.01f, true, true),

ReportedConfigSetting("PostShaderSettingName4", &g_Config.sPostShaderSettingName4, "", true, true),
ReportedConfigSetting("PostShaderSettingValue4", &g_Config.fPostShaderSettingValue4, 0.0f, true, true),
ConfigSetting("PostShaderSettingMaxValue4", &g_Config.fPostShaderMaxSettingValue4, 1.0f, true, true),
ConfigSetting("PostShaderSettingMinValue4", &g_Config.fPostShaderMinSettingValue4, -1.0f, true, true),
ConfigSetting("PostShaderSettingStep4", &g_Config.fPostShaderSettingStep4, 0.01f, true, true),

ReportedConfigSetting("MemBlockTransferGPU", &g_Config.bBlockTransferGPU, true, true, true),
ReportedConfigSetting("DisableSlowFramebufEffects", &g_Config.bDisableSlowFramebufEffects, false, true, true),
ReportedConfigSetting("FragmentTestCache", &g_Config.bFragmentTestCache, true, true, true),
Expand Down Expand Up @@ -1216,8 +1192,8 @@ void Config::Load(const char *iniFileName, const char *controllerIniFilename) {

auto postShaderSetting = iniFile.GetOrCreateSection("PostShaderSetting")->ToMap();
mPostShaderSetting.clear();
for (auto it = postShaderSetting.begin(), end = postShaderSetting.end(); it != end; ++it) {
mPostShaderSetting.insert(std::pair<std::string, float>(it->first, std::stof(it->second)));
for (auto it : postShaderSetting) {
mPostShaderSetting[it.first] = std::stof(it.second);
}

// This caps the exponent 4 (so 16x.)
Expand Down Expand Up @@ -1615,8 +1591,8 @@ bool Config::loadGameConfig(const std::string &pGameId, const std::string &title

auto postShaderSetting = iniFile.GetOrCreateSection("PostShaderSetting")->ToMap();
mPostShaderSetting.clear();
for (auto it = postShaderSetting.begin(), end = postShaderSetting.end(); it != end; ++it) {
mPostShaderSetting.insert(std::pair<std::string, float>(it->first, std::stof(it->second)));
for (auto it : postShaderSetting) {
mPostShaderSetting[it.first] = std::stof(it.second);
}

IterateSettings(iniFile, [](IniFile::Section *section, ConfigSetting *setting) {
Expand All @@ -1643,6 +1619,12 @@ void Config::unloadGameConfig() {
}
});

auto postShaderSetting = iniFile.GetOrCreateSection("PostShaderSetting")->ToMap();
mPostShaderSetting.clear();
for (auto it : postShaderSetting) {
mPostShaderSetting[it.first] = std::stof(it.second);
}

LoadStandardControllerIni();
}
}
Expand Down
20 changes: 0 additions & 20 deletions Core/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -205,26 +205,6 @@ struct Config {
int iSplineBezierQuality; // 0 = low , 1 = Intermediate , 2 = High
bool bHardwareTessellation;
std::string sPostShaderName; // Off for off.
std::string sPostShaderSettingName1;
float fPostShaderSettingValue1;
float fPostShaderMaxSettingValue1;
float fPostShaderMinSettingValue1;
float fPostShaderSettingStep1;
std::string sPostShaderSettingName2;
float fPostShaderSettingValue2;
float fPostShaderMaxSettingValue2;
float fPostShaderMinSettingValue2;
float fPostShaderSettingStep2;
std::string sPostShaderSettingName3;
float fPostShaderSettingValue3;
float fPostShaderMaxSettingValue3;
float fPostShaderMinSettingValue3;
float fPostShaderSettingStep3;
std::string sPostShaderSettingName4;
float fPostShaderSettingValue4;
float fPostShaderMaxSettingValue4;
float fPostShaderMinSettingValue4;
float fPostShaderSettingStep4;
std::map<std::string, float> mPostShaderSetting;
bool bGfxDebugOutput;
bool bGfxDebugSplitSubmit;
Expand Down
10 changes: 10 additions & 0 deletions GPU/Common/PostShader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,16 @@ void LoadPostShaderInfo(std::vector<std::string> directories) {
section.Get("SettingMinValue4", &info.minSettingValue4, -1.0f);
section.Get("SettingMaxValue4", &info.maxSettingValue4, 1.0f);
section.Get("SettingStep4", &info.settingStep4, 0.01f);

if (g_Config.mPostShaderSetting.find(info.section + "SettingValue1") == g_Config.mPostShaderSetting.end())
g_Config.mPostShaderSetting.insert(std::pair<std::string, float>(info.section + "SettingValue1", info.settingValue1));
if (g_Config.mPostShaderSetting.find(info.section + "SettingValue2") == g_Config.mPostShaderSetting.end())
g_Config.mPostShaderSetting.insert(std::pair<std::string, float>(info.section + "SettingValue2", info.settingValue2));
if (g_Config.mPostShaderSetting.find(info.section + "SettingValue3") == g_Config.mPostShaderSetting.end())
g_Config.mPostShaderSetting.insert(std::pair<std::string, float>(info.section + "SettingValue3", info.settingValue3));
if (g_Config.mPostShaderSetting.find(info.section + "SettingValue4") == g_Config.mPostShaderSetting.end())
g_Config.mPostShaderSetting.insert(std::pair<std::string, float>(info.section + "SettingValue4", info.settingValue4));

// Let's ignore shaders we can't support. TODO: Not a very good check
if (gl_extensions.IsGLES && !gl_extensions.GLES3) {
bool requiresIntegerSupport;
Expand Down
15 changes: 6 additions & 9 deletions GPU/Common/PresentationCommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,10 @@ void PresentationCommon::CalculatePostShaderUniforms(int bufferWidth, int buffer
uniforms->gl_HalfPixel[0] = u_pixel_delta * 0.5f;
uniforms->gl_HalfPixel[1] = v_pixel_delta * 0.5f;

uniforms->setting1 = g_Config.fPostShaderSettingValue1;
uniforms->setting2 = g_Config.fPostShaderSettingValue2;
uniforms->setting3 = g_Config.fPostShaderSettingValue3;
uniforms->setting4 = g_Config.fPostShaderSettingValue4;
uniforms->setting[0] = g_Config.mPostShaderSetting[g_Config.sPostShaderName + "SettingValue1"];;
uniforms->setting[1] = g_Config.mPostShaderSetting[g_Config.sPostShaderName + "SettingValue2"];
uniforms->setting[2] = g_Config.mPostShaderSetting[g_Config.sPostShaderName + "SettingValue3"];
uniforms->setting[3] = g_Config.mPostShaderSetting[g_Config.sPostShaderName + "SettingValue4"];
}

static std::string ReadShaderSrc(const std::string &filename) {
Expand Down Expand Up @@ -218,11 +218,8 @@ bool PresentationCommon::UpdatePostShader() {
{ "u_texelDelta", 1, 1, Draw::UniformType::FLOAT2, offsetof(PostShaderUniforms, texelDelta) },
{ "u_pixelDelta", 2, 2, Draw::UniformType::FLOAT2, offsetof(PostShaderUniforms, pixelDelta) },
{ "u_time", 3, 3, Draw::UniformType::FLOAT4, offsetof(PostShaderUniforms, time) },
{ "u_video", 4, 4, Draw::UniformType::FLOAT1, offsetof(PostShaderUniforms, video) },
{ "u_setting1", 5, 5, Draw::UniformType::FLOAT1, offsetof(PostShaderUniforms, setting1) },
{ "u_setting2", 6, 6, Draw::UniformType::FLOAT1, offsetof(PostShaderUniforms, setting2) },
{ "u_setting3", 7, 7, Draw::UniformType::FLOAT1, offsetof(PostShaderUniforms, setting3) },
{ "u_setting4", 8, 8, Draw::UniformType::FLOAT1, offsetof(PostShaderUniforms, setting4) },
{ "u_setting", 4, 4, Draw::UniformType::FLOAT4, offsetof(PostShaderUniforms, setting) },
{ "u_video", 5, 5, Draw::UniformType::FLOAT1, offsetof(PostShaderUniforms, video) },
} };
Draw::Pipeline *pipeline = CreatePipeline({ vs, fs }, true, &postShaderDesc);
if (!pipeline)
Expand Down
8 changes: 2 additions & 6 deletions GPU/Common/PresentationCommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,8 @@ struct CardboardSettings {
struct PostShaderUniforms {
float texelDelta[2]; float pixelDelta[2];
float time[4];
float video;
float setting1;
float setting2;
float setting3;
float setting4;
float pad[3];
float setting[4];
float video; float pad[3];
// Used on Direct3D9.
float gl_HalfPixel[4];
};
Expand Down
17 changes: 4 additions & 13 deletions GPU/Common/ShaderTranslation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,8 @@ cbuffer data : register(b0) {
float2 u_texelDelta;
float2 u_pixelDelta;
float4 u_time;
float4 u_setting;
float u_video;
float u_setting1;
float u_setting2;
float u_setting3;
float u_setting4;
};
)";

Expand All @@ -105,11 +102,8 @@ layout (std140, set = 0, binding = 0) uniform Data {
vec2 u_texelDelta;
vec2 u_pixelDelta;
vec4 u_time;
vec4 u_setting;
float u_video;
float u_setting1;
float u_setting2;
float u_setting3;
float u_setting4;
};
)";

Expand All @@ -118,11 +112,8 @@ float4 gl_HalfPixel : register(c0);
float2 u_texelDelta : register(c1);
float2 u_pixelDelta : register(c2);
float4 u_time : register(c3);
float u_video : register(c4);
float u_setting1 : register(c5);
float u_setting2 : register(c6);
float u_setting3 : register(c7);
float u_setting4 : register(c8);
float4 u_setting : register(c4);
float u_video : register(c5);
)";

// SPIRV-Cross' HLSL output has some deficiencies we need to work around.
Expand Down
44 changes: 17 additions & 27 deletions UI/GameSettingsScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -290,34 +290,24 @@ void GameSettingsScreen::CreateViews() {
return g_Config.iRenderingMode != FB_NON_BUFFERED_MODE;
});

if (g_Config.sPostShaderSettingName1 != "") {
graphicsSettings->Add(new PopupSliderChoiceFloat(&g_Config.fPostShaderSettingValue1, g_Config.fPostShaderMinSettingValue1, g_Config.fPostShaderMaxSettingValue1,
g_Config.sPostShaderSettingName1, g_Config.fPostShaderSettingStep1, screenManager()))->OnChange.Add([=](EventParams &e) {
g_Config.mPostShaderSetting[g_Config.sPostShaderName + "SettingValue1"] = g_Config.fPostShaderSettingValue1;
return UI::EVENT_CONTINUE;
});;
}
if (g_Config.sPostShaderSettingName2 != "") {
graphicsSettings->Add(new PopupSliderChoiceFloat(&g_Config.fPostShaderSettingValue2, g_Config.fPostShaderMinSettingValue2, g_Config.fPostShaderMaxSettingValue2,
g_Config.sPostShaderSettingName2, g_Config.fPostShaderSettingStep2, screenManager()))->OnChange.Add([=](EventParams &e) {
g_Config.mPostShaderSetting[g_Config.sPostShaderName + "SettingValue2"] = g_Config.fPostShaderSettingValue2;
return UI::EVENT_CONTINUE;
});;
}
if (g_Config.sPostShaderSettingName3 != "") {
graphicsSettings->Add(new PopupSliderChoiceFloat(&g_Config.fPostShaderSettingValue3, g_Config.fPostShaderMinSettingValue3, g_Config.fPostShaderMaxSettingValue3,
g_Config.sPostShaderSettingName3, g_Config.fPostShaderSettingStep3, screenManager()))->OnChange.Add([=](EventParams &e) {
g_Config.mPostShaderSetting[g_Config.sPostShaderName + "SettingValue3"] = g_Config.fPostShaderSettingValue3;
return UI::EVENT_CONTINUE;
});;
}
if (g_Config.sPostShaderSettingName4 != "") {
graphicsSettings->Add(new PopupSliderChoiceFloat(&g_Config.fPostShaderSettingValue4, g_Config.fPostShaderMinSettingValue4, g_Config.fPostShaderMaxSettingValue4,
g_Config.sPostShaderSettingName4, g_Config.fPostShaderSettingStep4, screenManager()))->OnChange.Add([=](EventParams &e) {
g_Config.mPostShaderSetting[g_Config.sPostShaderName + "SettingValue4"] = g_Config.fPostShaderSettingValue4;
return UI::EVENT_CONTINUE;
});;
const ShaderInfo *shaderInfo = GetPostShaderInfo(g_Config.sPostShaderName);
if (shaderInfo && !shaderInfo->settingName1.empty()) {
auto &value = g_Config.mPostShaderSetting[g_Config.sPostShaderName + "SettingValue1"];
graphicsSettings->Add(new PopupSliderChoiceFloat(&value, shaderInfo->minSettingValue1, shaderInfo->maxSettingValue1, shaderInfo->settingName1, shaderInfo->settingStep1, screenManager()));
}
if (shaderInfo && !shaderInfo->settingName2.empty()) {
auto &value = g_Config.mPostShaderSetting[g_Config.sPostShaderName + "SettingValue2"];
graphicsSettings->Add(new PopupSliderChoiceFloat(&value, shaderInfo->minSettingValue2, shaderInfo->maxSettingValue2, shaderInfo->settingName2, shaderInfo->settingStep2, screenManager()));
}
if (shaderInfo && !shaderInfo->settingName3.empty()) {
auto &value = g_Config.mPostShaderSetting[g_Config.sPostShaderName + "SettingValue3"];
graphicsSettings->Add(new PopupSliderChoiceFloat(&value, shaderInfo->minSettingValue3, shaderInfo->maxSettingValue3, shaderInfo->settingName3, shaderInfo->settingStep3, screenManager()));
}
if (shaderInfo && !shaderInfo->settingName4.empty()) {
auto &value = g_Config.mPostShaderSetting[g_Config.sPostShaderName + "SettingValue4"];
graphicsSettings->Add(new PopupSliderChoiceFloat(&value, shaderInfo->minSettingValue4, shaderInfo->maxSettingValue4, shaderInfo->settingName4, shaderInfo->settingStep4, screenManager()));
}

#if !defined(MOBILE_DEVICE)
graphicsSettings->Add(new CheckBox(&g_Config.bFullScreen, gr->T("FullScreen", "Full Screen")))->OnClick.Handle(this, &GameSettingsScreen::OnFullscreenChange);
if (System_GetPropertyInt(SYSPROP_DISPLAY_COUNT) > 1) {
Expand Down
33 changes: 0 additions & 33 deletions UI/MiscScreens.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -317,39 +317,6 @@ void PostProcScreen::OnCompleted(DialogResult result) {
if (result != DR_OK)
return;
g_Config.sPostShaderName = shaders_[listView_->GetSelected()].section;

if (g_Config.mPostShaderSetting.find(g_Config.sPostShaderName + "SettingValue1") == g_Config.mPostShaderSetting.end())
g_Config.mPostShaderSetting.insert(std::pair<std::string, float>(g_Config.sPostShaderName + "SettingValue1", shaders_[listView_->GetSelected()].settingValue1));
if (g_Config.mPostShaderSetting.find(g_Config.sPostShaderName + "SettingValue2") == g_Config.mPostShaderSetting.end())
g_Config.mPostShaderSetting.insert(std::pair<std::string, float>(g_Config.sPostShaderName + "SettingValue2", shaders_[listView_->GetSelected()].settingValue2));
if (g_Config.mPostShaderSetting.find(g_Config.sPostShaderName + "SettingValue3") == g_Config.mPostShaderSetting.end())
g_Config.mPostShaderSetting.insert(std::pair<std::string, float>(g_Config.sPostShaderName + "SettingValue3", shaders_[listView_->GetSelected()].settingValue3));
if (g_Config.mPostShaderSetting.find(g_Config.sPostShaderName + "SettingValue4") == g_Config.mPostShaderSetting.end())
g_Config.mPostShaderSetting.insert(std::pair<std::string, float>(g_Config.sPostShaderName + "SettingValue4", shaders_[listView_->GetSelected()].settingValue4));

g_Config.sPostShaderSettingName1 = shaders_[listView_->GetSelected()].settingName1;
g_Config.fPostShaderSettingValue1 = g_Config.mPostShaderSetting[g_Config.sPostShaderName + "SettingValue1"];
g_Config.fPostShaderMaxSettingValue1 = shaders_[listView_->GetSelected()].maxSettingValue1;
g_Config.fPostShaderMinSettingValue1 = shaders_[listView_->GetSelected()].minSettingValue1;
g_Config.fPostShaderSettingStep1 = shaders_[listView_->GetSelected()].settingStep1;

g_Config.sPostShaderSettingName2 = shaders_[listView_->GetSelected()].settingName2;
g_Config.fPostShaderSettingValue2 = g_Config.mPostShaderSetting[g_Config.sPostShaderName + "SettingValue2"];
g_Config.fPostShaderMaxSettingValue2 = shaders_[listView_->GetSelected()].maxSettingValue2;
g_Config.fPostShaderMinSettingValue2 = shaders_[listView_->GetSelected()].minSettingValue2;
g_Config.fPostShaderSettingStep2 = shaders_[listView_->GetSelected()].settingStep2;

g_Config.sPostShaderSettingName3 = shaders_[listView_->GetSelected()].settingName3;
g_Config.fPostShaderSettingValue3 = g_Config.mPostShaderSetting[g_Config.sPostShaderName + "SettingValue3"];
g_Config.fPostShaderMaxSettingValue3 = shaders_[listView_->GetSelected()].maxSettingValue3;
g_Config.fPostShaderMinSettingValue3 = shaders_[listView_->GetSelected()].minSettingValue3;
g_Config.fPostShaderSettingStep3 = shaders_[listView_->GetSelected()].settingStep3;

g_Config.sPostShaderSettingName4 = shaders_[listView_->GetSelected()].settingName4;
g_Config.fPostShaderSettingValue4 = g_Config.mPostShaderSetting[g_Config.sPostShaderName + "SettingValue4"];
g_Config.fPostShaderMaxSettingValue4 = shaders_[listView_->GetSelected()].maxSettingValue4;
g_Config.fPostShaderMinSettingValue4 = shaders_[listView_->GetSelected()].minSettingValue4;
g_Config.fPostShaderSettingStep4 = shaders_[listView_->GetSelected()].settingStep4;
}

NewLanguageScreen::NewLanguageScreen(const std::string &title) : ListPopupScreen(title) {
Expand Down
11 changes: 5 additions & 6 deletions assets/shaders/bloom.fsh
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ precision mediump int;
uniform sampler2D sampler0;
varying vec2 v_texcoord0;

uniform float u_setting1; // float amount = 0.60; // suitable range = 0.00 - 1.00
uniform float u_setting2; // float power = 0.5; // suitable range = 0.0 - 1.0
uniform vec4 u_setting;

void main()
{
Expand All @@ -21,9 +20,9 @@ void main()

for(int i= -3 ;i < 3; i++)
{
sum += texture2D(sampler0, v_texcoord0 + vec2(-1, i)*0.004) * u_setting1;
sum += texture2D(sampler0, v_texcoord0 + vec2(0, i)*0.004) * u_setting1;
sum += texture2D(sampler0, v_texcoord0 + vec2(1, i)*0.004) * u_setting1;
sum += texture2D(sampler0, v_texcoord0 + vec2(-1, i)*0.004) * u_setting.x;
sum += texture2D(sampler0, v_texcoord0 + vec2(0, i)*0.004) * u_setting.x;
sum += texture2D(sampler0, v_texcoord0 + vec2(1, i)*0.004) * u_setting.x;
}

if (color.r < 0.3 && color.g < 0.3 && color.b < 0.3)
Expand All @@ -42,7 +41,7 @@ void main()
}
}

bloom = mix(color, bloom, u_setting2);
bloom = mix(color, bloom, u_setting.y);
gl_FragColor.rgb = bloom;
gl_FragColor.a = 1.0;
}
4 changes: 2 additions & 2 deletions assets/shaders/cartoon.fsh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ precision mediump float;
precision mediump int;
#endif

uniform float u_setting1; // const float bb = 0.5; // effects black border sensitivity; from 0.0 to 1.0
uniform vec4 u_setting;

uniform sampler2D sampler0;

Expand Down Expand Up @@ -39,7 +39,7 @@ void main()
float d2=dot(abs(c20-c02),dt);
float hl=dot(abs(c01-c21),dt);
float vl=dot(abs(c10-c12),dt);
float d = u_setting1*(d1+d2+hl+vl)/(dot(c11,dt)+0.15);
float d = u_setting.x*(d1+d2+hl+vl)/(dot(c11,dt)+0.15);

float lc = 4.0*length(c11);
float f = fract(lc); f*=f;
Expand Down
11 changes: 4 additions & 7 deletions assets/shaders/colorcorrection.fsh
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,13 @@ precision mediump int;
uniform sampler2D sampler0;
varying vec2 v_texcoord0;

uniform float u_setting1; // brightness - default: 1.0, range = 0.1 - 2.0
uniform float u_setting2; // saturation - default: 1.0, range = 0.0 - 2.0
uniform float u_setting3; // contrast - default: 1.0, range = 0.1 - 3.0
uniform float u_setting4; // gamma - default: 1.0, range = 0.1 - 2.0
uniform vec4 u_setting;

void main()
{
vec3 rgb = texture2D( sampler0, v_texcoord0 ).xyz;
rgb = vec3(mix(vec3(dot(rgb, vec3(0.299, 0.587, 0.114))), rgb, u_setting2));
rgb = (rgb-0.5)*u_setting3+0.5+u_setting1-1.0;
gl_FragColor.rgb = pow(rgb, vec3(1.0/u_setting4));
rgb = vec3(mix(vec3(dot(rgb, vec3(0.299, 0.587, 0.114))), rgb, u_setting.y));
rgb = (rgb-0.5)*u_setting.z+0.5+u_setting.x-1.0;
gl_FragColor.rgb = pow(rgb, vec3(1.0/u_setting.w));
gl_FragColor.a = 1.0;
}
7 changes: 3 additions & 4 deletions assets/shaders/scanlines.fsh
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,12 @@ precision mediump int;
uniform sampler2D sampler0;
varying vec2 v_texcoord0;

uniform float u_setting1; // float amount = 1.0; // suitable range = 0.0 - 1.0
uniform float u_setting2; // float intensity = 0.5; // suitable range = 0.0 - 1.0
uniform vec4 u_setting;

void main()
{
float pos0 = ((v_texcoord0.y + 1.0) * 170.0*u_setting1);
float pos1 = cos((fract( pos0 ) - 0.5)*3.1415926*u_setting2)*1.5;
float pos0 = ((v_texcoord0.y + 1.0) * 170.0*u_setting.x);
float pos1 = cos((fract( pos0 ) - 0.5)*3.1415926*u_setting.y)*1.5;
vec4 rgb = texture2D( sampler0, v_texcoord0 );

// slight contrast curve
Expand Down
Loading

0 comments on commit b07874c

Please sign in to comment.