diff options
Diffstat (limited to 'src/render/shaders')
| -rw-r--r-- | src/render/shaders/glsl/blur1.frag | 10 | ||||
| -rw-r--r-- | src/render/shaders/glsl/blur2.frag | 10 | ||||
| -rw-r--r-- | src/render/shaders/glsl/blurfinish_legacy.frag | 28 | ||||
| -rw-r--r-- | src/render/shaders/glsl/blurprepare_legacy.frag | 29 | ||||
| -rw-r--r-- | src/render/shaders/glsl/border_legacy.frag | 174 | ||||
| -rw-r--r-- | src/render/shaders/glsl/ext.frag | 7 | ||||
| -rw-r--r-- | src/render/shaders/glsl/glitch.frag | 7 | ||||
| -rw-r--r-- | src/render/shaders/glsl/passthru.frag | 7 | ||||
| -rw-r--r-- | src/render/shaders/glsl/quad.frag | 7 | ||||
| -rw-r--r-- | src/render/shaders/glsl/rgba.frag | 7 | ||||
| -rw-r--r-- | src/render/shaders/glsl/rgbamatte.frag | 7 | ||||
| -rw-r--r-- | src/render/shaders/glsl/rgbx.frag | 12 | ||||
| -rw-r--r-- | src/render/shaders/glsl/shadow_legacy.frag | 86 | ||||
| -rw-r--r-- | src/render/shaders/glsl/tex.vert | 15 | ||||
| -rw-r--r-- | src/render/shaders/glsl/tex300.vert | 2 | ||||
| -rw-r--r-- | src/render/shaders/glsl/tex320.vert | 2 |
16 files changed, 54 insertions, 356 deletions
diff --git a/src/render/shaders/glsl/blur1.frag b/src/render/shaders/glsl/blur1.frag index dbabd610..f0f8cc10 100644 --- a/src/render/shaders/glsl/blur1.frag +++ b/src/render/shaders/glsl/blur1.frag @@ -1,6 +1,5 @@ -#version 100 +#version 300 es precision highp float; -varying highp vec2 v_texcoord; // is in 0-1 uniform sampler2D tex; uniform float radius; @@ -9,6 +8,8 @@ uniform int passes; uniform float vibrancy; uniform float vibrancy_darkness; +in vec2 v_texcoord; + // see http://alienryderflex.com/hsp.html const float Pr = 0.299; const float Pg = 0.587; @@ -107,6 +108,7 @@ vec3 hsl2rgb(vec3 col) { return rgb; } +layout(location = 0) out vec4 fragColor; void main() { vec2 uv = v_texcoord * 2.0; @@ -119,7 +121,7 @@ void main() { vec4 color = sum / 8.0; if (vibrancy == 0.0) { - gl_FragColor = color; + fragColor = color; } else { // Invert it so that it correctly maps to the config setting float vibrancy_darkness1 = 1.0 - vibrancy_darkness; @@ -136,6 +138,6 @@ void main() { vec3 newColor = hsl2rgb(vec3(hsl[0], saturation, hsl[2])); - gl_FragColor = vec4(newColor, color[3]); + fragColor = vec4(newColor, color[3]); } } diff --git a/src/render/shaders/glsl/blur2.frag b/src/render/shaders/glsl/blur2.frag index dfd8eeab..2483bcf4 100644 --- a/src/render/shaders/glsl/blur2.frag +++ b/src/render/shaders/glsl/blur2.frag @@ -1,11 +1,15 @@ -#version 100 +#version 300 es precision highp float; -varying highp vec2 v_texcoord; // is in 0-1 uniform sampler2D tex; uniform float radius; uniform vec2 halfpixel; +in vec2 v_texcoord; + +out vec4 v_color; + +layout(location = 0) out vec4 fragColor; void main() { vec2 uv = v_texcoord / 2.0; @@ -19,5 +23,5 @@ void main() { sum += texture2D(tex, uv + vec2(0.0, -halfpixel.y * 2.0) * radius); sum += texture2D(tex, uv + vec2(-halfpixel.x, -halfpixel.y) * radius) * 2.0; - gl_FragColor = sum / 12.0; + fragColor = sum / 12.0; } diff --git a/src/render/shaders/glsl/blurfinish_legacy.frag b/src/render/shaders/glsl/blurfinish_legacy.frag deleted file mode 100644 index 2a7ebca1..00000000 --- a/src/render/shaders/glsl/blurfinish_legacy.frag +++ /dev/null @@ -1,28 +0,0 @@ -precision highp float; -varying vec2 v_texcoord; // is in 0-1 -uniform sampler2D tex; - -uniform float noise; -uniform float brightness; - -float hash(vec2 p) { - vec3 p3 = fract(vec3(p.xyx) * 1689.1984); - p3 += dot(p3, p3.yzx + 33.33); - return fract((p3.x + p3.y) * p3.z); -} - -void main() { - vec4 pixColor = texture2D(tex, v_texcoord); - - // noise - float noiseHash = hash(v_texcoord); - float noiseAmount = (mod(noiseHash, 1.0) - 0.5); - pixColor.rgb += noiseAmount * noise; - - // brightness - if (brightness < 1.0) { - pixColor.rgb *= brightness; - } - - gl_FragColor = pixColor; -} diff --git a/src/render/shaders/glsl/blurprepare_legacy.frag b/src/render/shaders/glsl/blurprepare_legacy.frag deleted file mode 100644 index 2df933d5..00000000 --- a/src/render/shaders/glsl/blurprepare_legacy.frag +++ /dev/null @@ -1,29 +0,0 @@ -precision highp float; -varying vec2 v_texcoord; // is in 0-1 -uniform sampler2D tex; - -uniform float contrast; -uniform float brightness; - -float gain(float x, float k) { - float a = 0.5 * pow(2.0 * ((x < 0.5) ? x : 1.0 - x), k); - return (x < 0.5) ? a : 1.0 - a; -} - -void main() { - vec4 pixColor = texture2D(tex, v_texcoord); - - // contrast - if (contrast != 1.0) { - pixColor.r = gain(pixColor.r, contrast); - pixColor.g = gain(pixColor.g, contrast); - pixColor.b = gain(pixColor.b, contrast); - } - - // brightness - if (brightness > 1.0) { - pixColor.rgb *= brightness; - } - - gl_FragColor = pixColor; -} diff --git a/src/render/shaders/glsl/border_legacy.frag b/src/render/shaders/glsl/border_legacy.frag deleted file mode 100644 index 39842be5..00000000 --- a/src/render/shaders/glsl/border_legacy.frag +++ /dev/null @@ -1,174 +0,0 @@ -#extension GL_ARB_shading_language_include : enable - -precision highp float; -varying vec4 v_color; -varying vec2 v_texcoord; - -uniform vec2 fullSizeUntransformed; -uniform float radiusOuter; -uniform float thick; - -// Gradients are in OkLabA!!!! {l, a, b, alpha} -uniform vec4 gradient[10]; -uniform vec4 gradient2[10]; -uniform int gradientLength; -uniform int gradient2Length; -uniform float angle; -uniform float angle2; -uniform float gradientLerp; -uniform float alpha; - -#include "rounding.glsl" - -float linearToGamma(float x) { - return x >= 0.0031308 ? 1.055 * pow(x, 0.416666666) - 0.055 : 12.92 * x; -} - -vec4 okLabAToSrgb(vec4 lab) { - float l = pow(lab[0] + lab[1] * 0.3963377774 + lab[2] * 0.2158037573, 3.0); - float m = pow(lab[0] + lab[1] * (-0.1055613458) + lab[2] * (-0.0638541728), 3.0); - float s = pow(lab[0] + lab[1] * (-0.0894841775) + lab[2] * (-1.2914855480), 3.0); - - return vec4(linearToGamma(l * 4.0767416621 + m * -3.3077115913 + s * 0.2309699292), - linearToGamma(l * (-1.2684380046) + m * 2.6097574011 + s * (-0.3413193965)), - linearToGamma(l * (-0.0041960863) + m * (-0.7034186147) + s * 1.7076147010), - lab[3]); -} - -vec4 getOkColorForCoordArray1(vec2 normalizedCoord) { - if (gradientLength < 2) - return gradient[0]; - - float finalAng = 0.0; - - if (angle > 4.71 /* 270 deg */) { - normalizedCoord[1] = 1.0 - normalizedCoord[1]; - finalAng = 6.28 - angle; - } else if (angle > 3.14 /* 180 deg */) { - normalizedCoord[0] = 1.0 - normalizedCoord[0]; - normalizedCoord[1] = 1.0 - normalizedCoord[1]; - finalAng = angle - 3.14; - } else if (angle > 1.57 /* 90 deg */) { - normalizedCoord[0] = 1.0 - normalizedCoord[0]; - finalAng = 3.14 - angle; - } else { - finalAng = angle; - } - - float sine = sin(finalAng); - - float progress = (normalizedCoord[1] * sine + normalizedCoord[0] * (1.0 - sine)) * float(gradientLength - 1); - int bottom = int(floor(progress)); - int top = bottom + 1; - - return gradient[top] * (progress - float(bottom)) + gradient[bottom] * (float(top) - progress); -} - -vec4 getOkColorForCoordArray2(vec2 normalizedCoord) { - if (gradient2Length < 2) - return gradient2[0]; - - float finalAng = 0.0; - - if (angle2 > 4.71 /* 270 deg */) { - normalizedCoord[1] = 1.0 - normalizedCoord[1]; - finalAng = 6.28 - angle; - } else if (angle2 > 3.14 /* 180 deg */) { - normalizedCoord[0] = 1.0 - normalizedCoord[0]; - normalizedCoord[1] = 1.0 - normalizedCoord[1]; - finalAng = angle - 3.14; - } else if (angle2 > 1.57 /* 90 deg */) { - normalizedCoord[0] = 1.0 - normalizedCoord[0]; - finalAng = 3.14 - angle2; - } else { - finalAng = angle2; - } - - float sine = sin(finalAng); - - float progress = (normalizedCoord[1] * sine + normalizedCoord[0] * (1.0 - sine)) * float(gradient2Length - 1); - int bottom = int(floor(progress)); - int top = bottom + 1; - - return gradient2[top] * (progress - float(bottom)) + gradient2[bottom] * (float(top) - progress); -} - -vec4 getColorForCoord(vec2 normalizedCoord) { - vec4 result1 = getOkColorForCoordArray1(normalizedCoord); - - if (gradient2Length <= 0) - return okLabAToSrgb(result1); - - vec4 result2 = getOkColorForCoordArray2(normalizedCoord); - - return okLabAToSrgb(mix(result1, result2, gradientLerp)); -} - -void main() { - - highp vec2 pixCoord = vec2(gl_FragCoord); - highp vec2 pixCoordOuter = pixCoord; - highp vec2 originalPixCoord = v_texcoord; - originalPixCoord *= fullSizeUntransformed; - float additionalAlpha = 1.0; - - vec4 pixColor = vec4(1.0, 1.0, 1.0, 1.0); - - bool done = false; - - pixCoord -= topLeft + fullSize * 0.5; - pixCoord *= vec2(lessThan(pixCoord, vec2(0.0))) * -2.0 + 1.0; - pixCoordOuter = pixCoord; - pixCoord -= fullSize * 0.5 - radius; - pixCoordOuter -= fullSize * 0.5 - radiusOuter; - - // center the pixes dont make it top-left - pixCoord += vec2(1.0, 1.0) / fullSize; - pixCoordOuter += vec2(1.0, 1.0) / fullSize; - - if (min(pixCoord.x, pixCoord.y) > 0.0 && radius > 0.0) { - float dist = pow(pow(pixCoord.x,roundingPower)+pow(pixCoord.y,roundingPower),1.0/roundingPower); - float distOuter = pow(pow(pixCoordOuter.x,roundingPower)+pow(pixCoordOuter.y,roundingPower),1.0/roundingPower); - float h = (thick / 2.0); - - if (dist < radius - h) { - // lower - float normalized = smoothstep(0.0, 1.0, (dist - radius + thick + SMOOTHING_CONSTANT) / (SMOOTHING_CONSTANT * 2.0)); - additionalAlpha *= normalized; - done = true; - } else if (min(pixCoordOuter.x, pixCoordOuter.y) > 0.0) { - // higher - float normalized = 1.0 - smoothstep(0.0, 1.0, (distOuter - radiusOuter + SMOOTHING_CONSTANT) / (SMOOTHING_CONSTANT * 2.0)); - additionalAlpha *= normalized; - done = true; - } else if (distOuter < radiusOuter - h) { - additionalAlpha = 1.0; - done = true; - } - } - - // now check for other shit - if (!done) { - // distance to all straight bb borders - float distanceT = originalPixCoord[1]; - float distanceB = fullSizeUntransformed[1] - originalPixCoord[1]; - float distanceL = originalPixCoord[0]; - float distanceR = fullSizeUntransformed[0] - originalPixCoord[0]; - - // get the smallest - float smallest = min(min(distanceT, distanceB), min(distanceL, distanceR)); - - if (smallest > thick) - discard; - } - - if (additionalAlpha == 0.0) - discard; - - pixColor = getColorForCoord(v_texcoord); - pixColor.rgb *= pixColor[3]; - - pixColor *= alpha * additionalAlpha; - - gl_FragColor = pixColor; -} diff --git a/src/render/shaders/glsl/ext.frag b/src/render/shaders/glsl/ext.frag index 3b71f59c..d8a12c39 100644 --- a/src/render/shaders/glsl/ext.frag +++ b/src/render/shaders/glsl/ext.frag @@ -1,8 +1,10 @@ +#version 300 es + #extension GL_ARB_shading_language_include : enable #extension GL_OES_EGL_image_external : require precision highp float; -varying vec2 v_texcoord; +in vec2 v_texcoord; uniform samplerExternalOES texture0; uniform float alpha; @@ -15,6 +17,7 @@ uniform int discardAlphaValue; uniform int applyTint; uniform vec3 tint; +layout(location = 0) out vec4 fragColor; void main() { vec4 pixColor = texture2D(texture0, v_texcoord); @@ -31,5 +34,5 @@ void main() { if (radius > 0.0) pixColor = rounding(pixColor); - gl_FragColor = pixColor * alpha; + fragColor = pixColor * alpha; } diff --git a/src/render/shaders/glsl/glitch.frag b/src/render/shaders/glsl/glitch.frag index f1dc121e..2b03b498 100644 --- a/src/render/shaders/glsl/glitch.frag +++ b/src/render/shaders/glsl/glitch.frag @@ -1,5 +1,7 @@ +#version 300 es + precision highp float; -varying vec2 v_texcoord; +in vec2 v_texcoord; uniform sampler2D tex; uniform float time; // quirk: time is set to 0 at the beginning, should be around 10 when crash. uniform float distort; @@ -24,6 +26,7 @@ float noise(vec2 point) { return mixed * mixed; } +layout(location = 0) out vec4 fragColor; void main() { float ABERR_OFFSET = 4.0 * (distort / 5.5) * time; float TEAR_AMOUNT = 9000.0 * (1.0 - (distort / 5.5)); @@ -60,5 +63,5 @@ void main() { pixColor[0] += distort / 90.0; - gl_FragColor = pixColor; + fragColor = pixColor; } diff --git a/src/render/shaders/glsl/passthru.frag b/src/render/shaders/glsl/passthru.frag index 532b5525..a5075abf 100644 --- a/src/render/shaders/glsl/passthru.frag +++ b/src/render/shaders/glsl/passthru.frag @@ -1,7 +1,10 @@ +#version 300 es + precision highp float; -varying vec2 v_texcoord; // is in 0-1 +in vec2 v_texcoord; // is in 0-1 uniform sampler2D tex; +layout(location = 0) out vec4 fragColor; void main() { - gl_FragColor = texture2D(tex, v_texcoord); + fragColor = texture2D(tex, v_texcoord); } diff --git a/src/render/shaders/glsl/quad.frag b/src/render/shaders/glsl/quad.frag index 303d1a81..5dae493e 100644 --- a/src/render/shaders/glsl/quad.frag +++ b/src/render/shaders/glsl/quad.frag @@ -1,14 +1,17 @@ +#version 300 es + #extension GL_ARB_shading_language_include : enable precision highp float; -varying vec4 v_color; +in vec4 v_color; #include "rounding.glsl" +layout(location = 0) out vec4 fragColor; void main() { vec4 pixColor = v_color; if (radius > 0.0) pixColor = rounding(pixColor); - gl_FragColor = pixColor; + fragColor = pixColor; } diff --git a/src/render/shaders/glsl/rgba.frag b/src/render/shaders/glsl/rgba.frag index ac2d237d..86ea6d87 100644 --- a/src/render/shaders/glsl/rgba.frag +++ b/src/render/shaders/glsl/rgba.frag @@ -1,6 +1,8 @@ +#version 300 es + #extension GL_ARB_shading_language_include : enable precision highp float; -varying vec2 v_texcoord; // is in 0-1 +in vec2 v_texcoord; // is in 0-1 uniform sampler2D tex; uniform float alpha; @@ -13,6 +15,7 @@ uniform float discardAlphaValue; uniform int applyTint; uniform vec3 tint; +layout(location = 0) out vec4 fragColor; void main() { vec4 pixColor = texture2D(tex, v_texcoord); @@ -32,5 +35,5 @@ void main() { if (radius > 0.0) pixColor = rounding(pixColor); - gl_FragColor = pixColor * alpha; + fragColor = pixColor * alpha; } diff --git a/src/render/shaders/glsl/rgbamatte.frag b/src/render/shaders/glsl/rgbamatte.frag index 618e495f..bf295f73 100644 --- a/src/render/shaders/glsl/rgbamatte.frag +++ b/src/render/shaders/glsl/rgbamatte.frag @@ -1,8 +1,11 @@ +#version 300 es + precision highp float; -varying vec2 v_texcoord; // is in 0-1 +in vec2 v_texcoord; // is in 0-1 uniform sampler2D tex; uniform sampler2D texMatte; +layout(location = 0) out vec4 fragColor; void main() { - gl_FragColor = texture2D(tex, v_texcoord) * texture2D(texMatte, v_texcoord)[0]; // I know it only uses R, but matte should be black/white anyways. + fragColor = texture2D(tex, v_texcoord) * texture2D(texMatte, v_texcoord)[0]; // I know it only uses R, but matte should be black/white anyways. } diff --git a/src/render/shaders/glsl/rgbx.frag b/src/render/shaders/glsl/rgbx.frag index 2a2aad63..5376a257 100644 --- a/src/render/shaders/glsl/rgbx.frag +++ b/src/render/shaders/glsl/rgbx.frag @@ -1,6 +1,7 @@ +#version 300 es #extension GL_ARB_shading_language_include : enable precision highp float; -varying vec2 v_texcoord; +in vec2 v_texcoord; uniform sampler2D tex; uniform float alpha; @@ -13,6 +14,7 @@ uniform int discardAlphaValue; uniform int applyTint; uniform vec3 tint; +layout(location = 0) out vec4 fragColor; void main() { if (discardOpaque == 1 && alpha == 1.0) @@ -21,13 +23,13 @@ void main() { vec4 pixColor = vec4(texture2D(tex, v_texcoord).rgb, 1.0); if (applyTint == 1) { - pixColor[0] = pixColor[0] * tint[0]; - pixColor[1] = pixColor[1] * tint[1]; - pixColor[2] = pixColor[2] * tint[2]; + pixColor[0] = pixColor[0] * tint[0]; + pixColor[1] = pixColor[1] * tint[1]; + pixColor[2] = pixColor[2] * tint[2]; } if (radius > 0.0) pixColor = rounding(pixColor); - gl_FragColor = pixColor * alpha; + fragColor = pixColor * alpha; } diff --git a/src/render/shaders/glsl/shadow_legacy.frag b/src/render/shaders/glsl/shadow_legacy.frag deleted file mode 100644 index bf929e63..00000000 --- a/src/render/shaders/glsl/shadow_legacy.frag +++ /dev/null @@ -1,86 +0,0 @@ -#extension GL_ARB_shading_language_include : enable -precision highp float; -varying vec4 v_color; -varying vec2 v_texcoord; - -uniform vec2 topLeft; -uniform vec2 bottomRight; -uniform vec2 fullSize; -uniform float radius; -uniform float roundingPower; -uniform float range; -uniform float shadowPower; - -float pixAlphaRoundedDistance(float distanceToCorner) { - if (distanceToCorner > radius) { - return 0.0; - } - - if (distanceToCorner > radius - range) { - return pow((range - (distanceToCorner - radius + range)) / range, shadowPower); // i think? - } - - return 1.0; -} - -float modifiedLength(vec2 a) { - return pow(pow(abs(a.x),roundingPower)+pow(abs(a.y),roundingPower),1.0/roundingPower); -} - -void main() { - - vec4 pixColor = v_color; - float originalAlpha = pixColor[3]; - - bool done = false; - - vec2 pixCoord = fullSize * v_texcoord; - - // ok, now we check the distance to a border. - - if (pixCoord[0] < topLeft[0]) { - if (pixCoord[1] < topLeft[1]) { - // top left - pixColor[3] = pixColor[3] * pixAlphaRoundedDistance(modifiedLength(pixCoord - topLeft)); - done = true; - } else if (pixCoord[1] > bottomRight[1]) { - // bottom left - pixColor[3] = pixColor[3] * pixAlphaRoundedDistance(modifiedLength(pixCoord - vec2(topLeft[0], bottomRight[1]))); - done = true; - } - } else if (pixCoord[0] > bottomRight[0]) { - if (pixCoord[1] < topLeft[1]) { - // top right - pixColor[3] = pixColor[3] * pixAlphaRoundedDistance(modifiedLength(pixCoord - vec2(bottomRight[0], topLeft[1]))); - done = true; - } else if (pixCoord[1] > bottomRight[1]) { - // bottom right - pixColor[3] = pixColor[3] * pixAlphaRoundedDistance(modifiedLength(pixCoord - bottomRight)); - done = true; - } - } - - if (!done) { - // distance to all straight bb borders - float distanceT = pixCoord[1]; - float distanceB = fullSize[1] - pixCoord[1]; - float distanceL = pixCoord[0]; - float distanceR = fullSize[0] - pixCoord[0]; - - // get the smallest - float smallest = min(min(distanceT, distanceB), min(distanceL, distanceR)); - - if (smallest < range) { - pixColor[3] = pixColor[3] * pow((smallest / range), shadowPower); - } - } - - if (pixColor[3] == 0.0) { - discard; return; - } - - // premultiply - pixColor.rgb *= pixColor[3]; - - gl_FragColor = pixColor; -} diff --git a/src/render/shaders/glsl/tex.vert b/src/render/shaders/glsl/tex.vert deleted file mode 100644 index 6ede6a8e..00000000 --- a/src/render/shaders/glsl/tex.vert +++ /dev/null @@ -1,15 +0,0 @@ -uniform mat3 proj; -uniform vec4 color; -attribute vec2 pos; -attribute vec2 texcoord; -attribute vec2 texcoordMatte; -varying vec4 v_color; -varying vec2 v_texcoord; -varying vec2 v_texcoordMatte; - -void main() { - gl_Position = vec4(proj * vec3(pos, 1.0), 1.0); - v_color = color; - v_texcoord = texcoord; - v_texcoordMatte = texcoordMatte; -}
\ No newline at end of file diff --git a/src/render/shaders/glsl/tex300.vert b/src/render/shaders/glsl/tex300.vert index f9f12998..e20e7356 100644 --- a/src/render/shaders/glsl/tex300.vert +++ b/src/render/shaders/glsl/tex300.vert @@ -2,9 +2,11 @@ uniform mat3 proj; uniform vec4 color; + in vec2 pos; in vec2 texcoord; in vec2 texcoordMatte; + out vec4 v_color; out vec2 v_texcoord; out vec2 v_texcoordMatte; diff --git a/src/render/shaders/glsl/tex320.vert b/src/render/shaders/glsl/tex320.vert index 309bc02b..b99e2ba7 100644 --- a/src/render/shaders/glsl/tex320.vert +++ b/src/render/shaders/glsl/tex320.vert @@ -2,9 +2,11 @@ uniform mat3 proj; uniform vec4 color; + in vec2 pos; in vec2 texcoord; in vec2 texcoordMatte; + out vec4 v_color; out vec2 v_texcoord; out vec2 v_texcoordMatte; |
