diff --git a/src/net/torvald/terrarum/Hq2x.kt b/src/net/torvald/terrarum/Hq2x.kt index ed07b69bc..e24306657 100644 --- a/src/net/torvald/terrarum/Hq2x.kt +++ b/src/net/torvald/terrarum/Hq2x.kt @@ -47,7 +47,7 @@ class Hq2x : Disposable { program = compileShader( Gdx.files.classpath("shaders/hq2x.vert"), Gdx.files.classpath("shaders/hq2x.frag"), - "#define SCALE ${scaleFactor}.0") + "") lutTexture = Texture(Gdx.files.classpath("shaders/hq${scaleFactor}x.png")) diff --git a/src/shaders/hq2x.frag b/src/shaders/hq2x.frag index 1a8361bc7..7db8dac50 100644 --- a/src/shaders/hq2x.frag +++ b/src/shaders/hq2x.frag @@ -1,6 +1,8 @@ +#version 150 // This float value should be defined from the compiling code. // #define SCALE [2, 3, 4].0 +#define SCALE 2.0 #ifdef GL_ES #define PRECISION mediump precision PRECISION float; @@ -13,12 +15,14 @@ uniform sampler2D u_texture; uniform sampler2D u_lut; uniform vec2 u_textureSize; -varying vec4 v_texCoord[4]; +in vec4 v_texCoord[4]; const mat3 YUV_MATRIX = mat3(0.299, 0.587, 0.114, -0.169, -0.331, 0.5, 0.5, -0.419, -0.081); const vec3 YUV_THRESHOLD = vec3(48.0/255.0, 7.0/255.0, 6.0/255.0); const vec3 YUV_OFFSET = vec3(0, 0.5, 0.5); +out vec4 fragColor; + bool diff(vec3 yuv1, vec3 yuv2) { return any(greaterThan(abs((yuv1 + YUV_OFFSET) - (yuv2 + YUV_OFFSET)), YUV_THRESHOLD)); } @@ -79,5 +83,5 @@ void main() { float sum = dot(weights, vec4(1)); vec3 res = (pixels * (weights / sum)).rgb; - gl_FragColor.rgb = res; + fragColor.rgb = res; } \ No newline at end of file diff --git a/src/shaders/hq2x.vert b/src/shaders/hq2x.vert index 997648c3c..64fd28d1d 100644 --- a/src/shaders/hq2x.vert +++ b/src/shaders/hq2x.vert @@ -1,17 +1,11 @@ -#ifdef GL_ES -#define PRECISION mediump -precision PRECISION float; -precision PRECISION int; -#else -#define PRECISION -#endif +#version 150 -attribute vec4 a_position; -attribute vec2 a_texCoord0; +in vec4 a_position; +in vec2 a_texCoord0; uniform vec2 u_textureSize; -varying vec4 v_texCoord[4]; +out vec4 v_texCoord[4]; void main() { gl_Position = a_position;