diff --git a/src/net/torvald/terrarum/FlippingSpriteBatch.kt b/src/net/torvald/terrarum/FlippingSpriteBatch.kt index cbc48bcba..df1cfa24e 100644 --- a/src/net/torvald/terrarum/FlippingSpriteBatch.kt +++ b/src/net/torvald/terrarum/FlippingSpriteBatch.kt @@ -9,7 +9,7 @@ import com.badlogic.gdx.graphics.g2d.TextureRegion * * Created by minjaesong on 2021-12-13. */ -class FlippingSpriteBatch(size: Int = 1000) : SpriteBatch(size, if (App.isAppleM) MacosGL32Shaders.createSpriteBatchShader() else null) { +class FlippingSpriteBatch(size: Int = 1000) : SpriteBatch(size, MacosGL32Shaders.createSpriteBatchShader()) { /** * This function draws the flipped version of the image by giving flipped uv-coord to the SpriteBatch diff --git a/src/shaders/aaaxmul.frag b/src/shaders/aaaxmul.frag index 29971fa77..0cce13177 100644 --- a/src/shaders/aaaxmul.frag +++ b/src/shaders/aaaxmul.frag @@ -1,14 +1,15 @@ -#version 130 +#version 150 #ifdef GL_ES precision mediump float; #endif -varying vec4 v_color; -varying vec2 v_texCoords; -uniform sampler2D u_texture; // world texture, has alpha value that is meaningful +in vec4 v_color; +in vec2 v_texCoords; +uniform sampler2D u_texture; // world texture, has alpha value that is meaningful uniform sampler2D tex1; // lightmap texture uniform vec2 tex1Offset; +out vec4 fragColor; void main() { vec4 colorTex0 = texture2D(u_texture, v_texCoords); // world texture @@ -16,5 +17,5 @@ void main() { colorTex1 = vec4(colorTex1.www, 1.0); - gl_FragColor = colorTex0 * colorTex1; + fragColor = colorTex0 * colorTex1; } diff --git a/src/shaders/actors.frag b/src/shaders/actors.frag index f2f9a7468..379fb579a 100644 --- a/src/shaders/actors.frag +++ b/src/shaders/actors.frag @@ -1,10 +1,10 @@ -#version 130 +#version 150 #ifdef GL_ES precision mediump float; #endif -varying vec4 v_color; -varying vec2 v_texCoords; +in vec4 v_color; +in vec2 v_texCoords; uniform sampler2D u_texture; int bayer[36] = int[]( @@ -19,6 +19,7 @@ float bayerSize = 6.0; float bayerDivider = 256; vec2 boolean = vec2(0.0, 1.0); +out vec4 fragColor; void main() { vec4 inColor = v_color * (texture2D(u_texture, v_texCoords)); @@ -29,6 +30,6 @@ void main() { vec4 selvec = vec4(0.0, 0.0, 0.0, (alpha > bayerThreshold) ? 1.0 : 0.0); - gl_FragColor = inColor * boolean.yyyx + selvec; - gl_FragColor = inColor; + fragColor = inColor * boolean.yyyx + selvec; + fragColor = inColor; } \ No newline at end of file diff --git a/src/shaders/aonly.frag b/src/shaders/aonly.frag index 45c2cd411..4eff6b76a 100644 --- a/src/shaders/aonly.frag +++ b/src/shaders/aonly.frag @@ -1,9 +1,12 @@ -varying vec4 v_color; -varying vec2 v_texCoords; +#version 150 + +in vec4 v_color; +in vec2 v_texCoords; uniform sampler2D u_texture; vec2 boolean = vec2(0.0, 1.0); +out vec4 fragColor; void main(void) { - gl_FragColor = texture2D(u_texture, v_texCoords).aaaa * boolean.yyyx + boolean.xxxy; + fragColor = texture2D(u_texture, v_texCoords).aaaa * boolean.yyyx + boolean.xxxy; } \ No newline at end of file diff --git a/src/shaders/blendGlow.frag b/src/shaders/blendGlow.frag index d53aa148d..f9c525d69 100644 --- a/src/shaders/blendGlow.frag +++ b/src/shaders/blendGlow.frag @@ -1,18 +1,19 @@ -#version 130 +#version 150 #ifdef GL_ES precision mediump float; #endif -varying vec4 v_color; -varying vec2 v_texCoords; +in vec4 v_color; +in vec2 v_texCoords; uniform sampler2D u_texture; // world texture, has alpha value that is meaningful uniform sampler2D tex1; // glow texture, SHOULD contain alpha of all 1.0 +out vec4 fragColor; void main(void) { vec4 colorTex0 = texture2D(u_texture, v_texCoords); // lightmap (RGB) pre-mixed vec4 colorTex1 = texture2D(tex1, v_texCoords); // lightmap (A) pre-mixed - gl_FragColor = vec4(max(colorTex0.rgb, colorTex1.rgb), colorTex0.a); + fragColor = vec4(max(colorTex0.rgb, colorTex1.rgb), colorTex0.a); } \ No newline at end of file diff --git a/src/shaders/blendGlow.vert b/src/shaders/blendGlow.vert index cf5b65ce0..84b21a8d8 100644 --- a/src/shaders/blendGlow.vert +++ b/src/shaders/blendGlow.vert @@ -1,11 +1,13 @@ -attribute vec4 a_position; -attribute vec4 a_color; -attribute vec2 a_texCoord0; +#version 150 + +in vec4 a_position; +in vec4 a_color; +in vec2 a_texCoord0; uniform mat4 u_projTrans; // camera.combined -varying vec4 v_color; -varying vec2 v_texCoords; +out vec4 v_color; +out vec2 v_texCoords; void main() { v_color = a_color; diff --git a/src/shaders/blur.frag b/src/shaders/blur.frag index 8a0566b82..ce1919faa 100644 --- a/src/shaders/blur.frag +++ b/src/shaders/blur.frag @@ -1,17 +1,18 @@ +#version 150 #ifdef GL_ES precision mediump float; #endif -varying vec4 v_color; -varying vec2 v_texCoords; +in vec4 v_color; +in vec2 v_texCoords; + uniform sampler2D u_texture; - - uniform vec2 iResolution; uniform float flip; uniform vec2 direction; +out vec4 fragColor; vec4 blur(sampler2D image, vec2 uv, vec2 resolution, vec2 direction) { vec4 color = vec4(0.0); @@ -31,5 +32,5 @@ void main() { uv.y = 1.0 - uv.y; } - gl_FragColor = blur(u_texture, uv, iResolution.xy, direction); + fragColor = blur(u_texture, uv, iResolution.xy, direction); } \ No newline at end of file diff --git a/src/shaders/blur.vert b/src/shaders/blur.vert index 17d96ca8d..b899fbcdc 100644 --- a/src/shaders/blur.vert +++ b/src/shaders/blur.vert @@ -1,11 +1,13 @@ -attribute vec4 a_position; -attribute vec4 a_color; -attribute vec2 a_texCoord0; +#version 150 + +in vec4 a_position; +in vec4 a_color; +in vec2 a_texCoord0; uniform mat4 u_projTrans; -varying vec4 v_color; -varying vec2 v_texCoords; +out vec4 v_color; +out vec2 v_texCoords; void main() { v_color = a_color; diff --git a/src/shaders/blur2.frag b/src/shaders/blur2.frag index 88f21eb7a..cd7cc9a04 100644 --- a/src/shaders/blur2.frag +++ b/src/shaders/blur2.frag @@ -1,16 +1,18 @@ +#version 150 #ifdef GL_ES precision highp float; #endif -varying vec4 v_color; -varying vec2 v_texCoords; -uniform sampler2D u_texture; +in vec4 v_color; +in vec2 v_texCoords; +uniform sampler2D u_texture; uniform vec2 iResolution; uniform float flip; uniform vec2 direction; +out vec4 fragColor; vec4 blur(sampler2D image, vec2 uv, vec2 resolution, vec2 direction) { vec4 color = vec4(0.0); @@ -33,5 +35,5 @@ void main() { uv.y = 1.0 - uv.y; } - gl_FragColor = blur(u_texture, uv, iResolution.xy, direction); + fragColor = blur(u_texture, uv, iResolution.xy, direction); } \ No newline at end of file diff --git a/src/shaders/boxdown.frag b/src/shaders/boxdown.frag index e8e7a87b2..0400d3edb 100644 --- a/src/shaders/boxdown.frag +++ b/src/shaders/boxdown.frag @@ -1,10 +1,11 @@ -#version 130 +#version 150 #ifdef GL_ES precision mediump float; #endif -varying vec4 v_color; -varying vec2 v_texCoords; +in vec4 v_color; +in vec2 v_texCoords; + uniform sampler2D u_texture; // recommended value: n / vec2(fbo_width, fbo_height) where n is something like {0.5, 1, 2, 4, ... } diff --git a/src/shaders/boxup.frag b/src/shaders/boxup.frag index e8e7a87b2..adab12175 100644 --- a/src/shaders/boxup.frag +++ b/src/shaders/boxup.frag @@ -1,10 +1,10 @@ -#version 130 +#version 150 #ifdef GL_ES precision mediump float; #endif -varying vec4 v_color; -varying vec2 v_texCoords; +in vec4 v_color; +in vec2 v_texCoords; uniform sampler2D u_texture; // recommended value: n / vec2(fbo_width, fbo_height) where n is something like {0.5, 1, 2, 4, ... } @@ -16,6 +16,8 @@ vec2 doubley = vec2(0.0, 2.0); vec2 twister = vec2(1.0, -1.0); vec2 boolean = vec2(1.0, 0.0); +out vec4 fragColor; + void main() { vec4 sum = texture2D(u_texture, v_texCoords) + texture2D(u_texture, v_texCoords + halfpixel) + @@ -27,5 +29,5 @@ void main() { texture2D(u_texture, v_texCoords + halfpixel * boolean.yx) + texture2D(u_texture, v_texCoords - halfpixel * boolean.yx) ; - gl_FragColor = sum / 9.0; + fragColor = sum / 9.0; } \ No newline at end of file diff --git a/src/shaders/crt.frag b/src/shaders/crt.frag index 75f1b56dc..dc6d38116 100644 --- a/src/shaders/crt.frag +++ b/src/shaders/crt.frag @@ -1,11 +1,11 @@ -#version 130 +#version 150 #ifdef GL_ES precision mediump float; #endif -varying vec4 v_color; -varying vec2 v_texCoords; +in vec4 v_color; +in vec2 v_texCoords; uniform sampler2D u_texture; uniform vec2 resolution; @@ -17,6 +17,7 @@ vec3 scanline_darkening = vec3(0.66, 0.66, 0.66); uniform float alternative_scanline = 0.0; // 1.0: true uniform float blur_blend = 0.5; +out vec4 fragColor; void main(void) { vec4 color = texture2D(u_texture, v_texCoords).rgba; @@ -40,6 +41,6 @@ void main(void) { out_color = out_color * scanline_darkening; } - gl_FragColor = vec4(out_color, 1); - //gl_FragColor = texture2D(u_texture, v_texCoords); + fragColor = vec4(out_color, 1); + //fragColor = texture2D(u_texture, v_texCoords); } \ No newline at end of file diff --git a/src/shaders/default.vert b/src/shaders/default.vert index 17d96ca8d..09430c19a 100644 --- a/src/shaders/default.vert +++ b/src/shaders/default.vert @@ -1,14 +1,17 @@ -attribute vec4 a_position; -attribute vec4 a_color; -attribute vec2 a_texCoord0; +#version 150 + +in vec4 a_position; +in vec4 a_color; +in vec2 a_texCoord0; uniform mat4 u_projTrans; -varying vec4 v_color; -varying vec2 v_texCoords; +out vec4 v_color; +out vec2 v_texCoords; void main() { v_color = a_color; + v_color.a = v_color.a * (255.0/254.0); v_texCoords = a_texCoord0; gl_Position = u_projTrans * a_position; } \ No newline at end of file diff --git a/src/shaders/demultiply.frag b/src/shaders/demultiply.frag index 145e6000c..f29fc7b02 100644 --- a/src/shaders/demultiply.frag +++ b/src/shaders/demultiply.frag @@ -1,17 +1,18 @@ -#version 130 +#version 150 #ifdef GL_ES precision mediump float; #endif -varying vec4 v_color; -varying vec2 v_texCoords; +in vec4 v_color; +in vec2 v_texCoords; uniform sampler2D u_texture; vec2 boolean = vec2(0.0, 1.0); +out vec4 fragColor; void main() { vec4 inColor = v_color * (texture2D(u_texture, v_texCoords)); vec4 divided = inColor / pow(inColor.aaaa, vec4(2.0)); - gl_FragColor = divided * boolean.yyyx + inColor * boolean.xxxy; + fragColor = divided * boolean.yyyx + inColor * boolean.xxxy; } \ No newline at end of file diff --git a/src/shaders/diff.frag b/src/shaders/diff.frag index b14fa041c..dcdc744a6 100644 --- a/src/shaders/diff.frag +++ b/src/shaders/diff.frag @@ -1,16 +1,17 @@ -#version 130 +#version 150 #ifdef GL_ES precision mediump float; #endif -varying vec4 v_color; -varying vec2 v_texCoords; +in vec4 v_color; +in vec2 v_texCoords; uniform sampler2D u_texture; +out vec4 fragColor; void main(void) { vec4 inColor = texture2D(u_texture, v_texCoords); ivec4 bytes = ivec4(255.0 * inColor); ivec4 mask = ivec4(0x55); - gl_FragColor = (bytes ^ mask) / 255.0; + fragColor = (bytes ^ mask) / 255.0; } \ No newline at end of file diff --git a/src/shaders/float_to_disp_dither_static.frag b/src/shaders/float_to_disp_dither_static.frag index fd6ae6596..902610cf3 100644 --- a/src/shaders/float_to_disp_dither_static.frag +++ b/src/shaders/float_to_disp_dither_static.frag @@ -1,11 +1,12 @@ -#version 130 +#version 150 #ifdef GL_ES precision mediump float; #endif -varying vec4 v_color; -varying vec2 v_texCoords; +in vec4 v_color; +in vec2 v_texCoords; + uniform sampler2D u_texture; uniform sampler2D u_pattern; @@ -18,6 +19,7 @@ uniform float parallax_size = 1.0/3.0; // 0: no parallax // inverted zoom; this value must set to (1f/zoom) uniform float zoomInv = 1.0; +out vec4 fragColor; float quant = 255.0; // 64 steps -> 63.0; 256 steps -> 255.0 vec4 quantiser = vec4(quant); @@ -50,7 +52,7 @@ void main(void) { vec4 inColor = v_color * mix(newBottom, newTop, scale); vec4 selvec = getDitherredDot(inColor); - gl_FragColor = selvec; + fragColor = selvec; } /* diff --git a/src/shaders/ghastlywhite.frag b/src/shaders/ghastlywhite.frag index a92cd7847..9c9d45bdf 100644 --- a/src/shaders/ghastlywhite.frag +++ b/src/shaders/ghastlywhite.frag @@ -1,13 +1,15 @@ -varying vec4 v_color; -varying vec2 v_texCoords; +#version 150 +in vec4 v_color; +in vec2 v_texCoords; uniform sampler2D u_texture; vec2 boolean = vec2(0.0, 1.0); vec4 desaturate = vec4(0.2126, 0.7152, 0.0722, 0.0); +out vec4 fragColor; void main(void) { vec4 incolour = texture2D(u_texture, v_texCoords); float lum = dot(incolour * desaturate, boolean.yyyx) * 0.5 + 0.5; - gl_FragColor = v_color * (vec4(lum) * boolean.yyyx + incolour * boolean.xxxy); + fragColor = v_color * (vec4(lum) * boolean.yyyx + incolour * boolean.xxxy); } \ No newline at end of file diff --git a/src/shaders/gl32spritebatch.vert b/src/shaders/gl32spritebatch.vert index 39167d38e..b02f596f7 100644 --- a/src/shaders/gl32spritebatch.vert +++ b/src/shaders/gl32spritebatch.vert @@ -3,7 +3,9 @@ in vec4 a_position; in vec4 a_color; in vec2 a_texCoord0; + uniform mat4 u_projTrans; + out vec4 v_color; out vec2 v_texCoords; @@ -11,5 +13,5 @@ void main() { v_color = a_color; v_color.a = v_color.a * (255.0/254.0); v_texCoords = a_texCoord0; - gl_Position = u_projTrans * a_position; -} \ No newline at end of file + gl_Position = u_projTrans * a_position; +} diff --git a/src/shaders/hicolour.frag b/src/shaders/hicolour.frag index d1eaa040f..ae5782a69 100644 --- a/src/shaders/hicolour.frag +++ b/src/shaders/hicolour.frag @@ -1,13 +1,13 @@ -#version 130 +#version 150 #ifdef GL_ES precision mediump float; #endif -varying vec4 v_color; -varying vec2 v_texCoords; -uniform sampler2D u_texture; +in vec4 v_color; +in vec2 v_texCoords; +uniform sampler2D u_texture; // "steps" of R, G and B. Must be integer && equal or greater than 2 uniform float rcount = 8.0; @@ -15,6 +15,8 @@ uniform float gcount = 8.0; uniform float bcount = 8.0; uniform float acount = 1.0; +out vec4 fragColor; + //int bayer[14 * 14] = int[](131,187,8,78,50,18,134,89,155,102,29,95,184,73,22,86,113,171,142,105,34,166,9,60,151,128,40,110,168,137,45,28,64,188,82,54,124,189,80,13,156,56,7,61,186,121,154,6,108,177,24,100,38,176,93,123,83,148,96,17,88,133,44,145,69,161,139,72,30,181,115,27,163,47,178,65,164,14,120,48,5,127,153,52,190,58,126,81,116,21,106,77,173,92,191,63,99,12,76,144,4,185,37,149,192,39,135,23,117,31,170,132,35,172,103,66,129,79,3,97,57,159,70,141,53,94,114,20,49,158,19,146,169,122,183,11,104,180,2,165,152,87,182,118,91,42,67,25,84,147,43,85,125,68,16,136,71,10,193,112,160,138,51,111,162,26,194,46,174,107,41,143,33,74,1,101,195,15,75,140,109,90,32,62,157,98,167,119,179,59,36,130,175,55,0,150); //float bayerSize = 14.0; int bayer[4 * 4] = int[](0,8,2,10,12,4,14,6,3,11,1,9,15,7,13,5); @@ -57,5 +59,5 @@ void main(void) { vec4 outColor = nearestColour(inColor + spread * (bayer[int(entry.y) * int(bayerSize) + int(entry.x)] / bayerDivider - 0.5)); - gl_FragColor = outColor; + fragColor = outColor; } \ No newline at end of file diff --git a/src/shaders/kawasedown.frag b/src/shaders/kawasedown.frag index 2586a6cb8..ecf350c69 100644 --- a/src/shaders/kawasedown.frag +++ b/src/shaders/kawasedown.frag @@ -1,15 +1,17 @@ -#version 130 +#version 150 #ifdef GL_ES precision mediump float; #endif -varying vec4 v_color; -varying vec2 v_texCoords; +in vec4 v_color; +in vec2 v_texCoords; + uniform sampler2D u_texture; // recommended value: n / vec2(fbo_width, fbo_height) where n is something like {0.5, 1, 2, 4, ... } // that, or simply 0.5, depending on how your uv coord works uniform vec2 halfpixel = vec2(0.0, 0.0); +out vec4 fragColor; vec2 twister = vec2(1.0, -1.0); @@ -19,7 +21,7 @@ void main() { sum += texture2D(u_texture, v_texCoords + halfpixel); sum += texture2D(u_texture, v_texCoords - halfpixel * twister); sum += texture2D(u_texture, v_texCoords + halfpixel * twister); - gl_FragColor = sum / 8.0; + fragColor = sum / 8.0; // gl_FragColor = texture2D(u_texture, v_texCoords); } \ No newline at end of file diff --git a/src/shaders/kawaseup.frag b/src/shaders/kawaseup.frag index 51731b2b4..f13b2a48a 100644 --- a/src/shaders/kawaseup.frag +++ b/src/shaders/kawaseup.frag @@ -1,15 +1,17 @@ -#version 130 +#version 150 #ifdef GL_ES precision mediump float; #endif -varying vec4 v_color; -varying vec2 v_texCoords; +in vec4 v_color; +in vec2 v_texCoords; + uniform sampler2D u_texture; // recommended value: n / vec2(fbo_width, fbo_height) where n is something like {0.5, 1, 2, 4, ... } // that, or simply 0.5, depending on how your uv coord works uniform vec2 halfpixel = vec2(0.0, 0.0); +out vec4 fragColor; vec2 doublex = vec2(2.0, 0.0); vec2 doubley = vec2(0.0, 2.0); @@ -24,7 +26,7 @@ void main() { sum += texture2D(u_texture, v_texCoords + halfpixel * twister) * 2.0; sum += texture2D(u_texture, v_texCoords - halfpixel * doubley); sum += texture2D(u_texture, v_texCoords - halfpixel) * 2.0; - gl_FragColor = sum / 12.0; + fragColor = sum / 12.0; -// gl_FragColor = texture2D(u_texture, v_texCoords); +// fragColor = texture2D(u_texture, v_texCoords); } \ No newline at end of file diff --git a/src/shaders/loadingCircle.frag b/src/shaders/loadingCircle.frag index 0f27e28b2..6b528724e 100644 --- a/src/shaders/loadingCircle.frag +++ b/src/shaders/loadingCircle.frag @@ -1,11 +1,11 @@ -#version 130 +#version 150 #ifdef GL_ES precision mediump float; #endif +in vec4 v_color; +in vec2 v_texCoords; -varying vec4 v_color; -varying vec2 v_texCoords; uniform sampler2D u_texture; uniform float rcount = 64.0; @@ -17,6 +17,8 @@ uniform vec2 circleCentrePoint; uniform vec2 colorCentrePoint; uniform float circleSize; +out vec4 fragColor; + void main() { vec2 screenCoord = gl_FragCoord.xy; @@ -27,13 +29,13 @@ void main() { if (distToCircleCentre <= circleSizeSqr) { - gl_FragColor = vec4(0.993, 0.993, 0.993, 1.0); + fragColor = vec4(0.993, 0.993, 0.993, 1.0); } else if (distToCircleCentre <= circleSizeSqr + 200) { // dunno why it's 200; 2000 makes 10px feather - gl_FragColor = vec4(0.993, 0.993, 0.993, 1 - (distToCircleCentre - circleSizeSqr) / 200); + fragColor = vec4(0.993, 0.993, 0.993, 1 - (distToCircleCentre - circleSizeSqr) / 200); } else { - gl_FragColor = vec4(0,0,0,1); + fragColor = vec4(0,0,0,1); } } diff --git a/src/shaders/passthrurgb.frag b/src/shaders/passthrurgb.frag index 57918c361..5b2df0473 100644 --- a/src/shaders/passthrurgb.frag +++ b/src/shaders/passthrurgb.frag @@ -1,14 +1,16 @@ -#version 130 +#version 150 #ifdef GL_ES precision mediump float; #endif -varying vec4 v_color; -varying vec2 v_texCoords; +in vec4 v_color; +in vec2 v_texCoords; + uniform sampler2D u_texture; +out vec4 fragColor; void main(void) { - gl_FragColor = vec4(texture2D(u_texture, v_texCoords).rgb, 1.0); + fragColor = vec4(texture2D(u_texture, v_texCoords).rgb, 1.0); } \ No newline at end of file diff --git a/src/shaders/postproc_dither.frag b/src/shaders/postproc_dither.frag index 05824bfef..855afddf5 100644 --- a/src/shaders/postproc_dither.frag +++ b/src/shaders/postproc_dither.frag @@ -3,7 +3,7 @@ * http://momentsingraphics.de/BlueNoise.html */ -#version 130 +#version 150 #ifdef GL_ES precision mediump float; #endif @@ -17,8 +17,9 @@ vec4 gammaOut(vec4 col) { return pow(col, vec4(1.0 / 2.2)); } -varying vec4 v_color; // unused! -varying vec2 v_texCoords; +in vec4 v_color; // unused! +in vec2 v_texCoords; + uniform sampler2D u_texture; uniform sampler2D u_pattern; uniform ivec2 rnd = ivec2(0,0); @@ -30,6 +31,8 @@ uniform mat4 swizzler = mat4( ); uniform float quant = 255.0; // 64 steps -> 63.0; 256 steps -> 255.0 +out vec4 fragColor; + vec2 boolean = vec2(0.0, 1.0); vec4 matrixNormaliser = vec4(0.5 / 256.0); @@ -78,8 +81,8 @@ void main(void) { vec4 selvec = getDitherredDot(graded); vec4 outcol = selvec * boolean.yyyx + boolean.xxxy; // use quantised RGB but not the A - gl_FragColor = outcol; + fragColor = outcol; // ivec4 bytes = ivec4(255.0 * outcol); // ivec4 mask = ivec4(0x55); -// gl_FragColor = (bytes ^ mask) / 255.0; +// fragColor = (bytes ^ mask) / 255.0; } \ No newline at end of file diff --git a/src/shaders/postproc_nodither.frag b/src/shaders/postproc_nodither.frag index 277f0ec4e..3d18c32dd 100644 --- a/src/shaders/postproc_nodither.frag +++ b/src/shaders/postproc_nodither.frag @@ -3,7 +3,7 @@ * http://momentsingraphics.de/BlueNoise.html */ -#version 130 +#version 150 #ifdef GL_ES precision mediump float; #endif @@ -17,8 +17,9 @@ vec4 gammaOut(vec4 col) { return pow(col, vec4(1.0 / 2.2)); } -varying vec4 v_color; // unused! -varying vec2 v_texCoords; +in vec4 v_color; // unused! +in vec2 v_texCoords; + uniform sampler2D u_texture; uniform sampler2D u_pattern; uniform ivec2 rnd = ivec2(0,0); @@ -44,6 +45,8 @@ mat4 ycocg_to_rgb = mat4( uniform vec4 vibrancy = vec4(1.0);//vec4(1.0, 1.4, 1.2, 1.0); +out vec4 fragColor; + void main(void) { // convert input RGB into YCoCg vec4 incolour = texture2D(u_texture, v_texCoords); @@ -57,5 +60,5 @@ void main(void) { // Dither the output vec4 graded = ycocg_to_rgb * newColour; - gl_FragColor = graded * boolean.yyyx + boolean.xxxy; // use quantised RGB but not the A + fragColor = graded * boolean.yyyx + boolean.xxxy; // use quantised RGB but not the A } \ No newline at end of file diff --git a/src/shaders/quickgreyscale.frag b/src/shaders/quickgreyscale.frag index 0a7045b79..09799fa9c 100644 --- a/src/shaders/quickgreyscale.frag +++ b/src/shaders/quickgreyscale.frag @@ -1,16 +1,20 @@ +#version 150 #ifdef GL_ES precision mediump float; #endif -varying vec4 v_color; -varying vec2 v_texCoords; +in vec4 v_color; +in vec2 v_texCoords; + uniform sampler2D u_texture; uniform mat4 u_projTrans; -void main() { - vec3 color = texture2D(u_texture, v_texCoords).rgb; - float gray = (3.0 * color.r + 4.0 * color.g + color.b) / 8.0; - vec3 grayscale = vec3(gray); +out vec4 fragColor; - gl_FragColor = vec4(grayscale, 1.0); +void main() { + vec3 color = texture2D(u_texture, v_texCoords).rgb; + float gray = (3.0 * color.r + 4.0 * color.g + color.b) / 8.0; + vec3 grayscale = vec3(gray); + + fragColor = vec4(grayscale, 1.0); } \ No newline at end of file diff --git a/src/shaders/quickgreyscale.vert b/src/shaders/quickgreyscale.vert index 17d96ca8d..09430c19a 100644 --- a/src/shaders/quickgreyscale.vert +++ b/src/shaders/quickgreyscale.vert @@ -1,14 +1,17 @@ -attribute vec4 a_position; -attribute vec4 a_color; -attribute vec2 a_texCoord0; +#version 150 + +in vec4 a_position; +in vec4 a_color; +in vec2 a_texCoord0; uniform mat4 u_projTrans; -varying vec4 v_color; -varying vec2 v_texCoords; +out vec4 v_color; +out vec2 v_texCoords; void main() { v_color = a_color; + v_color.a = v_color.a * (255.0/254.0); v_texCoords = a_texCoord0; gl_Position = u_projTrans * a_position; } \ No newline at end of file diff --git a/src/shaders/reflect.frag b/src/shaders/reflect.frag index c88816242..5e96142fc 100644 --- a/src/shaders/reflect.frag +++ b/src/shaders/reflect.frag @@ -1,9 +1,12 @@ -varying vec4 v_color; -varying vec2 v_texCoords; +#version 150 +in vec4 v_color; +in vec2 v_texCoords; uniform sampler2D u_texture; +out vec4 fragColor; + void main(void) { vec4 color = texture2D(u_texture, vec2(v_texCoords.x, 1.0 - v_texCoords.y)); vec4 alphamul = vec4(1.0, 1.0, 1.0, 0.5 * (1.0 - v_texCoords.y)); - gl_FragColor = color * alphamul; + fragColor = color * alphamul; } \ No newline at end of file diff --git a/src/shaders/rgbonly.frag b/src/shaders/rgbonly.frag index 9c9c50456..7ede12cab 100644 --- a/src/shaders/rgbonly.frag +++ b/src/shaders/rgbonly.frag @@ -1,9 +1,12 @@ -varying vec4 v_color; -varying vec2 v_texCoords; +#version 150 +in vec4 v_color; +in vec2 v_texCoords; uniform sampler2D u_texture; vec2 boolean = vec2(0.0, 1.0); +out vec4 fragColor; + void main(void) { - gl_FragColor = texture2D(u_texture, v_texCoords).rgba * boolean.yyyx + boolean.xxxy; + fragColor = texture2D(u_texture, v_texCoords).rgba * boolean.yyyx + boolean.xxxy; } \ No newline at end of file diff --git a/src/shaders/rgbxmul.frag b/src/shaders/rgbxmul.frag index 9bda4166a..c9e6cfecc 100644 --- a/src/shaders/rgbxmul.frag +++ b/src/shaders/rgbxmul.frag @@ -1,21 +1,24 @@ -#version 130 +#version 150 #ifdef GL_ES precision mediump float; #endif -varying vec4 v_color; -varying vec2 v_texCoords; +in vec4 v_color; +in vec2 v_texCoords; + uniform sampler2D u_texture; // world texture, has alpha value that is meaningful uniform sampler2D tex1; // lightmap texture uniform vec2 tex1Offset; uniform vec2 tex1Resolution; +out vec4 fragColor; + void main() { vec4 colorTex0 = texture2D(u_texture, v_texCoords + vec2(0.5, 0.5)); // world texture vec4 colorTex1 = texture2D(tex1, v_texCoords); // lightmap (RGBA) colorTex1 = vec4(colorTex1.xyz, 1.0); - gl_FragColor = colorTex0 * colorTex1; + fragColor = colorTex0 * colorTex1; } diff --git a/src/shaders/skyboxfill.frag b/src/shaders/skyboxfill.frag index 7665d2ef1..80eac0066 100644 --- a/src/shaders/skyboxfill.frag +++ b/src/shaders/skyboxfill.frag @@ -1,20 +1,20 @@ -#version 130 +#version 150 #ifdef GL_ES precision mediump float; #endif -varying vec4 v_color; -varying vec2 v_texCoords; -uniform sampler2D u_texture; +in vec4 v_color; +in vec2 v_texCoords; +uniform sampler2D u_texture; uniform vec3 topColor; uniform vec3 bottomColor; uniform float parallax = 0.0; // +1.0: all top col, -1.0: all bototm col, 0.0: normal grad uniform float parallax_size = 1.0/3.0; // 0: no parallax - +out vec4 fragColor; void main(void) { float scale = v_texCoords.y * (1.0 - parallax_size) + (parallax_size / 2.0) + (parallax * parallax_size / 2.0); @@ -23,7 +23,7 @@ void main(void) { float inG = mix(bottomColor.g, topColor.g, scale); float inB = mix(bottomColor.b, topColor.b, scale); - gl_FragColor = vec4(inR, inG, inB, 1.0); + fragColor = vec4(inR, inG, inB, 1.0); } /* UV mapping coord.y diff --git a/src/shaders/tiling.frag b/src/shaders/tiling.frag index 709797392..5a847e9f5 100644 --- a/src/shaders/tiling.frag +++ b/src/shaders/tiling.frag @@ -2,7 +2,7 @@ */ -#version 130 +#version 150 #ifdef GL_ES precision mediump float; #endif @@ -10,8 +10,9 @@ precision mediump float; //layout(origin_upper_left) in vec4 gl_FragCoord; // commented; requires #version 150 or later // gl_FragCoord is origin to bottom-left -varying vec4 v_color; -varying vec2 v_texCoords; +in vec4 v_color; +in vec2 v_texCoords; + uniform sampler2D u_texture; @@ -41,6 +42,8 @@ uniform float mulBlendIntensity = 1.0; // used my MUL-blending drawings; works a const vec2 bc = vec2(1.0, 0.0); //binary constant +out vec4 fragColor; + ivec2 getTileXY(int tileNumber) { return ivec2(tileNumber % int(tilesInAtlas.x), tileNumber / int(tilesInAtlas.x)); } @@ -106,6 +109,6 @@ void main() { vec4 finalColor =mix(finalTile, finalBreakage, finalBreakage.a) * bc.xxxy + (finalTile * bc.yyyx); - gl_FragColor = mix(colourFilter, colourFilter * finalColor, mulBlendIntensity); + fragColor = mix(colourFilter, colourFilter * finalColor, mulBlendIntensity); } diff --git a/src/shaders/tiling_dither.frag b/src/shaders/tiling_dither.frag index bcfb28627..3001214cb 100644 --- a/src/shaders/tiling_dither.frag +++ b/src/shaders/tiling_dither.frag @@ -2,13 +2,14 @@ */ -#version 130 +#version 150 #ifdef GL_ES precision mediump float; #endif -varying vec4 v_color; -varying vec2 v_texCoords; +in vec4 v_color; +in vec2 v_texCoords; + uniform sampler2D u_texture; @@ -38,6 +39,8 @@ uniform float mulBlendIntensity = 1.0; // used my MUL-blending drawings; works a const vec2 bc = vec2(1.0, 0.0); //binary constant +out vec4 fragColor; + // man the traditional bayer crosshatch pattern looks really good on tiles... int bayer[16] = int[]( 0,8,2,10, @@ -118,5 +121,5 @@ void main() { vec2 entry = mod(gl_FragCoord.xy, vec2(bayerSize, bayerSize)); float bayerThreshold = float(bayer[int(entry.y) * int(bayerSize) + int(entry.x)]) / bayerDivider; - gl_FragColor = undithered * bc.xxxy + vec4((undithered.a > bayerThreshold) ? 1.0 : 0.0) * bc.yyyx; + fragColor = undithered * bc.xxxy + vec4((undithered.a > bayerThreshold) ? 1.0 : 0.0) * bc.yyyx; } diff --git a/src/shaders/ycocg_grading.frag b/src/shaders/ycocg_grading.frag index 8efb02f43..1b4756f9e 100644 --- a/src/shaders/ycocg_grading.frag +++ b/src/shaders/ycocg_grading.frag @@ -1,12 +1,15 @@ +#version 150 #ifdef GL_ES precision mediump float; #endif +in vec4 v_color; +in vec2 v_texCoords; -varying vec4 v_color; -varying vec2 v_texCoords; uniform sampler2D u_texture; +out vec4 fragColor; + mat4 rgb_to_ycocg = mat4( 0.25, 1.0, -0.5, 0.0, 0.5, 0.0, 1.0, 0.0, @@ -29,5 +32,5 @@ void main() { vec4 scalar = vec4(1.0, 2.0, 2.0, 1.0); - gl_FragColor = ycocg_to_rgb * (yog * scalar); + fragColor = ycocg_to_rgb * (yog * scalar); } \ No newline at end of file