wanzer

Status:Offline Date registered: 22.03.2016 Post:1 Send Message | Created on 22.03.2016 - 12:49 |  |
Games like FF IX or FF VIII could use a good filter that smoothes background textures.
The problem is that 99% of the filters not only smooth background textures but 3D models as well, leading to a sever drop in details on those models.
There are filters tho that somehow manage to filter only 2D textures leaving 3D untouched.
Those are:
CRT-Hyllian-3D
Code: | 1: | 2: | 3: | 4: | 5: | 6: | 7: | 8: | 9: | 10: | 11: | 12: | 13: | 14: | 15: | 16: | 17: | 18: | 19: | 20: | 21: | 22: | 23: | 24: | 25: | 26: | 27: | 28: | 29: | 30: | 31: | 32: | 33: | 34: | 35: | 36: | 37: | 38: | 39: | 40: | 41: | 42: | 43: | 44: | 45: | 46: | 47: | 48: | 49: | 50: | 51: | 52: | 53: | 54: | 55: | 56: | 57: | 58: | 59: | 60: | 61: | 62: | 63: | 64: | 65: | 66: | 67: | 68: | 69: | 70: | 71: | 72: | 73: | 74: | 75: | 76: | 77: | 78: | 79: | 80: | 81: | 82: | 83: | 84: | 85: | 86: | 87: | 88: | 89: | 90: | 91: | 92: | 93: | 94: | 95: | 96: | 97: | 98: | 99: | 100: | 101: | 102: | 103: | 104: | 105: | 106: | 107: | 108: | 109: | 110: | 111: | 112: | 113: | 114: | 115: | 116: | 117: | 118: | 119: | 120: | 121: | 122: | 123: | 124: | 125: | 126: | 127: | 128: | 129: | 130: | 131: | 132: | 133: | 134: | 135: | 136: | 137: | 138: | 139: | 140: | 141: | 142: | 143: | 144: | 145: | 146: | 147: | 148: | 149: | 150: | 151: | 152: | 153: | 154: | 155: | 156: | 157: | 158: | 159: | 160: | 161: | 162: | 163: | 164: | 165: | 166: | 167: | 168: | 169: | 170: | 171: | 172: | 173: | 174: | 175: | 176: | 177: | 178: | 179: | 180: | 181: | 182: | 183: | 184: | 185: | 186: | 187: | 188: | 189: | 190: | 191: | 192: | 193: | 194: | 195: | 196: | 197: | 198: | 199: | 200: | 201: | 202: | 203: | 204: | 205: | 206: | 207: | 208: | 209: | 210: | 211: | 212: | 213: | 214: | 215: | 216: | 217: | 218: | 219: | 220: | 221: | 222: | 223: | 224: | 225: | 226: | 227: | 228: | 229: | 230: | 231: | 232: | 233: | 234: | 235: | 236: | 237: | 238: | 239: | 240: | 241: | 242: | 243: | 244: | 245: | 246: | 247: | 248: | 249: | 250: | 251: | 252: | 253: | 254: | 255: | 256: | 257: | 258: | 259: | 260: | 261: | 262: | 263: | 264: | 265: | 266: | 267: | 268: | 269: | 270: | 271: | 272: | 273: | 274: | 275: | 276: | 277: | 278: | 279: | 280: | 281: | 282: | 283: | 284: | 285: | 286: | 287: | 288: | 289: | 290: | 291: | | |
| /*
| Hyllian's CRT Shader
|
| Copyright (C) 2011-2015 Hyllian - sergiogdb@gmail.com
|
| Permission is hereby granted, free of charge, to any person obtaining a copy
| of this software and associated documentation files (the "Software"), to deal
| in the Software without restriction, including without limitation the rights
| to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
| copies of the Software, and to permit persons to whom the Software is
| furnished to do so, subject to the following conditions:
|
| The above copyright notice and this permission notice shall be included in
| all copies or substantial portions of the Software.
|
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
| IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
| FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
| AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
| LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
| OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
| THE SOFTWARE.
|
| */
|
| // Uncomment to enable anti-ringing to horizontal filter.
| //#define ANTI_RINGING
|
| // Comment next line if you don't desire the phosphor effect.
| //#define PHOSPHOR
|
| // Uncomment to enable adjustment of red and green saturation.
| //#define RED_GREEN_CONTROL
|
| #define InputGamma 2.4
| #define OutputGamma 2.2
| #define RED_BOOST 1.0
| #define GREEN_BOOST 1.0
| #define SCANLINES_STRENGTH 0.72
| #define BEAM_MIN_WIDTH 0.86
| #define BEAM_MAX_WIDTH 1.0
| #define COLOR_BOOST 1.5
| #define CRT_TV_BLUE_TINT 1.0
|
|
| #define GAMMA_IN(color) pow(color, vec3(InputGamma, InputGamma, InputGamma))
| #define GAMMA_OUT(color) pow(color, vec3(1.0 / OutputGamma, 1.0 / OutputGamma, 1.0 / OutputGamma))
|
| const vec3 dtt = vec3(65536,255,1);
|
|
| // Horizontal cubic filter.
|
| // Some known filters use these values:
|
| // B = 0.0, C = 0.0 => Hermite cubic filter.
| // B = 1.0, C = 0.0 => Cubic B-Spline filter.
| // B = 0.0, C = 0.5 => Catmull-Rom Spline filter. This is the default used in this shader.
| // B = C = 1.0/3.0 => Mitchell-Netravali cubic filter.
| // B = 0.3782, C = 0.3109 => Robidoux filter.
| // B = 0.2620, C = 0.3690 => Robidoux Sharp filter.
| // B = 0.36, C = 0.28 => My best config for ringing elimination in pixel art (Hyllian).
|
|
| // For more info, see: http://www.imagemagick.org/Usage/img_diagrams/cubic_survey.gif
|
| // Change these params to configure the horizontal filter.
| const float B = 0.0;
| const float C = 0.5;
|
| /*
| const mat4 invX = mat4( (-B - 6.0*C)/6.0, (3.0*B + 12.0*C)/6.0, (-3.0*B - 6.0*C)/6.0, B/6.0,
| (12.0 - 9.0*B - 6.0*C)/6.0, (-18.0 + 12.0*B + 6.0*C)/6.0, 0.0, (6.0 - 2.0*B)/6.0,
| -(12.0 - 9.0*B - 6.0*C)/6.0, (18.0 - 15.0*B - 12.0*C)/6.0, (3.0*B + 6.0*C)/6.0, B/6.0,
| (B + 6.0*C)/6.0, -C, 0.0, 0.0);
|
| */
| const mat4 invX = mat4( (-B - 6.0*C)/6.0, (12.0 - 9.0*B - 6.0*C)/6.0, -(12.0 - 9.0*B - 6.0*C)/6.0, (B + 6.0*C)/6.0,
| (3.0*B + 12.0*C)/6.0, (-18.0 + 12.0*B + 6.0*C)/6.0, (18.0 - 15.0*B - 12.0*C)/6.0, -C,
| (-3.0*B - 6.0*C)/6.0, 0.0, (3.0*B + 6.0*C)/6.0, 0.0,
| B/6.0, (6.0 - 2.0*B)/6.0, B/6.0, 0.0);
|
|
| /*
| const static float4x4 invX = float4x4( (-B - 6.0*C)/6.0, (3.0*B + 12.0*C)/6.0, (-3.0*B - 6.0*C)/6.0, B/6.0,
| (12.0 - 9.0*B - 6.0*C)/6.0, (-18.0 + 12.0*B + 6.0*C)/6.0, 0.0, (6.0 - 2.0*B)/6.0,
| -(12.0 - 9.0*B - 6.0*C)/6.0, (18.0 - 15.0*B - 12.0*C)/6.0, (3.0*B + 6.0*C)/6.0, B/6.0,
| (B + 6.0*C)/6.0, -C, 0.0, 0.0);
|
| */
|
| const float halfpi = 1.5707963267948966192313216916398;
| const float pi = 3.1415926535897932384626433832795;
| const float JINC2_WINDOW_SINC = 0.42;
| const float JINC2_SINC = 0.92;
| const float wa = JINC2_WINDOW_SINC*pi;
| const float wb = JINC2_SINC*pi;
| const float JINC2_AR_STRENGTH = 0.8;
|
| /*
| const vec2 OGLSize = vec2( 4096.0, 2048.0 );
|
| const vec2 OGLInvSize = vec2( 1.0/4096.0, 1.0/2048.0 );
|
| const vec2 dx = vec2( 1.0/4096.0, 0.0 );
|
| const vec2 dy = vec2( 0.0, 1.0/2048.0 );
|
| */
| /*
| const vec2 OGLSize = vec2( 1024.0, 512.0);
|
| const vec2 OGLInvSize = vec2( 0.0009765625, 0.001953125);
|
| const vec2 dx = vec2( 0.0009765625, 0.0);
|
| const vec2 dy = vec2( 0.0, 0.001953125 );
|
| */
|
| //uniform vec4 OGL2InvSize;
| //uniform vec4 OGL2Size;
|
| float reduce(vec3 A)
| {
| return dot(A, dtt);
| }
|
|
| // Calculates the distance between two points
| float d(vec2 pt1, vec2 pt2)
| {
| vec2 v = pt2 - pt1;
| return sqrt(dot(v,v));
| }
|
| vec3 min4(vec3 a, vec3 b, vec3 c, vec3 d)
| {
| return min(a, min(b, min(c, d)));
| }
|
| vec3 max4(vec3 a, vec3 b, vec3 c, vec3 d)
| {
| return max(a, max(b, max(c, d)));
| }
|
| vec4 resampler(vec4 x)
| {
| vec4 res;
|
| res = (x==vec4(0.0, 0.0, 0.0, 0.0)) ? vec4(wa*wb) : sin(x*wa)*sin(x*wb)/(x*x);
|
| return res;
| }
|
|
|
| uniform sampler2D OGL2Texture;
|
| void main()
| {
| vec3 color, E;
| vec2 OGL2Size = vec2(1024, 512);
| vec2 OGL2InvSize = 1.0/OGL2Size;
|
| vec2 dx = vec2(OGL2InvSize.x,0.0);
| vec2 dy = vec2(0.0, OGL2InvSize.y);
|
| vec2 pix_coord = gl_TexCoord[0].xy*OGL2Size+vec2(-0.5,0.5);
| vec2 tex = (floor(gl_TexCoord[0].xy*OGL2Size) + vec2(0.5, 0.5))/OGL2Size;
|
| vec2 tc = (floor(pix_coord)+vec2(0.5,0.5))/OGL2Size;
|
| vec2 fp = fract(pix_coord);
|
| vec3 c00 = GAMMA_IN(texture2D(OGL2Texture, tc - dx - dy).xyz);
| vec3 c01 = GAMMA_IN(texture2D(OGL2Texture, tc - dy).xyz);
| vec3 c02 = GAMMA_IN(texture2D(OGL2Texture, tc + dx - dy).xyz);
| vec3 c03 = GAMMA_IN(texture2D(OGL2Texture, tc + 2.0*dx - dy).xyz);
| vec3 c10 = GAMMA_IN(texture2D(OGL2Texture, tc - dx).xyz);
| vec3 c11 = GAMMA_IN(texture2D(OGL2Texture, tc ).xyz);
| vec3 c12 = GAMMA_IN(texture2D(OGL2Texture, tc + dx).xyz);
| vec3 c13 = GAMMA_IN(texture2D(OGL2Texture, tc + 2.0*dx).xyz);
|
| color = E = GAMMA_IN(texture2D(OGL2Texture, gl_TexCoord[0].xy).xyz);
|
| vec3 F0 = texture2D(OGL2Texture, tex +dx+0.25*dx +0.25*dy).xyz;
| vec3 F1 = texture2D(OGL2Texture, tex +dx+0.25*dx -0.25*dy).xyz;
| vec3 F2 = texture2D(OGL2Texture, tex +dx-0.25*dx -0.25*dy).xyz;
| vec3 F3 = texture2D(OGL2Texture, tex +dx-0.25*dx +0.25*dy).xyz;
|
| vec3 H0 = texture2D(OGL2Texture, tex +0.25*dx +0.25*dy+dy).xyz;
| vec3 H1 = texture2D(OGL2Texture, tex +0.25*dx -0.25*dy+dy).xyz;
| vec3 H2 = texture2D(OGL2Texture, tex -0.25*dx -0.25*dy+dy).xyz;
| vec3 H3 = texture2D(OGL2Texture, tex -0.25*dx +0.25*dy+dy).xyz;
|
| float f0 = reduce(F0);
| float f1 = reduce(F1);
| float f2 = reduce(F2);
| float f3 = reduce(F3);
|
| float h0 = reduce(H0);
| float h1 = reduce(H1);
| float h2 = reduce(H2);
| float h3 = reduce(H3);
|
| float block_3d = (float(f0==f1)*float(f1==f2)*float(f2==f3)*float(h0==h1)*float(h1==h2)*float(h2==h3));
|
|
| #ifdef ANTI_RINGING
| // Get min/max samples
| vec3 min_sample = min(min(c01,c11), min(c02,c12));
| vec3 max_sample = max(max(c01,c11), max(c02,c12));
| // vec3 min_sample = min(min(c01,c11), min(c02,c12)) + (c10-c11)*(c12-c13);
| // vec3 max_sample = max(max(c01,c11), max(c02,c12)) - (c10-c11)*(c12-c13);
| #endif
|
| mat4x3 color_matrix0 = mat4x3(c00, c01, c02, c03);
| mat4x3 color_matrix1 = mat4x3(c10, c11, c12, c13);
|
| vec4 lobes = vec4(fp.x*fp.x*fp.x, fp.x*fp.x, fp.x, 1.0);
|
| vec4 invX_Px = invX * lobes;
| vec3 color0 = color_matrix0 * invX_Px;
| vec3 color1 = color_matrix1 * invX_Px;
|
|
| /*
| vec4 invX_Px = vec4(dot(invX[0], poli), dot(invX[1], poli), dot(invX[2], poli), dot(invX[3], poli));
| vec3 color0 = vec3(dot(color_matrix0[0], invX_Px), dot(color_matrix0[1], invX_Px), dot(color_matrix0[2], invX_Px));
| vec3 color1 = vec3(dot(color_matrix1[0], invX_Px), dot(color_matrix1[1], invX_Px), dot(color_matrix1[2], invX_Px));
| */
|
| /*
| float4x3 color_matrix0 = float4x3(c00, c01, c02, c03);
| float4x3 color_matrix1 = float4x3(c10, c11, c12, c13);
|
| float4 invX_Px = mul(invX, float4(fp.x*fp.x*fp.x, fp.x*fp.x, fp.x, 1.0));
| float3 color0 = mul(invX_Px, color_matrix0);
| float3 color1 = mul(invX_Px, color_matrix1);
| */
|
| #ifdef ANTI_RINGING
| // Anti-ringing
| color0 = clamp(color0, min_sample, max_sample);
| color1 = clamp(color1, min_sample, max_sample);
| #endif
|
| float pos0 = fp.y;
| float pos1 = 1 - fp.y;
|
| vec3 lum0 = mix(vec3(BEAM_MIN_WIDTH), vec3(BEAM_MAX_WIDTH), color0);
| vec3 lum1 = mix(vec3(BEAM_MIN_WIDTH), vec3(BEAM_MAX_WIDTH), color1);
|
| vec3 d0 = clamp(pos0/(lum0+0.0000001), 0.0, 1.0);
| vec3 d1 = clamp(pos1/(lum1+0.0000001), 0.0, 1.0);
|
| d0 = exp(-10.0*SCANLINES_STRENGTH*d0*d0);
| d1 = exp(-10.0*SCANLINES_STRENGTH*d1*d1);
|
| color = clamp(color0*d0+color1*d1, 0.0, 1.0);
|
| color *= COLOR_BOOST;
|
| #ifdef RED_GREEN_CONTROL
| color.rgb *= vec3(RED_BOOST, GREEN_BOOST, CRT_TV_BLUE_TINT);
| #else
| color.b *= CRT_TV_BLUE_TINT;
| #endif
|
| #ifdef PHOSPHOR
| float mod_factor = VAR.texCoord.x * IN.output_size.x * IN.texture_size.x / IN.video_size.x;
|
| vec3 dotMaskWeights = mix(
| vec3(1.0, 0.7, 1.0),
| vec3(0.7, 1.0, 0.7),
| floor(fmod(mod_factor, 2.0))
| );
|
| color.rgb *= dotMaskWeights;
| #endif
|
| color = block_3d ? color : E;
|
| color = GAMMA_OUT(color);
|
| // final sum and weight normalization
| gl_FragColor.xyz = color;
| }
| | |
And Jinc2-Lanchos Sharper-3D
Code: | 1: | 2: | 3: | 4: | 5: | 6: | 7: | 8: | 9: | 10: | 11: | 12: | 13: | 14: | 15: | 16: | 17: | 18: | 19: | 20: | 21: | 22: | 23: | 24: | 25: | 26: | 27: | 28: | 29: | 30: | 31: | 32: | 33: | 34: | 35: | 36: | 37: | 38: | 39: | 40: | 41: | 42: | 43: | 44: | 45: | 46: | 47: | 48: | 49: | 50: | 51: | 52: | 53: | 54: | 55: | 56: | 57: | 58: | 59: | 60: | 61: | 62: | 63: | 64: | 65: | 66: | 67: | 68: | 69: | 70: | 71: | 72: | 73: | 74: | 75: | 76: | 77: | 78: | 79: | 80: | 81: | 82: | 83: | 84: | 85: | 86: | 87: | 88: | 89: | 90: | 91: | 92: | 93: | 94: | 95: | 96: | 97: | 98: | 99: | 100: | 101: | 102: | 103: | 104: | 105: | 106: | 107: | 108: | 109: | 110: | 111: | 112: | 113: | 114: | 115: | 116: | 117: | 118: | 119: | 120: | 121: | 122: | 123: | 124: | 125: | 126: | 127: | 128: | 129: | 130: | 131: | 132: | 133: | 134: | 135: | 136: | 137: | 138: | 139: | 140: | 141: | 142: | 143: | 144: | 145: | 146: | 147: | 148: | 149: | 150: | 151: | 152: | 153: | 154: | 155: | 156: | 157: | 158: | 159: | 160: | | | /*
| Hyllian's jinc windowed-jinc 2-lobe 3D sharpest with anti-ringing Shader
|
| Copyright (C) 2011-2015 Hyllian - sergiogdb@gmail.com
|
| Permission is hereby granted, free of charge, to any person obtaining a copy
| of this software and associated documentation files (the "Software"), to deal
| in the Software without restriction, including without limitation the rights
| to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
| copies of the Software, and to permit persons to whom the Software is
| furnished to do so, subject to the following conditions:
|
| The above copyright notice and this permission notice shall be included in
| all copies or substantial portions of the Software.
|
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
| IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
| FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
| AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
| LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
| OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
| THE SOFTWARE.
|
| */
|
| const float halfpi = 1.5707963267948966192313216916398;
| const float pi = 3.1415926535897932384626433832795;
| const float JINC2_WINDOW_SINC = 0.34;
| const float JINC2_SINC = 0.85;
| const float wa = JINC2_WINDOW_SINC*pi;
| const float wb = JINC2_SINC*pi;
| const float JINC2_AR_STRENGTH = 0.8;
|
| const vec3 dtt = vec3(65536,255,1);
|
| float reduce(vec3 A)
| {
| return dot(A, dtt);
| }
|
|
| // Calculates the distance between two points
| float d(vec2 pt1, vec2 pt2)
| {
| vec2 v = pt2 - pt1;
| return sqrt(dot(v,v));
| }
|
| vec3 min4(vec3 a, vec3 b, vec3 c, vec3 d)
| {
| return min(a, min(b, min(c, d)));
| }
|
| vec3 max4(vec3 a, vec3 b, vec3 c, vec3 d)
| {
| return max(a, max(b, max(c, d)));
| }
|
| vec4 resampler(vec4 x)
| {
| vec4 res;
|
| res = (x==vec4(0.0, 0.0, 0.0, 0.0)) ? vec4(wa*wb) : sin(x*wa)*sin(x*wb)/(x*x);
|
| return res;
| }
|
|
|
| uniform sampler2D OGL2Texture;
|
| void main()
| {
|
| vec3 color, E;
| vec4 weights[4];
|
| vec2 Dx = vec2(1.0, 0.0);
| vec2 Dy = vec2(0.0, 1.0);
| vec2 OGL2Size = vec2(1024, 512);
| vec2 OGL2InvSize = 1.0/OGL2Size;
|
| vec2 dx = vec2(OGL2InvSize.x,0.0);
| vec2 dy = vec2(0.0, OGL2InvSize.y);
|
| vec2 pc = gl_TexCoord[0].xy*OGL2Size.xy;
| vec2 tex = (floor(gl_TexCoord[0].xy*OGL2Size) + vec2(0.5, 0.5))/OGL2Size;
|
| vec2 tc = (floor(pc-vec2(0.5,0.5))+vec2(0.5,0.5));
|
| weights[0] = resampler(vec4(d(pc, tc -Dx -Dy), d(pc, tc -Dy), d(pc, tc +Dx -Dy), d(pc, tc+2.0*Dx -Dy)));
| weights[1] = resampler(vec4(d(pc, tc -Dx ), d(pc, tc ), d(pc, tc +Dx ), d(pc, tc+2.0*Dx )));
| weights[2] = resampler(vec4(d(pc, tc -Dx +Dy), d(pc, tc +Dy), d(pc, tc +Dx +Dy), d(pc, tc+2.0*Dx +Dy)));
| weights[3] = resampler(vec4(d(pc, tc -Dx+2.0*Dy), d(pc, tc +2.0*Dy), d(pc, tc +Dx+2.0*Dy), d(pc, tc+2.0*Dx+2.0*Dy)));
|
| tc = tc*OGL2InvSize.xy;
|
| vec3 c00 = texture2D(OGL2Texture, tc -dx -dy).xyz;
| vec3 c10 = texture2D(OGL2Texture, tc -dy).xyz;
| vec3 c20 = texture2D(OGL2Texture, tc +dx -dy).xyz;
| vec3 c30 = texture2D(OGL2Texture, tc+2.0*dx -dy).xyz;
| vec3 c01 = texture2D(OGL2Texture, tc -dx ).xyz;
| vec3 c11 = texture2D(OGL2Texture, tc ).xyz;
| vec3 c21 = texture2D(OGL2Texture, tc +dx ).xyz;
| vec3 c31 = texture2D(OGL2Texture, tc+2.0*dx ).xyz;
| vec3 c02 = texture2D(OGL2Texture, tc -dx +dy).xyz;
| vec3 c12 = texture2D(OGL2Texture, tc +dy).xyz;
| vec3 c22 = texture2D(OGL2Texture, tc +dx +dy).xyz;
| vec3 c32 = texture2D(OGL2Texture, tc+2.0*dx +dy).xyz;
| vec3 c03 = texture2D(OGL2Texture, tc -dx+2.0*dy).xyz;
| vec3 c13 = texture2D(OGL2Texture, tc +2.0*dy).xyz;
| vec3 c23 = texture2D(OGL2Texture, tc +dx+2.0*dy).xyz;
| vec3 c33 = texture2D(OGL2Texture, tc+2.0*dx+2.0*dy).xyz;
|
| color = E = texture2D(OGL2Texture, gl_TexCoord[0].xy).xyz;
|
| vec3 F0 = texture2D(OGL2Texture, tex +dx+0.25*dx +0.25*dy).xyz;
| vec3 F1 = texture2D(OGL2Texture, tex +dx+0.25*dx -0.25*dy).xyz;
| vec3 F2 = texture2D(OGL2Texture, tex +dx-0.25*dx -0.25*dy).xyz;
| vec3 F3 = texture2D(OGL2Texture, tex +dx-0.25*dx +0.25*dy).xyz;
|
| vec3 H0 = texture2D(OGL2Texture, tex +0.25*dx +0.25*dy+dy).xyz;
| vec3 H1 = texture2D(OGL2Texture, tex +0.25*dx -0.25*dy+dy).xyz;
| vec3 H2 = texture2D(OGL2Texture, tex -0.25*dx -0.25*dy+dy).xyz;
| vec3 H3 = texture2D(OGL2Texture, tex -0.25*dx +0.25*dy+dy).xyz;
|
| float f0 = reduce(F0);
| float f1 = reduce(F1);
| float f2 = reduce(F2);
| float f3 = reduce(F3);
|
| float h0 = reduce(H0);
| float h1 = reduce(H1);
| float h2 = reduce(H2);
| float h3 = reduce(H3);
|
| float block_3d = (float(f0==f1)*float(f1==f2)*float(f2==f3)*float(h0==h1)*float(h1==h2)*float(h2==h3));
|
| // Get min/max samples
| vec3 min_sample = min4(c11, c21, c12, c22);
| vec3 max_sample = max4(c11, c21, c12, c22);
|
| color = vec3(dot(weights[0], vec4(c00.x, c10.x, c20.x, c30.x)), dot(weights[0], vec4(c00.y, c10.y, c20.y, c30.y)), dot(weights[0], vec4(c00.z, c10.z, c20.z, c30.z)));
| color+= vec3(dot(weights[1], vec4(c01.x, c11.x, c21.x, c31.x)), dot(weights[1], vec4(c01.y, c11.y, c21.y, c31.y)), dot(weights[1], vec4(c01.z, c11.z, c21.z, c31.z)));
| color+= vec3(dot(weights[2], vec4(c02.x, c12.x, c22.x, c32.x)), dot(weights[2], vec4(c02.y, c12.y, c22.y, c32.y)), dot(weights[2], vec4(c02.z, c12.z, c22.z, c32.z)));
| color+= vec3(dot(weights[3], vec4(c03.x, c13.x, c23.x, c33.x)), dot(weights[3], vec4(c03.y, c13.y, c23.y, c33.y)), dot(weights[3], vec4(c03.z, c13.z, c23.z, c33.z)));
| color = color/(dot(weights[0], vec4(1,1,1,1)) + dot(weights[1], vec4(1,1,1,1)) + dot(weights[2], vec4(1,1,1,1)) + dot(weights[3], vec4(1,1,1,1)));
|
| // Anti-ringing
| vec3 aux = color;
| color = clamp(color, min_sample, max_sample);
| color = mix(aux, color, JINC2_AR_STRENGTH);
|
| color = block_3d ? color : E;
|
| // final sum and weight normalization
| gl_FragColor.xyz = color;
|
| }
| | |
So it is possible to apply shader to static 2D textures only.
Is there is a peace of code I could copy/paste in some other shader to unfilter 3D in that shader?
My knowledge of shaders is nonexistent so copy paste is the only way for me to do something like this.
I tried to merge this filter with 2xGLSL shaders to see how it goes but didnt work, I guess I need some guidance.
So, is there a piece of code I can just copy paste to unfilter 3D only.
Is there a resource that I could use to do this without learning how to code from groundup?
[Dieser Beitrag wurde am 22.03.2016 - 12:51 von wanzer aktualisiert]
|