Qt: Fix builtin post shaders

This commit is contained in:
Connor McLaughlin 2022-07-23 18:49:18 +10:00
parent 322c0c4c74
commit e84f38f466
9 changed files with 158 additions and 159 deletions

View file

@ -1,116 +1,116 @@
/*==========================================*/ /*==========================================*/
/*=======Calibrator by PavelDurov1488=======*/ /*=======Calibrator by PavelDurov1488=======*/
/*==========It's not ready yet...===========*/ /*==========It's not ready yet...===========*/
/*===I need to add blur, dynamic noise...===*/ /*===I need to add blur, dynamic noise...===*/
/* /*
[configuration] [configuration]
[OptionRangeFloat] [OptionRangeFloat]
GUIName = Luminance(Y) GUIName = Luminance(Y)
OptionName = LUMINANCE OptionName = LUMINANCE
MinValue = 0.000 MinValue = 0.000
MaxValue = 3.000 MaxValue = 3.000
StepAmount = 0.050 StepAmount = 0.050
DefaultValue = 1.200 DefaultValue = 1.200
[OptionRangeFloat] [OptionRangeFloat]
GUIName = Orange-Cyan(I) GUIName = Orange-Cyan(I)
OptionName = ORANGECYAN OptionName = ORANGECYAN
MinValue = 0.000 MinValue = 0.000
MaxValue = 3.000 MaxValue = 3.000
StepAmount = 0.050 StepAmount = 0.050
DefaultValue = 1.200 DefaultValue = 1.200
[OptionRangeFloat] [OptionRangeFloat]
GUIName = Magenta-Green(Q) GUIName = Magenta-Green(Q)
OptionName = MAGENTAGREEN OptionName = MAGENTAGREEN
MinValue = 0.000 MinValue = 0.000
MaxValue = 3.000 MaxValue = 3.000
StepAmount = 0.050 StepAmount = 0.050
DefaultValue = 1.200 DefaultValue = 1.200
[OptionRangeFloat] [OptionRangeFloat]
GUIName = Black GUIName = Black
OptionName = BLACK OptionName = BLACK
MinValue = 0.000 MinValue = 0.000
MaxValue = 255.000 MaxValue = 255.000
StepAmount = 1.000 StepAmount = 1.000
DefaultValue = 10.000 DefaultValue = 10.000
[OptionRangeFloat] [OptionRangeFloat]
GUIName = White GUIName = White
OptionName = WHITE OptionName = WHITE
MinValue = 0.000 MinValue = 0.000
MaxValue = 255.000 MaxValue = 255.000
StepAmount = 1.000 StepAmount = 1.000
DefaultValue = 240.000 DefaultValue = 240.000
[OptionRangeFloat] [OptionRangeFloat]
GUIName = Noise GUIName = Noise
OptionName = NOISE OptionName = NOISE
MinValue = 0.000 MinValue = 0.000
MaxValue = 50.000 MaxValue = 50.000
StepAmount = 1.000 StepAmount = 1.000
DefaultValue = 10.000 DefaultValue = 10.000
[OptionRangeFloat] [OptionRangeFloat]
GUIName = Saturation GUIName = Saturation
OptionName = SATURATION OptionName = SATURATION
MinValue = 0.000 MinValue = 0.000
MaxValue = 100.000 MaxValue = 100.000
StepAmount = 1.000 StepAmount = 1.000
DefaultValue = 50.000 DefaultValue = 50.000
[/configuration] [/configuration]
*/ */
float pseudoNoise(vec2 co) float pseudoNoise(vec2 co)
{ {
return fract(sin(dot(vec2(co.x+0.513,co.y+0.4124) ,vec2(12.9898,78.233))) * 43758.5453);// *fract(sin(dot(vec2(co.x+4.231,co.y+3.143) ,vec2(12.9898,78.233)*2.0)) * 43758.5453); //pseudo random number generator return fract(sin(dot(vec2(co.x+0.513,co.y+0.4124) ,vec2(12.9898,78.233))) * 43758.5453);// *fract(sin(dot(vec2(co.x+4.231,co.y+3.143) ,vec2(12.9898,78.233)*2.0)) * 43758.5453); //pseudo random number generator
} }
CONSTANT vec3 RGBtoY = vec3(0.299, 0.587, 0.114); CONSTANT vec3 RGBtoY = vec3(0.299, 0.587, 0.114);
CONSTANT vec3 RGBtoI = vec3(0.596,-0.275,-0.321); CONSTANT vec3 RGBtoI = vec3(0.596,-0.275,-0.321);
CONSTANT vec3 RGBtoQ = vec3(0.212,-0.523, 0.311); CONSTANT vec3 RGBtoQ = vec3(0.212,-0.523, 0.311);
CONSTANT vec3 YIQtoR = vec3(1.0, 0.95568806036115671171, 0.61985809445637075388); CONSTANT vec3 YIQtoR = vec3(1.0, 0.95568806036115671171, 0.61985809445637075388);
CONSTANT vec3 YIQtoG = vec3(1.0,-0.27158179694405859326,-0.64687381613840131330); CONSTANT vec3 YIQtoG = vec3(1.0,-0.27158179694405859326,-0.64687381613840131330);
CONSTANT vec3 YIQtoB = vec3(1.0,-1.10817732668266195230, 1.70506455991918171490); CONSTANT vec3 YIQtoB = vec3(1.0,-1.10817732668266195230, 1.70506455991918171490);
void main() void main()
{ {
float2 texcoord = GetCoordinates(); float2 texcoord = GetCoordinates();
float2 time = float2(GetTime(), GetTime()); float2 time = float2(GetTime(), GetTime());
// int FrameCount = GetFrameCount(); // int FrameCount = GetFrameCount();
float4 color = Sample(); float4 color = Sample();
// float brightness_scale = GetOption(BRIGHTNESS_SCALE); // float brightness_scale = GetOption(BRIGHTNESS_SCALE);
//vec3 czm_saturation(vec3 rgb, float adjustment) //vec3 czm_saturation(vec3 rgb, float adjustment)
//{ //{
// // Algorithm from Chapter 16 of OpenGL Shading Language // // Algorithm from Chapter 16 of OpenGL Shading Language
// const vec3 W = vec3(0.2125, 0.7154, 0.0721); // const vec3 W = vec3(0.2125, 0.7154, 0.0721);
// vec3 intensity = vec3(dot(rgb, W)); // vec3 intensity = vec3(dot(rgb, W));
// return mix(intensity, rgb, adjustment); // return mix(intensity, rgb, adjustment);
//} //}
// rgb->yiq // rgb->yiq
float3 yuv; float3 yuv;
yuv.r = pow(dot(color.rgb, float3(0.299, 0.587, 0.114)),LUMINANCE); yuv.r = pow(dot(color.rgb, float3(0.299, 0.587, 0.114)),LUMINANCE);
yuv.g = dot(color.rgb, float3(0.595716,-0.274453,-0.321263))*ORANGECYAN; yuv.g = dot(color.rgb, float3(0.595716,-0.274453,-0.321263))*ORANGECYAN;
yuv.b = dot(color.rgb, float3(0.211456,-0.522591, 0.311135))*MAGENTAGREEN; yuv.b = dot(color.rgb, float3(0.211456,-0.522591, 0.311135))*MAGENTAGREEN;
// apply brightness to y // apply brightness to y
// yuv.r = saturate(yuv.r * brightness_scale); // yuv.r = saturate(yuv.r * brightness_scale);
// yuv->rgb // yuv->rgb
color.r = dot(yuv, float3(1.0, 0.95629572, 0.62102442)); color.r = dot(yuv, float3(1.0, 0.95629572, 0.62102442));
color.g = dot(yuv, float3(1.0,-0.27212210,-0.64738060)); color.g = dot(yuv, float3(1.0,-0.27212210,-0.64738060));
color.b = dot(yuv, float3(1.0,-1.10698902, 1.70461500)); color.b = dot(yuv, float3(1.0,-1.10698902, 1.70461500));
color.rgb = saturate(color.rgb*WHITE/255.0+BLACK/255.0-color.rgb*BLACK/255.0+(pseudoNoise(texcoord))*1.0/255.0); color.rgb = saturate(color.rgb*WHITE/255.0+BLACK/255.0-color.rgb*BLACK/255.0+(pseudoNoise(texcoord))*1.0/255.0);
color.rgb = saturate(color.rgb+(pseudoNoise(vec2(color.r+color.b,color.g+color.b))-0.5)*NOISE/255.0); color.rgb = saturate(color.rgb+(pseudoNoise(vec2(color.r+color.b,color.g+color.b))-0.5)*NOISE/255.0);
SetOutput(saturate(color)); SetOutput(saturate(color));
} }

View file

@ -1,41 +1,41 @@
/* /*
[configuration] [configuration]
[OptionRangeInteger] [OptionRangeInteger]
GUIName = Flip Horizontally GUIName = Flip Horizontally
OptionName = G_FLIP_HORZ OptionName = G_FLIP_HORZ
MinValue = 0 MinValue = 0
MaxValue = 1 MaxValue = 1
StepAmount = 1 StepAmount = 1
DefaultValue = 1 DefaultValue = 1
[OptionRangeInteger] [OptionRangeInteger]
GUIName = Flip Vertically GUIName = Flip Vertically
OptionName = G_FLIP_VERT OptionName = G_FLIP_VERT
MinValue = 0 MinValue = 0
MaxValue = 1 MaxValue = 1
StepAmount = 1 StepAmount = 1
DefaultValue = 0 DefaultValue = 0
[/configuration] [/configuration]
*/ */
void main() void main()
{ {
vec2 uv = GetCoordinates(); vec2 uv = GetCoordinates();
vec2 ts = GetInvResolution(); vec2 ts = GetInvResolution();
vec2 pos = uv; vec2 pos = uv;
if (GetOption(G_FLIP_HORZ) == 1) { if (GetOption(G_FLIP_HORZ) == 1) {
pos.x = 1.0 - pos.x; pos.x = 1.0 - pos.x;
} }
if (GetOption(G_FLIP_VERT) == 1) { if (GetOption(G_FLIP_VERT) == 1) {
pos.y = 1.0 - pos.y; pos.y = 1.0 - pos.y;
} }
vec4 sum = SampleLocation(pos); vec4 sum = SampleLocation(pos);
SetOutput(saturate(sum)); SetOutput(saturate(sum));
} }

View file

@ -21,9 +21,8 @@ PostProcessingSettingsWidget::PostProcessingSettingsWidget(SettingsDialog* dialo
{ {
if (!m_ui.widget->setConfigString(post_chain)) if (!m_ui.widget->setConfigString(post_chain))
{ {
QMessageBox::critical(this, tr("Error"), QMessageBox::critical(this, tr("Error"), tr("The current post-processing chain is invalid, it has been reset."));
tr("The current post-processing chain is invalid, it has been reset. Any changes made will " m_dialog->removeSettingValue("Display", "PostProcessChain");
"overwrite the existing config."));
} }
else else
{ {