|
|
@@ -487,7 +487,7 @@ public: |
|
|
|
#endif |
|
|
|
"" |
|
|
|
"uniform vec4 u_TexelSize;" |
|
|
|
"uniform sampler2D in_Texture;" |
|
|
|
"uniform sampler2D u_Texture;" |
|
|
|
"" |
|
|
|
"varying vec4 v_CenterX, v_CenterY, v_IndexX, v_IndexY;" |
|
|
|
"" |
|
|
@@ -545,75 +545,77 @@ public: |
|
|
|
" ret.xy = ret.xz * t2.yy + ret.yw * t2.xx;" |
|
|
|
"\n#endif\n" |
|
|
|
/* Nearest neighbour */ |
|
|
|
" gl_FragColor = texture2D(in_Texture, ret.xy);" |
|
|
|
" gl_FragColor = texture2D(u_Texture, ret.xy);" |
|
|
|
#else |
|
|
|
/* Alternate version: some kind of linear interpolation */ |
|
|
|
" vec4 p0 = texture2D(in_Texture, vec2(rx.x, ry.x));" |
|
|
|
" vec4 p1 = texture2D(in_Texture, vec2(rx.y, ry.y));" |
|
|
|
" vec4 p2 = texture2D(in_Texture, vec2(rx.z, ry.z));" |
|
|
|
" vec4 p3 = texture2D(in_Texture, vec2(rx.w, ry.w));" |
|
|
|
" vec4 p0 = texture2D(u_Texture, vec2(rx.x, ry.x));" |
|
|
|
" vec4 p1 = texture2D(u_Texture, vec2(rx.y, ry.y));" |
|
|
|
" vec4 p2 = texture2D(u_Texture, vec2(rx.z, ry.z));" |
|
|
|
" vec4 p3 = texture2D(u_Texture, vec2(rx.w, ry.w));" |
|
|
|
" gl_FragColor = 1.0 / (dd.x + dd.y + dd.z + dd.w)" |
|
|
|
" * (dd.x * p0 + dd.y * p1 + dd.z * p2 + dd.w * p3);" |
|
|
|
#endif |
|
|
|
"}" |
|
|
|
#else |
|
|
|
"void main(float4 in_Position : POSITION," |
|
|
|
"void main(float4 a_Vertex : POSITION," |
|
|
|
" float2 a_TexCoord : TEXCOORD0," |
|
|
|
" uniform float4x4 u_ZoomSettings," |
|
|
|
" uniform float4 u_TexelSize," |
|
|
|
" uniform float4 u_ScreenSize," |
|
|
|
" out float4 out_Position : POSITION," |
|
|
|
" out float2 out_TexCoord : TEXCOORD0)" |
|
|
|
" out float4 v_CenterX," |
|
|
|
" out float4 v_CenterY," |
|
|
|
" out float4 v_IndexX," |
|
|
|
" out float4 v_IndexY)" |
|
|
|
"{" |
|
|
|
" out_TexCoord = a_TexCoord;" |
|
|
|
" out_Position = in_Position;" |
|
|
|
" out_Position = a_Vertex;" |
|
|
|
" float4 offsets = float4(0.5, -0.5, 0.015625, -0.015625);" |
|
|
|
" float4 zoomscale = float4(u_ZoomSettings[2][0]," |
|
|
|
" u_ZoomSettings[2][1]," |
|
|
|
" u_ZoomSettings[2][2]," |
|
|
|
" u_ZoomSettings[2][3]);" |
|
|
|
" float4 zoomtx = float4(u_ZoomSettings[0][0]," |
|
|
|
" u_ZoomSettings[0][1]," |
|
|
|
" u_ZoomSettings[0][2]," |
|
|
|
" u_ZoomSettings[0][3]);" |
|
|
|
" float4 zoomty = float4(u_ZoomSettings[1][0]," |
|
|
|
" u_ZoomSettings[1][1]," |
|
|
|
" u_ZoomSettings[1][2]," |
|
|
|
" u_ZoomSettings[1][3]);" |
|
|
|
" v_CenterX = zoomscale * a_TexCoord.x + zoomtx" |
|
|
|
" + offsets.xyxy * u_TexelSize.x;" |
|
|
|
" v_CenterY = zoomscale * a_TexCoord.y - zoomty" |
|
|
|
" + offsets.xyyx * u_TexelSize.y;" |
|
|
|
" v_IndexX = v_CenterX * u_ScreenSize.z - (offsets.zwzw + float4(0.001, 0.002, 0.003, 0.004));" |
|
|
|
" v_IndexY = v_CenterY * u_ScreenSize.w - (offsets.zwwz + float4(0.0015, 0.0025, 0.0035, 0.0045));" |
|
|
|
"}", |
|
|
|
|
|
|
|
"float3 nearest0(float2 p, float4 u_TexelSize)" |
|
|
|
"{" |
|
|
|
" float2 q = p + 0.5 * u_TexelSize.xy;" |
|
|
|
" q -= fmod(q, 2.0 * u_TexelSize.xy);" |
|
|
|
" q += 0.5 * u_TexelSize.xy;" |
|
|
|
" return float3(q * float2(1.0, 0.25)," |
|
|
|
" length(q - p));" |
|
|
|
"}" |
|
|
|
"" |
|
|
|
"float3 nearest1(float2 p, float4 u_TexelSize)" |
|
|
|
"{" |
|
|
|
" float2 q = p - 0.5 * u_TexelSize.xy;" |
|
|
|
" q -= fmod(q, 2.0 * u_TexelSize.xy);" |
|
|
|
" q += 1.5 * u_TexelSize.xy;" |
|
|
|
" return float3(q * float2(1.0, 0.25) + float2(0.0, 0.25)," |
|
|
|
" length(q - p));" |
|
|
|
"}" |
|
|
|
"" |
|
|
|
"float3 nearest2(float2 p, float4 u_TexelSize)" |
|
|
|
"{" |
|
|
|
" float2 q = p + float2(0.5, -0.5) * u_TexelSize.xy;" |
|
|
|
" q -= fmod(q, 2.0 * u_TexelSize.xy);" |
|
|
|
" q += float2(0.5, 1.5) * u_TexelSize.xy;" |
|
|
|
" return float3(q * float2(1.0, 0.25) + float2(0.0, 0.50)," |
|
|
|
" length(q - p));" |
|
|
|
"}" |
|
|
|
"" |
|
|
|
"float3 nearest3(float2 p, float4 u_TexelSize)" |
|
|
|
"{" |
|
|
|
" float2 q = p + float2(-0.5, 0.5) * u_TexelSize.xy;" |
|
|
|
" q -= fmod(q, 2.0 * u_TexelSize.xy);" |
|
|
|
" q += float2(1.5, 0.5) * u_TexelSize.xy;" |
|
|
|
" return float3(q * float2(1.0, 0.25) + float2(0.0, 0.75)," |
|
|
|
" length(q - p));" |
|
|
|
"}" |
|
|
|
"" |
|
|
|
"void main(float2 a_TexCoord : TEXCOORD0," |
|
|
|
"void main(in float4 v_CenterX," |
|
|
|
" in float4 v_CenterY," |
|
|
|
" in float4 v_IndexX," |
|
|
|
" in float4 v_IndexY," |
|
|
|
" uniform float4 u_TexelSize," |
|
|
|
" uniform sampler2D in_Texture," |
|
|
|
" uniform sampler2D u_Texture," |
|
|
|
" out float4 out_FragColor : COLOR)" |
|
|
|
"{" |
|
|
|
" float2 coord = a_TexCoord.xy;" |
|
|
|
" coord -= 0.1 * u_TexelSize.xy;" |
|
|
|
" float4 p0 = tex2D(in_Texture, nearest0(coord, u_TexelSize).xy);" |
|
|
|
" float4 p1 = tex2D(in_Texture, nearest1(coord, u_TexelSize).xy);" |
|
|
|
" float4 p2 = tex2D(in_Texture, nearest2(coord, u_TexelSize).xy);" |
|
|
|
" float4 p3 = tex2D(in_Texture, nearest3(coord, u_TexelSize).xy);" |
|
|
|
" out_FragColor = 0.25 * (p0 + p1 + p2 + p3);" |
|
|
|
" float4 v05 = float4(0.5, 0.5, 0.5, 0.5);" |
|
|
|
" float4 rx, ry, t0, dx, dy, dd;" |
|
|
|
" rx = u_TexelSize.x + u_TexelSize.z * floor(v_IndexX);" |
|
|
|
" ry = u_TexelSize.y + u_TexelSize.w * floor(v_IndexY);" |
|
|
|
" t0 = step(abs(rx - v05), v05) * step(abs(ry - v05), v05);" |
|
|
|
" dx = rx - v_CenterX;" |
|
|
|
" dy = ry - v_CenterY;" |
|
|
|
" dd = t0 / (0.000001 + (dx * dx) + (dy * dy));" |
|
|
|
" ry = ry * 0.25 + float4(0.0, 0.25, 0.5, 0.75);" |
|
|
|
" float2 t1 = step(dd.xz, dd.yw);" |
|
|
|
" float4 ret = lerp(float4(rx.xz, ry.xz)," |
|
|
|
" float4(rx.yw, ry.yw), t1.xyxy);" |
|
|
|
" dd.xy = lerp(dd.xz, dd.yw, t1);" |
|
|
|
" float t2 = step(dd.x, dd.y);" |
|
|
|
" ret.xy = lerp(ret.xz, ret.yw, t2);" |
|
|
|
/* FIXME: above currently broken; fall back to this */ |
|
|
|
" ret.xy = float2(v_CenterX.x, v_CenterY.x * 0.25);" |
|
|
|
" out_FragColor = tex2D(u_Texture, ret.xy);" |
|
|
|
"}" |
|
|
|
#endif |
|
|
|
); |
|
|
|